scripted-diff: rename proxyType to Proxy

-BEGIN VERIFY SCRIPT-
sed -i 's/\<proxyType\>/Proxy/g' $(git grep -l proxyType)
-END VERIFY SCRIPT-
This commit is contained in:
Vasil Dimov 2021-11-08 17:34:32 +01:00
parent e53a8505db
commit 0eea83a85e
No known key found for this signature in database
GPG key ID: 54DF06F64B55CBBF
10 changed files with 30 additions and 30 deletions

View file

@ -1315,7 +1315,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// Check for host lookup allowed before parsing any network related parameters // Check for host lookup allowed before parsing any network related parameters
fNameLookup = args.GetBoolArg("-dns", DEFAULT_NAME_LOOKUP); fNameLookup = args.GetBoolArg("-dns", DEFAULT_NAME_LOOKUP);
proxyType onion_proxy; Proxy onion_proxy;
bool proxyRandomize = args.GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE); bool proxyRandomize = args.GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE);
// -proxy sets a proxy for all outgoing network traffic // -proxy sets a proxy for all outgoing network traffic
@ -1327,7 +1327,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg)); return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
} }
proxyType addrProxy = proxyType(proxyAddr, proxyRandomize); Proxy addrProxy = Proxy(proxyAddr, proxyRandomize);
if (!addrProxy.IsValid()) if (!addrProxy.IsValid())
return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg)); return InitError(strprintf(_("Invalid -proxy address or hostname: '%s'"), proxyArg));
@ -1344,13 +1344,13 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
std::string onionArg = args.GetArg("-onion", ""); std::string onionArg = args.GetArg("-onion", "");
if (onionArg != "") { if (onionArg != "") {
if (onionArg == "0") { // Handle -noonion/-onion=0 if (onionArg == "0") { // Handle -noonion/-onion=0
onion_proxy = proxyType{}; onion_proxy = Proxy{};
} else { } else {
CService addr; CService addr;
if (!Lookup(onionArg, addr, 9050, fNameLookup) || !addr.IsValid()) { if (!Lookup(onionArg, addr, 9050, fNameLookup) || !addr.IsValid()) {
return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg)); return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
} }
onion_proxy = proxyType{addr, proxyRandomize}; onion_proxy = Proxy{addr, proxyRandomize};
} }
} }
@ -1851,7 +1851,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
if (!Lookup(i2psam_arg, addr, 7656, fNameLookup) || !addr.IsValid()) { if (!Lookup(i2psam_arg, addr, 7656, fNameLookup) || !addr.IsValid()) {
return InitError(strprintf(_("Invalid -i2psam address or hostname: '%s'"), i2psam_arg)); return InitError(strprintf(_("Invalid -i2psam address or hostname: '%s'"), i2psam_arg));
} }
SetProxy(NET_I2P, proxyType{addr}); SetProxy(NET_I2P, Proxy{addr});
} else { } else {
SetReachable(NET_I2P, false); SetReachable(NET_I2P, false);
} }

View file

@ -28,7 +28,7 @@ class CNodeStats;
class Coin; class Coin;
class RPCTimerInterface; class RPCTimerInterface;
class UniValue; class UniValue;
class proxyType; class Proxy;
enum class SynchronizationState; enum class SynchronizationState;
enum class TransactionError; enum class TransactionError;
struct CNodeStateStats; struct CNodeStateStats;
@ -97,7 +97,7 @@ public:
virtual void mapPort(bool use_upnp, bool use_natpmp) = 0; virtual void mapPort(bool use_upnp, bool use_natpmp) = 0;
//! Get proxy. //! Get proxy.
virtual bool getProxy(Network net, proxyType& proxy_info) = 0; virtual bool getProxy(Network net, Proxy& proxy_info) = 0;
//! Get number of connections. //! Get number of connections.
virtual size_t getNodeCount(ConnectionDirection flags) = 0; virtual size_t getNodeCount(ConnectionDirection flags) = 0;

