if (mapArgs.count("-proxy"))
{
fUseProxy = true;
- addrProxy = CAddress(mapArgs["-proxy"]);
+ addrProxy = CService(mapArgs["-proxy"], 9050);
if (!addrProxy.IsValid())
{
wxMessageBox(_("Invalid -proxy address"), "Bitcoin");
{
BOOST_FOREACH(string strAddr, mapMultiArgs["-addnode"])
{
- CAddress addr(strAddr, fAllowDNS);
+ CAddress addr(CService(strAddr, GetDefaultPort(), fAllowDNS));
addr.nTime = 0; // so it won't relay unless successfully connected
if (addr.IsValid())
AddAddress(addr);
// We now get our external IP from the IRC server first and only use this as a backup
bool GetMyExternalIP(CNetAddr& ipRet)
{
- CAddress addrConnect;
+ CService addrConnect;
const char* pszGet;
const char* pszKeyword;
// <?php echo $_SERVER["REMOTE_ADDR"]; ?>
if (nHost == 1)
{
- addrConnect = CAddress("91.198.22.70",80); // checkip.dyndns.org
+ addrConnect = CService("91.198.22.70",80); // checkip.dyndns.org
if (nLookup == 1)
{
}
else if (nHost == 2)
{
- addrConnect = CAddress("74.208.43.192", 80); // www.showmyip.com
+ addrConnect = CService("74.208.43.192", 80); // www.showmyip.com
if (nLookup == 1)
{
{
/// when NTP implemented, change to just nTime = GetAdjustedTime()
int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
- CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
- CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
+ CAddress addrYou = (fUseProxy ? CAddress(CService("0.0.0.0",0)) : addr);
+ CAddress addrMe = (fUseProxy ? CAddress(CService("0.0.0.0",0)) : addrLocalHost);
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight);
{
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
{
- CAddress addr(strAddr, fAllowDNS);
+ CAddress addr(CService(strAddr, GetDefaultPort(), fAllowDNS));
if (addr.IsValid())
OpenNetworkConnection(addr);
for (int i = 0; i < 10 && i < nLoop; i++)
*this = ip;
}
-CService::CService(const char *pszIp, int portIn, bool fAllowLookup)
+CService::CService(const char *pszIpPort, int portDefault, bool fAllowLookup)
{
- std::vector<CNetAddr> ip;
- if (LookupHost(pszIp, ip, 1, fAllowLookup))
- *this = CService(ip[0], portIn);
+ Init();
+ CService ip;
+ if (Lookup(pszIpPort, ip, portDefault, fAllowLookup))
+ *this = ip;
}
CService::CService(const std::string &strIpPort, bool fAllowLookup)
*this = ip;
}
-CService::CService(const std::string &strIp, int portIn, bool fAllowLookup)
+CService::CService(const std::string &strIpPort, int portDefault, bool fAllowLookup)
{
- std::vector<CNetAddr> ip;
- if (LookupHost(strIp.c_str(), ip, 1, fAllowLookup))
- *this = CService(ip[0], portIn);
+ Init();
+ CService ip;
+ if (Lookup(strIpPort.c_str(), ip, portDefault, fAllowLookup))
+ *this = ip;
}
unsigned short CService::GetPort() const
public:
CNetAddr();
CNetAddr(const struct in_addr& ipv4Addr);
- CNetAddr(const char *pszIp, bool fAllowLookup = false);
- CNetAddr(const std::string &strIp, bool fAllowLookup = false);
+ explicit CNetAddr(const char *pszIp, bool fAllowLookup = false);
+ explicit CNetAddr(const std::string &strIp, bool fAllowLookup = false);
void Init();
void SetIP(const CNetAddr& ip);
bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
CService(const CNetAddr& ip, unsigned short port);
CService(const struct in_addr& ipv4Addr, unsigned short port);
CService(const struct sockaddr_in& addr);
- CService(const char *pszIp, int port, bool fAllowLookup = false);
- CService(const char *pszIpPort, bool fAllowLookup = false);
- CService(const std::string& strIp, int port, bool fAllowLookup = false);
- CService(const std::string& strIpPort, bool fAllowLookup = false);
+ 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);
void Init();
void SetPort(unsigned short portIn);
unsigned short GetPort() const;
{
public:
CAddress();
- CAddress(CService ipIn, uint64 nServicesIn=NODE_NETWORK);
+ explicit CAddress(CService ipIn, uint64 nServicesIn=NODE_NETWORK);
void Init();