diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-08-07 15:09:45 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-08-07 15:09:45 +0200 |
commit | f5be5b7e7be454291f6bb1cd04d95c4587c64992 (patch) | |
tree | 263eba5341ca6fa45f7aacd630327d9cb3f23e64 /src/common | |
parent | Merge pull request #2206 (diff) | |
parent | Move OpenAlias console input back from libs (diff) | |
download | monero-f5be5b7e7be454291f6bb1cd04d95c4587c64992.tar.xz |
Merge pull request #2210
cb0b5594 Move OpenAlias console input back from libs (moneromooo-monero)
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/dns_utils.cpp | 46 | ||||
-rw-r--r-- | src/common/dns_utils.h | 2 |
2 files changed, 4 insertions, 44 deletions
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp index 979f34b3e..e7ff11c5c 100644 --- a/src/common/dns_utils.cpp +++ b/src/common/dns_utils.cpp @@ -26,12 +26,9 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "common/command_line.h" -#include "common/i18n.h" #include "common/dns_utils.h" +#include "common/i18n.h" #include "cryptonote_basic/cryptonote_basic_impl.h" -#include <cstring> -#include <sstream> // check local first (in the event of static or in-source compilation of libunbound) #include "unbound.h" @@ -401,7 +398,7 @@ std::vector<std::string> addresses_from_url(const std::string& url, bool& dnssec return addresses; } -std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, bool cli_confirm) +std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> dns_confirm) { // attempt to get address from dns query auto addresses = addresses_from_url(url, dnssec_valid); @@ -410,44 +407,7 @@ std::string get_account_address_as_str_from_url(const std::string& url, bool& dn LOG_ERROR("wrong address: " << url); return {}; } - // for now, move on only if one address found - if (addresses.size() > 1) - { - LOG_ERROR("not yet supported: Multiple Monero addresses found for given URL: " << url); - return {}; - } - if (!cli_confirm) - return addresses[0]; - // prompt user for confirmation. - // inform user of DNSSEC validation status as well. - std::string dnssec_str; - if (dnssec_valid) - { - dnssec_str = tr("DNSSEC validation passed"); - } - else - { - dnssec_str = tr("WARNING: DNSSEC validation was unsuccessful, this address may not be correct!"); - } - std::stringstream prompt; - prompt << tr("For URL: ") << url - << ", " << dnssec_str << std::endl - << tr(" Monero Address = ") << addresses[0] - << std::endl - << tr("Is this OK? (Y/n) ") - ; - // prompt the user for confirmation given the dns query and dnssec status - std::string confirm_dns_ok = command_line::input_line(prompt.str()); - if (std::cin.eof()) - { - return {}; - } - if (!command_line::is_yes(confirm_dns_ok)) - { - std::cout << tr("you have cancelled the transfer request") << std::endl; - return {}; - } - return addresses[0]; + return dns_confirm(url, addresses, dnssec_valid); } namespace diff --git a/src/common/dns_utils.h b/src/common/dns_utils.h index 7a093db51..69b32f435 100644 --- a/src/common/dns_utils.h +++ b/src/common/dns_utils.h @@ -163,7 +163,7 @@ namespace dns_utils std::string address_from_txt_record(const std::string& s); std::vector<std::string> addresses_from_url(const std::string& url, bool& dnssec_valid); -std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, bool cli_confirm = true); +std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> confirm_dns); bool load_txt_records_from_dns(std::vector<std::string> &records, const std::vector<std::string> &dns_urls); |