Skip to content

Commit

Permalink
net: disable resolving from storage structures
Browse files Browse the repository at this point in the history
CNetAddr/CService/CSubnet can no longer resolve DNS.
  • Loading branch information
theuni committed Apr 20, 2016
1 parent 3675699 commit d39f5b4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
28 changes: 14 additions & 14 deletions src/netbase.cpp
Expand Up @@ -688,19 +688,19 @@ CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr, const uint32_t scope)
scopeId = scope;
}

CNetAddr::CNetAddr(const char *pszIp, bool fAllowLookup)
CNetAddr::CNetAddr(const char *pszIp)
{
Init();
std::vector<CNetAddr> vIP;
if (LookupHost(pszIp, vIP, 1, fAllowLookup))
if (LookupHost(pszIp, vIP, 1, false))
*this = vIP[0];
}

CNetAddr::CNetAddr(const std::string &strIp, bool fAllowLookup)
CNetAddr::CNetAddr(const std::string &strIp)
{
Init();
std::vector<CNetAddr> vIP;
if (LookupHost(strIp.c_str(), vIP, 1, fAllowLookup))
if (LookupHost(strIp.c_str(), vIP, 1, false))
*this = vIP[0];
}

Expand Down Expand Up @@ -1123,35 +1123,35 @@ bool CService::SetSockAddr(const struct sockaddr *paddr)
}
}

CService::CService(const char *pszIpPort, bool fAllowLookup)
CService::CService(const char *pszIpPort)
{
Init();
CService ip;
if (Lookup(pszIpPort, ip, 0, fAllowLookup))
if (Lookup(pszIpPort, ip, 0, false))
*this = ip;
}

CService::CService(const char *pszIpPort, int portDefault, bool fAllowLookup)
CService::CService(const char *pszIpPort, int portDefault)
{
Init();
CService ip;
if (Lookup(pszIpPort, ip, portDefault, fAllowLookup))
if (Lookup(pszIpPort, ip, portDefault, false))
*this = ip;
}

CService::CService(const std::string &strIpPort, bool fAllowLookup)
CService::CService(const std::string &strIpPort)
{
Init();
CService ip;
if (Lookup(strIpPort.c_str(), ip, 0, fAllowLookup))
if (Lookup(strIpPort.c_str(), ip, 0, false))
*this = ip;
}

CService::CService(const std::string &strIpPort, int portDefault, bool fAllowLookup)
CService::CService(const std::string &strIpPort, int portDefault)
{
Init();
CService ip;
if (Lookup(strIpPort.c_str(), ip, portDefault, fAllowLookup))
if (Lookup(strIpPort.c_str(), ip, portDefault, false))
*this = ip;
}

Expand Down Expand Up @@ -1245,7 +1245,7 @@ CSubNet::CSubNet():
memset(netmask, 0, sizeof(netmask));
}

CSubNet::CSubNet(const std::string &strSubnet, bool fAllowLookup)
CSubNet::CSubNet(const std::string &strSubnet)
{
size_t slash = strSubnet.find_last_of('/');
std::vector<CNetAddr> vIP;
Expand All @@ -1255,7 +1255,7 @@ CSubNet::CSubNet(const std::string &strSubnet, bool fAllowLookup)
memset(netmask, 255, sizeof(netmask));

std::string strAddress = strSubnet.substr(0, slash);
if (LookupHost(strAddress.c_str(), vIP, 1, fAllowLookup))
if (LookupHost(strAddress.c_str(), vIP, 1, false))
{
network = vIP[0];
if (slash != strSubnet.npos)
Expand Down
14 changes: 7 additions & 7 deletions src/netbase.h
Expand Up @@ -49,8 +49,8 @@ class CNetAddr
public:
CNetAddr();
CNetAddr(const struct in_addr& ipv4Addr);
explicit CNetAddr(const char *pszIp, bool fAllowLookup = false);
explicit CNetAddr(const std::string &strIp, bool fAllowLookup = false);
explicit CNetAddr(const char *pszIp);
explicit CNetAddr(const std::string &strIp);
void Init();
void SetIP(const CNetAddr& ip);

Expand Down Expand Up @@ -119,7 +119,7 @@ class CSubNet

public:
CSubNet();
explicit CSubNet(const std::string &strSubnet, bool fAllowLookup = false);
explicit CSubNet(const std::string &strSubnet);

//constructor for single ip subnet (<ipv4>/32 or <ipv6>/128)
explicit CSubNet(const CNetAddr &addr);
Expand Down Expand Up @@ -154,10 +154,10 @@ class CService : public CNetAddr
CService(const CNetAddr& ip, unsigned short port);
CService(const struct in_addr& ipv4Addr, unsigned short port);
CService(const struct sockaddr_in& addr);
explicit CService(const char *pszIpPort, int portDefault, bool fAllowLookup = false);
explicit CService(const char *pszIpPort, bool fAllowLookup = false);
explicit CService(const std::string& strIpPort, int portDefault, bool fAllowLookup = false);
explicit CService(const std::string& strIpPort, bool fAllowLookup = false);
explicit CService(const char *pszIpPort, int portDefault);
explicit CService(const char *pszIpPort);
explicit CService(const std::string& strIpPort, int portDefault);
explicit CService(const std::string& strIpPort);
void Init();
void SetPort(unsigned short portIn);
unsigned short GetPort() const;
Expand Down
2 changes: 1 addition & 1 deletion src/torcontrol.cpp
Expand Up @@ -438,7 +438,7 @@ void TorController::add_onion_cb(TorControlConnection& conn, const TorControlRep
private_key = i->second;
}

service = CService(service_id+".onion", GetListenPort(), false);
service = CService(service_id+".onion", GetListenPort());
LogPrintf("tor: Got service ID %s, advertising service %s\n", service_id, service.ToString());
if (WriteBinaryFile(GetPrivateKeyFile(), private_key)) {
LogPrint("tor", "tor: Cached service private key to %s\n", GetPrivateKeyFile());
Expand Down

0 comments on commit d39f5b4

Please sign in to comment.