diff options
author | Vasil Dimov <vd@FreeBSD.org> | 2022-07-18 13:28:40 +0200 |
---|---|---|
committer | Vasil Dimov <vd@FreeBSD.org> | 2022-12-12 11:48:30 +0100 |
commit | 043b9de59aec88ae5e29daac7dc2a8b51a9414ce (patch) | |
tree | 7f589d495a380d93040ca9b7aabab3862a29d746 | |
parent | 6061eb6564105ad54703a7cf3282590d0e1a7f28 (diff) | |
download | bitcoin-043b9de59aec88ae5e29daac7dc2a8b51a9414ce.tar.xz |
scripted-diff: rename ToStringIP[Port]() to ToStringAddr[Port]()
"IP" stands for "Internet Protocol".
"IP address" is sometimes shortened to just "IP" or "address".
However, Tor or I2P addresses are not "IP addresses", nor "IPs".
Thus, use "Addr" instead of "IP" for addresses that could be IP, Tor or
I2P addresses:
`CService::ToStringIPPort()` -> `CService::ToStringAddrPort()`
`CNetAddr::ToStringIP()` -> `CNetAddr::ToStringAddr()`
-BEGIN VERIFY SCRIPT-
sed -i 's/ToStringIPPort/ToStringAddrPort/g' -- $(git grep -l ToStringIPPort src)
sed -i 's/ToStringIP/ToStringAddr/g' -- $(git grep -l ToStringIP src)
-END VERIFY SCRIPT-
-rw-r--r-- | src/i2p.cpp | 2 | ||||
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/net.cpp | 6 | ||||
-rw-r--r-- | src/netaddress.cpp | 12 | ||||
-rw-r--r-- | src/netaddress.h | 4 | ||||
-rw-r--r-- | src/qt/clientmodel.cpp | 2 | ||||
-rw-r--r-- | src/qt/optionsdialog.cpp | 6 | ||||
-rw-r--r-- | src/rpc/net.cpp | 4 | ||||
-rw-r--r-- | src/test/fuzz/netaddress.cpp | 4 | ||||
-rw-r--r-- | src/torcontrol.cpp | 4 |
10 files changed, 23 insertions, 23 deletions
diff --git a/src/i2p.cpp b/src/i2p.cpp index d54486ecff..9778ef8b76 100644 --- a/src/i2p.cpp +++ b/src/i2p.cpp @@ -206,7 +206,7 @@ bool Session::Connect(const CService& to, Connection& conn, bool& proxy_error) } const Reply& lookup_reply = - SendRequestAndGetReply(*sock, strprintf("NAMING LOOKUP NAME=%s", to.ToStringIP())); + SendRequestAndGetReply(*sock, strprintf("NAMING LOOKUP NAME=%s", to.ToStringAddr())); const std::string& dest = lookup_reply.Get("VALUE"); diff --git a/src/init.cpp b/src/init.cpp index f31a45aa9f..ac2830e10a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1784,7 +1784,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) if (connOptions.onion_binds.size() > 1) { InitWarning(strprintf(_("More than one onion bind address is provided. Using %s " "for the automatically created Tor onion service."), - onion_service_target.ToStringIPPort())); + onion_service_target.ToStringAddrPort())); } StartTorControl(onion_service_target); } diff --git a/src/net.cpp b/src/net.cpp index 374e93a2bd..078624146f 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -405,7 +405,7 @@ CNode* CConnman::FindNode(const CService& addr) bool CConnman::AlreadyConnectedToAddress(const CAddress& addr) { - return FindNode(static_cast<CNetAddr>(addr)) || FindNode(addr.ToStringIPPort()); + return FindNode(static_cast<CNetAddr>(addr)) || FindNode(addr.ToStringAddrPort()); } bool CConnman::CheckIncomingNonce(uint64_t nonce) @@ -509,7 +509,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo if (!sock) { return nullptr; } - connected = ConnectThroughProxy(proxy, addrConnect.ToStringIP(), addrConnect.GetPort(), + connected = ConnectThroughProxy(proxy, addrConnect.ToStringAddr(), addrConnect.GetPort(), *sock, nConnectTimeout, proxyConnectionFailed); } else { // no proxy needed (none set for target network) @@ -2742,7 +2742,7 @@ CNode::CNode(NodeId idIn, m_connected{GetTime<std::chrono::seconds>()}, addr{addrIn}, addrBind{addrBindIn}, - m_addr_name{addrNameIn.empty() ? addr.ToStringIPPort() : addrNameIn}, + m_addr_name{addrNameIn.empty() ? addr.ToStringAddrPort() : addrNameIn}, m_inbound_onion{inbound_onion}, m_prefer_evict{node_opts.prefer_evict}, nKeyedNetGroup{nKeyedNetGroupIn}, diff --git a/src/netaddress.cpp b/src/netaddress.cpp index eabab3dd99..0b554dc3a2 100644 --- a/src/netaddress.cpp +++ b/src/netaddress.cpp @@ -599,7 +599,7 @@ std::string OnionToString(Span<const uint8_t> addr) return EncodeBase32(address) + ".onion"; } -std::string CNetAddr::ToStringIP() const +std::string CNetAddr::ToStringAddr() const { switch (m_net) { case NET_IPV4: @@ -624,7 +624,7 @@ std::string CNetAddr::ToStringIP() const std::string CNetAddr::ToString() const { - return ToStringIP(); + return ToStringAddr(); } bool operator==(const CNetAddr& a, const CNetAddr& b) @@ -921,18 +921,18 @@ std::string CService::ToStringPort() const return strprintf("%u", port); } -std::string CService::ToStringIPPort() const +std::string CService::ToStringAddrPort() const { if (IsIPv4() || IsTor() || IsI2P() || IsInternal()) { - return ToStringIP() + ":" + ToStringPort(); + return ToStringAddr() + ":" + ToStringPort(); } else { - return "[" + ToStringIP() + "]:" + ToStringPort(); + return "[" + ToStringAddr() + "]:" + ToStringPort(); } } std::string CService::ToString() const { - return ToStringIPPort(); + return ToStringAddrPort(); } CSubNet::CSubNet(): diff --git a/src/netaddress.h b/src/netaddress.h index 11086eaee0..0db23b8efd 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -194,7 +194,7 @@ public: enum Network GetNetwork() const; std::string ToString() const; - std::string ToStringIP() const; + std::string ToStringAddr() const; bool GetInAddr(struct in_addr* pipv4Addr) const; Network GetNetClass() const; @@ -538,7 +538,7 @@ public: std::vector<unsigned char> GetKey() const; std::string ToString() const; std::string ToStringPort() const; - std::string ToStringIPPort() const; + std::string ToStringAddrPort() const; CService(const struct in6_addr& ipv6Addr, uint16_t port); explicit CService(const struct sockaddr_in6& addr); diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 092ffe7e5b..e2b8cfffef 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -287,7 +287,7 @@ bool ClientModel::getProxyInfo(std::string& ip_port) const { Proxy ipv4, ipv6; if (m_node.getProxy((Network) 1, ipv4) && m_node.getProxy((Network) 2, ipv6)) { - ip_port = ipv4.proxy.ToStringIPPort(); + ip_port = ipv4.proxy.ToStringAddrPort(); return true; } return false; diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 7c91eac37e..7b01d420d2 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -413,17 +413,17 @@ void OptionsDialog::updateDefaultProxyNets() QString strDefaultProxyGUI; model->node().getProxy(NET_IPV4, proxy); - strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort(); + strProxy = proxy.proxy.ToStringAddr() + ":" + proxy.proxy.ToStringPort(); strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text(); (strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachIPv4->setChecked(true) : ui->proxyReachIPv4->setChecked(false); model->node().getProxy(NET_IPV6, proxy); - strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort(); + strProxy = proxy.proxy.ToStringAddr() + ":" + proxy.proxy.ToStringPort(); strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text(); (strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachIPv6->setChecked(true) : ui->proxyReachIPv6->setChecked(false); model->node().getProxy(NET_ONION, proxy); - strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort(); + strProxy = proxy.proxy.ToStringAddr() + ":" + proxy.proxy.ToStringPort(); strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text(); (strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachTor->setChecked(true) : ui->proxyReachTor->setChecked(false); } diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 1a4cd09284..c0a939e9c8 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -568,7 +568,7 @@ static UniValue GetNetworksInfo() obj.pushKV("name", GetNetworkName(network)); obj.pushKV("limited", !IsReachable(network)); obj.pushKV("reachable", IsReachable(network)); - obj.pushKV("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string()); + obj.pushKV("proxy", proxy.IsValid() ? proxy.proxy.ToStringAddrPort() : std::string()); obj.pushKV("proxy_randomize_credentials", proxy.randomize_credentials); networks.push_back(obj); } @@ -902,7 +902,7 @@ static RPCHelpMan getnodeaddresses() UniValue obj(UniValue::VOBJ); obj.pushKV("time", int64_t{TicksSinceEpoch<std::chrono::seconds>(addr.nTime)}); obj.pushKV("services", (uint64_t)addr.nServices); - obj.pushKV("address", addr.ToStringIP()); + obj.pushKV("address", addr.ToStringAddr()); obj.pushKV("port", addr.GetPort()); obj.pushKV("network", GetNetworkName(addr.GetNetClass())); ret.push_back(obj); diff --git a/src/test/fuzz/netaddress.cpp b/src/test/fuzz/netaddress.cpp index 2022f16a48..d71bbcf812 100644 --- a/src/test/fuzz/netaddress.cpp +++ b/src/test/fuzz/netaddress.cpp @@ -71,7 +71,7 @@ FUZZ_TARGET(netaddress) } (void)net_addr.IsValid(); (void)net_addr.ToString(); - (void)net_addr.ToStringIP(); + (void)net_addr.ToStringAddr(); const CSubNet sub_net{net_addr, fuzzed_data_provider.ConsumeIntegral<uint8_t>()}; (void)sub_net.IsValid(); @@ -81,7 +81,7 @@ FUZZ_TARGET(netaddress) (void)service.GetKey(); (void)service.GetPort(); (void)service.ToString(); - (void)service.ToStringIPPort(); + (void)service.ToStringAddrPort(); (void)service.ToStringPort(); (void)CServiceHash()(service); (void)CServiceHash(0, 0)(service); diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 3a21a79a34..ecffa6762c 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -380,7 +380,7 @@ void TorController::get_socks_cb(TorControlConnection& _conn, const TorControlRe } Assume(resolved.IsValid()); - LogPrint(BCLog::TOR, "Configuring onion proxy for %s\n", resolved.ToStringIPPort()); + LogPrint(BCLog::TOR, "Configuring onion proxy for %s\n", resolved.ToStringAddrPort()); Proxy addrOnion = Proxy(resolved, true); SetProxy(NET_ONION, addrOnion); @@ -453,7 +453,7 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply& } // Request onion service, redirect port. // Note that the 'virtual' port is always the default port to avoid decloaking nodes using other ports. - _conn.Command(strprintf("ADD_ONION %s Port=%i,%s", private_key, Params().GetDefaultPort(), m_target.ToStringIPPort()), + _conn.Command(strprintf("ADD_ONION %s Port=%i,%s", private_key, Params().GetDefaultPort(), m_target.ToStringAddrPort()), std::bind(&TorController::add_onion_cb, this, std::placeholders::_1, std::placeholders::_2)); } else { LogPrintf("tor: Authentication failed\n"); |