View file

@ -447,7 +447,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
// Connect // Connect
bool connected = false; bool connected = false;
std::unique_ptr<Sock> sock; std::unique_ptr<Sock> sock;
proxyType proxy; Proxy proxy;
CAddress addr_bind; CAddress addr_bind;
assert(!addr_bind.IsValid()); assert(!addr_bind.IsValid());
@ -2538,7 +2538,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
return false; return false;
} }
proxyType i2p_sam; Proxy i2p_sam;
if (GetProxy(NET_I2P, i2p_sam)) { if (GetProxy(NET_I2P, i2p_sam)) {
m_i2p_sam_session = std::make_unique<i2p::sam::Session>(gArgs.GetDataDirNet() / "i2p_private_key", m_i2p_sam_session = std::make_unique<i2p::sam::Session>(gArgs.GetDataDirNet() / "i2p_private_key",
i2p_sam.proxy, &interruptNet); i2p_sam.proxy, &interruptNet);

View file

@ -31,8 +31,8 @@
// Settings // Settings
static Mutex g_proxyinfo_mutex; static Mutex g_proxyinfo_mutex;
static proxyType proxyInfo[NET_MAX] GUARDED_BY(g_proxyinfo_mutex); static Proxy proxyInfo[NET_MAX] GUARDED_BY(g_proxyinfo_mutex);
static proxyType nameProxy GUARDED_BY(g_proxyinfo_mutex); static Proxy nameProxy GUARDED_BY(g_proxyinfo_mutex);
int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT; int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
bool fNameLookup = DEFAULT_NAME_LOOKUP; bool fNameLookup = DEFAULT_NAME_LOOKUP;
@ -605,7 +605,7 @@ bool ConnectSocketDirectly(const CService &addrConnect, const Sock& sock, int nT
return true; return true;
} }
bool SetProxy(enum Network net, const proxyType &addrProxy) { bool SetProxy(enum Network net, const Proxy &addrProxy) {
assert(net >= 0 && net < NET_MAX); assert(net >= 0 && net < NET_MAX);
if (!addrProxy.IsValid()) if (!addrProxy.IsValid())
return false; return false;
@ -614,7 +614,7 @@ bool SetProxy(enum Network net, const proxyType &addrProxy) {
return true; return true;
} }
bool GetProxy(enum Network net, proxyType &proxyInfoOut) { bool GetProxy(enum Network net, Proxy &proxyInfoOut) {
assert(net >= 0 && net < NET_MAX); assert(net >= 0 && net < NET_MAX);
LOCK(g_proxyinfo_mutex); LOCK(g_proxyinfo_mutex);
if (!proxyInfo[net].IsValid()) if (!proxyInfo[net].IsValid())
@ -623,7 +623,7 @@ bool GetProxy(enum Network net, proxyType &proxyInfoOut) {
return true; return true;
} }
bool SetNameProxy(const proxyType &addrProxy) { bool SetNameProxy(const Proxy &addrProxy) {
if (!addrProxy.IsValid()) if (!addrProxy.IsValid())
return false; return false;
LOCK(g_proxyinfo_mutex); LOCK(g_proxyinfo_mutex);
@ -631,7 +631,7 @@ bool SetNameProxy(const proxyType &addrProxy) {
return true; return true;
} }
bool GetNameProxy(proxyType &nameProxyOut) { bool GetNameProxy(Proxy &nameProxyOut) {
LOCK(g_proxyinfo_mutex); LOCK(g_proxyinfo_mutex);
if(!nameProxy.IsValid()) if(!nameProxy.IsValid())
return false; return false;
@ -653,7 +653,7 @@ bool IsProxy(const CNetAddr &addr) {
return false; return false;
} }
bool ConnectThroughProxy(const proxyType& proxy, const std::string& strDest, uint16_t port, const Sock& sock, int nTimeout, bool& outProxyConnectionFailed) bool ConnectThroughProxy(const Proxy& proxy, const std::string& strDest, uint16_t port, const Sock& sock, int nTimeout, bool& outProxyConnectionFailed)
{ {
// first connect to proxy server // first connect to proxy server
if (!ConnectSocketDirectly(proxy.proxy, sock, nTimeout, true)) { if (!ConnectSocketDirectly(proxy.proxy, sock, nTimeout, true)) {

View file

@ -45,11 +45,11 @@ static inline bool operator&(ConnectionDirection a, ConnectionDirection b) {
return (underlying(a) & underlying(b)); return (underlying(a) & underlying(b));
} }
class proxyType class Proxy
{ {
public: public:
proxyType(): randomize_credentials(false) {} Proxy(): randomize_credentials(false) {}
explicit proxyType(const CService &_proxy, bool _randomize_credentials=false): proxy(_proxy), randomize_credentials(_randomize_credentials) {} explicit Proxy(const CService &_proxy, bool _randomize_credentials=false): proxy(_proxy), randomize_credentials(_randomize_credentials) {}
bool IsValid() const { return proxy.IsValid(); } bool IsValid() const { return proxy.IsValid(); }
@ -73,8 +73,8 @@ enum Network ParseNetwork(const std::string& net);
std::string GetNetworkName(enum Network net); std::string GetNetworkName(enum Network net);
/** Return a vector of publicly routable Network names; optionally append NET_UNROUTABLE. */ /** Return a vector of publicly routable Network names; optionally append NET_UNROUTABLE. */
std::vector<std::string> GetNetworkNames(bool append_unroutable = false); std::vector<std::string> GetNetworkNames(bool append_unroutable = false);
bool SetProxy(enum Network net, const proxyType &addrProxy); bool SetProxy(enum Network net, const Proxy &addrProxy);
bool GetProxy(enum Network net, proxyType &proxyInfoOut); bool GetProxy(enum Network net, Proxy &proxyInfoOut);
bool IsProxy(const CNetAddr &addr); bool IsProxy(const CNetAddr &addr);
/** /**
* Set the name proxy to use for all connections to nodes specified by a * Set the name proxy to use for all connections to nodes specified by a
@ -92,9 +92,9 @@ bool IsProxy(const CNetAddr &addr);
* server in common use (most notably Tor) actually implements UDP * server in common use (most notably Tor) actually implements UDP
* support, and a DNS resolver is beyond the scope of this project. * support, and a DNS resolver is beyond the scope of this project.
*/ */
bool SetNameProxy(const proxyType &addrProxy); bool SetNameProxy(const Proxy &addrProxy);
bool HaveNameProxy(); bool HaveNameProxy();
bool GetNameProxy(proxyType &nameProxyOut); bool GetNameProxy(Proxy &nameProxyOut);
using DNSLookupFn = std::function<std::vector<CNetAddr>(const std::string&, bool)>; using DNSLookupFn = std::function<std::vector<CNetAddr>(const std::string&, bool)>;
extern DNSLookupFn g_dns_lookup; extern DNSLookupFn g_dns_lookup;
@ -218,7 +218,7 @@ bool ConnectSocketDirectly(const CService &addrConnect, const Sock& sock, int nT
* *
* @returns Whether or not the operation succeeded. * @returns Whether or not the operation succeeded.
*/ */
bool ConnectThroughProxy(const proxyType& proxy, const std::string& strDest, uint16_t port, const Sock& sock, int nTimeout, bool& outProxyConnectionFailed); bool ConnectThroughProxy(const Proxy& proxy, const std::string& strDest, uint16_t port, const Sock& sock, int nTimeout, bool& outProxyConnectionFailed);
/** Disable or enable blocking-mode for a socket */ /** Disable or enable blocking-mode for a socket */
bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking); bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking);

View file

@ -113,7 +113,7 @@ public:
} }
bool shutdownRequested() override { return ShutdownRequested(); } bool shutdownRequested() override { return ShutdownRequested(); }
void mapPort(bool use_upnp, bool use_natpmp) override { StartMapPort(use_upnp, use_natpmp); } void mapPort(bool use_upnp, bool use_natpmp) override { StartMapPort(use_upnp, use_natpmp); }
bool getProxy(Network net, proxyType& proxy_info) override { return GetProxy(net, proxy_info); } bool getProxy(Network net, Proxy& proxy_info) override { return GetProxy(net, proxy_info); }
size_t getNodeCount(ConnectionDirection flags) override size_t getNodeCount(ConnectionDirection flags) override
{ {
return m_context->connman ? m_context->connman->GetNodeCount(flags) : 0; return m_context->connman ? m_context->connman->GetNodeCount(flags) : 0;

View file

@ -328,7 +328,7 @@ void ClientModel::unsubscribeFromCoreSignals()
bool ClientModel::getProxyInfo(std::string& ip_port) const bool ClientModel::getProxyInfo(std::string& ip_port) const
{ {
proxyType ipv4, ipv6; Proxy ipv4, ipv6;
if (m_node.getProxy((Network) 1, ipv4) && m_node.getProxy((Network) 2, ipv6)) { if (m_node.getProxy((Network) 1, ipv4) && m_node.getProxy((Network) 2, ipv6)) {
ip_port = ipv4.proxy.ToStringIPPort(); ip_port = ipv4.proxy.ToStringIPPort();
return true; return true;

View file

@ -392,7 +392,7 @@ void OptionsDialog::updateProxyValidationState()
void OptionsDialog::updateDefaultProxyNets() void OptionsDialog::updateDefaultProxyNets()
{ {
proxyType proxy; Proxy proxy;
std::string strProxy; std::string strProxy;
QString strDefaultProxyGUI; QString strDefaultProxyGUI;
@ -422,7 +422,7 @@ QValidator::State ProxyAddressValidator::validate(QString &input, int &pos) cons
Q_UNUSED(pos); Q_UNUSED(pos);
// Validate the proxy // Validate the proxy
CService serv(LookupNumeric(input.toStdString(), DEFAULT_GUI_PROXY_PORT)); CService serv(LookupNumeric(input.toStdString(), DEFAULT_GUI_PROXY_PORT));
proxyType addrProxy = proxyType(serv, true); Proxy addrProxy = Proxy(serv, true);
if (addrProxy.IsValid()) if (addrProxy.IsValid())
return QValidator::Acceptable; return QValidator::Acceptable;

View file

@ -567,7 +567,7 @@ static UniValue GetNetworksInfo()
for (int n = 0; n < NET_MAX; ++n) { for (int n = 0; n < NET_MAX; ++n) {
enum Network network = static_cast<enum Network>(n); enum Network network = static_cast<enum Network>(n);
if (network == NET_UNROUTABLE || network == NET_INTERNAL) continue; if (network == NET_UNROUTABLE || network == NET_INTERNAL) continue;
proxyType proxy; Proxy proxy;
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
GetProxy(network, proxy); GetProxy(network, proxy);
obj.pushKV("name", GetNetworkName(network)); obj.pushKV("name", GetNetworkName(network));

View file

@ -378,7 +378,7 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
// if -onion isn't set to something else. // if -onion isn't set to something else.
if (gArgs.GetArg("-onion", "") == "") { if (gArgs.GetArg("-onion", "") == "") {
CService resolved(LookupNumeric("127.0.0.1", 9050)); CService resolved(LookupNumeric("127.0.0.1", 9050));
proxyType addrOnion = proxyType(resolved, true); Proxy addrOnion = Proxy(resolved, true);
SetProxy(NET_ONION, addrOnion); SetProxy(NET_ONION, addrOnion);
const auto onlynets = gArgs.GetArgs("-onlynet"); const auto onlynets = gArgs.GetArgs("-onlynet");