CService addrProxy;
bool fProxy = false;
if (mapArgs.count("-proxy")) {
- addrProxy = CService(mapArgs["-proxy"], 9050);
+ addrProxy = CService(mapArgs["-proxy"], nSocksDefault);
if (!addrProxy.IsValid())
return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"].c_str()));
if (!mapArgs.count("-tor"))
addrOnion = addrProxy;
else
- addrOnion = CService(mapArgs["-tor"], 9050);
+ addrOnion = CService(mapArgs["-tor"], nSocksDefault);
if (!addrOnion.IsValid())
return InitError(strprintf(_("Invalid -tor address: '%s'"), mapArgs["-tor"].c_str()));
SetProxy(NET_TOR, addrOnion, 5);
while (!fShutdown)
{
- CService addrConnect("92.243.23.21", 6667); // irc.lfnet.org
+ CService addrConnect("92.243.23.21", (uint16_t)6667); // irc.lfnet.org
- CService addrIRC("irc.lfnet.org", 6667, true);
+ CService addrIRC("irc.lfnet.org", (uint16_t)6667, true);
if (addrIRC.IsValid())
addrConnect = addrIRC;
struct LocalServiceInfo {
int nScore;
- int nPort;
+ uint16_t nPort;
};
//
static bool vfLimited[NET_MAX] = {};
static CNode* pnodeLocalHost = NULL;
static CNode* pnodeSync = NULL;
-CAddress addrSeenByPeer(CService("0.0.0.0", 0), nLocalServices);
+CAddress addrSeenByPeer(CService("0.0.0.0", (uint16_t)0), nLocalServices);
uint64_t nLocalHostNonce = 0;
boost::array<int, THREAD_MAX> vnThreadsRunning;
static std::vector<SOCKET> vhListenSocket;
// get best local address for a particular peer as a CAddress
CAddress GetLocalAddress(const CNetAddr *paddrPeer)
{
- CAddress ret(CService("0.0.0.0",0),0);
+ CAddress ret(CService("0.0.0.0", (uint16_t)0), 0);
CService addr;
if (GetLocal(addr, paddrPeer))
{
}
if (!fHidden) {
- addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
+ addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",(uint16_t)0)));
addrMe = GetLocalAddress(&addr);
}
}
if (pnodeLocalHost == NULL)
- pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices));
+ pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", (uint16_t)0), nLocalServices));
Discover();
class CBlockIndex;
extern int nBestHeight;
+const uint16_t nSocksDefault = 9050;
inline uint64_t ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
return NET_UNROUTABLE;
}
-void SplitHostPort(std::string in, int &portOut, std::string &hostOut) {
+void SplitHostPort(std::string in, uint16_t &portOut, std::string &hostOut) {
size_t colon = in.find_last_of(':');
// if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator
bool fHaveColon = colon != in.npos;
return LookupHost(pszName, vIP, nMaxSolutions, false);
}
-bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
+bool Lookup(const char *pszName, std::vector<CService>& vAddr, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
{
if (pszName[0] == 0)
return false;
- int port = portDefault;
+ uint16_t port = portDefault;
std::string hostname = "";
SplitHostPort(std::string(pszName), port, hostname);
return true;
}
-bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLookup)
+bool Lookup(const char *pszName, CService& addr, uint16_t portDefault, bool fAllowLookup)
{
std::vector<CService> vService;
bool fRet = Lookup(pszName, vService, portDefault, fAllowLookup, 1);
return true;
}
-bool LookupNumeric(const char *pszName, CService& addr, int portDefault)
+bool LookupNumeric(const char *pszName, CService& addr, uint16_t portDefault)
{
return Lookup(pszName, addr, portDefault, false);
}
return true;
}
-bool static Socks5(string strDest, int port, SOCKET& hSocket)
+bool static Socks5(string strDest, uint16_t port, SOCKET& hSocket)
{
printf("SOCKS5 connecting %s\n", strDest.c_str());
if (strDest.size() > 255)
return true;
}
-bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout)
+bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, uint16_t portDefault, int nTimeout)
{
string strDest;
- int port = portDefault;
+ uint16_t port = portDefault;
SplitHostPort(string(pszDest), port, strDest);
SOCKET hSocket = INVALID_SOCKET;
return EncodeBase32(&ip[6], 10) + ".onion";
if (IsI2P())
return EncodeBase32(&ip[6], 10) + ".oc.b32.i2p";
- CService serv(*this, 0);
+ CService serv(*this, (uint16_t)0);
#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
#else
Init();
}
-CService::CService(const CNetAddr& cip, unsigned short portIn) : CNetAddr(cip), port(portIn)
+CService::CService(const CNetAddr& cip, uint16_t portIn) : CNetAddr(cip), port(portIn)
{
}
-CService::CService(const struct in_addr& ipv4Addr, unsigned short portIn) : CNetAddr(ipv4Addr), port(portIn)
+CService::CService(const struct in_addr& ipv4Addr, uint16_t portIn) : CNetAddr(ipv4Addr), port(portIn)
{
}
#ifdef USE_IPV6
-CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn)
+CService::CService(const struct in6_addr& ipv6Addr, uint16_t portIn) : CNetAddr(ipv6Addr), port(portIn)
{
}
#endif
*this = ip;
}
-CService::CService(const char *pszIpPort, int portDefault, bool fAllowLookup)
+CService::CService(const char *pszIpPort, uint16_t portDefault, bool fAllowLookup)
{
Init();
CService ip;
*this = ip;
}
-CService::CService(const std::string &strIpPort, int portDefault, bool fAllowLookup)
+CService::CService(const std::string &strIpPort, uint16_t portDefault, bool fAllowLookup)
{
Init();
CService ip;
public:
CService();
- CService(const CNetAddr& ip, unsigned short port);
- CService(const struct in_addr& ipv4Addr, unsigned short port);
+ CService(const CNetAddr& ip, uint16_t port);
+ CService(const struct in_addr& ipv4Addr, uint16_t port);
CService(const struct sockaddr_in& addr);
- explicit CService(const char *pszIpPort, int portDefault, bool fAllowLookup = false);
+ explicit CService(const char *pszIpPort, uint16_t 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, uint16_t portDefault, bool fAllowLookup = false);
explicit CService(const std::string& strIpPort, bool fAllowLookup = false);
void Init();
- void SetPort(unsigned short portIn);
+ void SetPort(uint16_t portIn);
unsigned short GetPort() const;
bool GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const;
bool SetSockAddr(const struct sockaddr* paddr);
void print() const;
#ifdef USE_IPV6
- CService(const struct in6_addr& ipv6Addr, unsigned short port);
+ CService(const struct in6_addr& ipv6Addr, uint16_t port);
CService(const struct sockaddr_in6& addr);
#endif
typedef std::pair<CService, int> proxyType;
enum Network ParseNetwork(std::string net);
-void SplitHostPort(std::string in, int &portOut, std::string &hostOut);
+void SplitHostPort(std::string in, uint16_t &portOut, std::string &hostOut);
bool SetProxy(enum Network net, CService addrProxy, int nSocksVersion = 5);
bool GetProxy(enum Network net, proxyType &proxyInfoOut);
bool IsProxy(const CNetAddr &addr);
bool HaveNameProxy();
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true);
bool LookupHostNumeric(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0);
-bool Lookup(const char *pszName, CService& addr, int portDefault = 0, bool fAllowLookup = true);
-bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault = 0, bool fAllowLookup = true, unsigned int nMaxSolutions = 0);
-bool LookupNumeric(const char *pszName, CService& addr, int portDefault = 0);
+bool Lookup(const char *pszName, CService& addr, uint16_t portDefault = 0, bool fAllowLookup = true);
+bool Lookup(const char *pszName, std::vector<CService>& vAddr, uint16_t portDefault = 0, bool fAllowLookup = true, unsigned int nMaxSolutions = 0);
+bool LookupNumeric(const char *pszName, CService& addr, uint16_t portDefault = 0);
bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout = nConnectTimeout);
-bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault = 0, int nTimeout = nConnectTimeout);
+bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, uint16_t portDefault = 0, int nTimeout = nConnectTimeout);
#endif
if (GetProxy(NET_IPV4, proxy))
return QVariant(proxy.first.GetPort());
else
- return QVariant(9050);
+ return QVariant(nSocksDefault);
}
case ProxySocksVersion:
return settings.value("nSocksVersion", 5);
if (GetProxy(NET_TOR, proxy))
return QVariant(proxy.first.GetPort());
else
- return QVariant(9050);
+ return QVariant(nSocksDefault);
}
case TorOnly:
return settings.value("fTorOnly", false);
break;
case ProxyIP: {
proxyType proxy;
- proxy.first = CService("127.0.0.1", 9050);
+ proxy.first = CService("127.0.0.1", nSocksDefault);
GetProxy(NET_IPV4, proxy);
CNetAddr addr(value.toString().toStdString());
break;
case ProxyPort: {
proxyType proxy;
- proxy.first = CService("127.0.0.1", 9050);
+ proxy.first = CService("127.0.0.1", nSocksDefault);
GetProxy(NET_IPV4, proxy);
proxy.first.SetPort(value.toInt());
break;
case TorIP: {
proxyType proxy;
- proxy.first = CService("127.0.0.1", 9050);
+ proxy.first = CService("127.0.0.1", nSocksDefault);
GetProxy(NET_TOR, proxy);
CNetAddr addr(value.toString().toStdString());
break;
case TorPort: {
proxyType proxy;
- proxy.first = CService("127.0.0.1", 9050);
+ proxy.first = CService("127.0.0.1", nSocksDefault);
GetProxy(NET_TOR, proxy);
- proxy.first.SetPort(value.toInt());
+ proxy.first.SetPort((uint16_t)value.toUInt());
settings.setValue("addrTor", proxy.first.ToStringIPPort().c_str());
successful = ApplyTorSettings();
}