void ThreadRPCServer3(void* parg);
-static inline unsigned short GetDefaultRPCPort()
+static inline uint16_t GetDefaultRPCPort()
{
return GetBoolArg("-testnet", false) ? 18344 : 8344;
}
struct ircaddr
{
struct in_addr ip;
- unsigned short port;
+ uint16_t port;
};
#pragma pack(pop)
struct stun_addr {
unsigned char unused;
unsigned char family;
- unsigned short port;
+ uint16_t port;
unsigned int addr;
} __attribute__((packed));
#else
struct stun_addr {
unsigned char unused;
unsigned char family;
- unsigned short port;
+ uint16_t port;
unsigned int addr;
};
#pragma pack(pop)
vOneShots.push_back(strDest);
}
-unsigned short GetListenPort()
+uint16_t GetListenPort()
{
- return (unsigned short)(GetArg("-port", GetDefaultPort()));
+ return static_cast<uint16_t>(GetArg("-port", GetDefaultPort()));
}
void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd)
}
}
-// DNS seeds
-// Each pair gives a source name and a seed name.
-// The first name is used as information source for addrman.
-// The second name should resolve to a list of seed addresses.
-static const char *strDNSSeed[][2] = {
- {"novacoin.karelia.pro", "dnsseed.novacoin.karelia.pro"},
- {"novacoin.ru", "dnsseed.novacoin.ru"},
- {"novacoin.ru", "testseed.novacoin.ru"},
- {"novaco.in", "dnsseed.novaco.in"},
-};
-
void ThreadDNSAddressSeed(void* parg)
{
// Make this thread recognisable as the DNS seeding thread
if (!fTestNet)
{
+ // DNS seeds
+ // Each pair gives a source name and a seed name.
+ // The first name is used as information source for addrman.
+ // The second name should resolve to a list of seed addresses.
+ static const vector<pair <string, string> > vstrDNSSeed = {
+ { "novacoin.karelia.pro", "dnsseed.novacoin.karelia.pro" },
+ { "novacoin.ru", "dnsseed.novacoin.ru" },
+ { "novacoin.ru", "testseed.novacoin.ru" },
+ { "novaco.in", "dnsseed.novaco.in" },
+ };
printf("Loading addresses from DNS seeds (could take a while)\n");
- for (unsigned int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) {
+ for (unsigned int seed_idx = 0; seed_idx < vstrDNSSeed.size(); seed_idx++) {
if (HaveNameProxy()) {
- AddOneShot(strDNSSeed[seed_idx][1]);
+ AddOneShot(vstrDNSSeed[seed_idx].second);
} else {
vector<CNetAddr> vaddr;
vector<CAddress> vAdd;
- if (LookupHost(strDNSSeed[seed_idx][1], vaddr))
+ if (LookupHost(vstrDNSSeed[seed_idx].second, vaddr))
{
for(CNetAddr& ip : vaddr)
{
found++;
}
}
- addrman.Add(vAdd, CNetAddr(strDNSSeed[seed_idx][0], true));
+ addrman.Add(vAdd, CNetAddr(vstrDNSSeed[seed_idx].first, true));
}
}
}
printf("%d addresses found from DNS seeds\n", found);
}
-
-
-
-
-
-
-
-
-
-
-
uint32_t pnSeed[] =
{
0xa52bf0da, 0x30aa43d8, 0x614488d5, 0x517b6fd5, 0xd4bf62d4, 0xb7d638d4, 0xbc12bcd1, 0xa2501bc6,
CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL, int64_t nTimeout=0);
bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);
void MapPort();
-unsigned short GetListenPort();
+uint16_t GetListenPort();
bool BindListenPort(const CService &bindAddr, string& strError=REF(string()));
void StartNode(void* parg);
bool StopNode();
return (vIP.size() > 0);
}
+bool LookupHost(const string strName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
+{
+ std::string strHost(strName);
+ if (strHost.empty())
+ return false;
+ if ((strHost.compare(0,1, "[") == 0) && (strHost.compare(strHost.length()-1,1, "]") == 0))
+ {
+ strHost = strHost.substr(1, strHost.size() - 2);
+ }
+
+ return LookupIntern(strHost.c_str(), vIP, nMaxSolutions, fAllowLookup);
+}
+
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
{
std::string strHost(pszName);
{
Init();
std::vector<CNetAddr> vIP;
- if (LookupHost(strIp.c_str(), vIP, 1, fAllowLookup))
+ if (LookupHost(strIp, vIP, 1, fAllowLookup))
*this = vIP[0];
}
*this = ip;
}
-unsigned short CService::GetPort() const
+uint16_t CService::GetPort() const
{
return port;
}
return ToStringIPPort();
}
-void CService::SetPort(unsigned short portIn)
+void CService::SetPort(uint16_t portIn)
{
port = portIn;
}
class CService : public CNetAddr
{
protected:
- unsigned short port; // host order
+ uint16_t port; // host order
public:
CService();
explicit CService(const std::string& strIpPort, bool fAllowLookup = false);
void Init();
void SetPort(uint16_t portIn);
- unsigned short GetPort() const;
+ uint16_t GetPort() const;
bool GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const;
bool SetSockAddr(const struct sockaddr* paddr);
friend bool operator==(const CService& a, const CService& b);
(
CService* pthis = const_cast<CService*>(this);
READWRITE(FLATDATA(ip));
- unsigned short portN = htons(port);
+ uint16_t portN = htons(port);
READWRITE(portN);
if (fRead)
pthis->port = ntohs(portN);
bool IsProxy(const CNetAddr &addr);
bool SetNameProxy(CService addrProxy, int nSocksVersion = 5);
bool HaveNameProxy();
+bool LookupHost(const std::string strName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true);
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true);
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);
sockfd = INVALID_SOCKET;
std::vector<CNetAddr> vIP;
- bool fRet = LookupHost(strHostName.c_str(), vIP, 10, true);
+ bool fRet = LookupHost(strHostName, vIP, 10, true);
if (!fRet) {
return false;
}
#include "uint256.h"
extern bool fTestNet;
-inline unsigned short GetDefaultPort()
+inline uint16_t GetDefaultPort()
{
- return static_cast<unsigned short>(fTestNet ? 17777 : 7777);
+ return static_cast<uint16_t>(fTestNet ? 17777 : 7777);
}
extern uint8_t pchMessageStart[4];