Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/netbase.h
Show All 13 Lines | |||||
extern int nConnectTimeout; | extern int nConnectTimeout; | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
// In MSVC, this is defined as a macro, undefine it to prevent a compile and | // In MSVC, this is defined as a macro, undefine it to prevent a compile and | ||||
// link error | // link error | ||||
#undef SetPort | #undef SetPort | ||||
#endif | #endif | ||||
extern int nConnectTimeout; | bool SetProxy(enum Network net, CService addrProxy, int nSocksVersion = 5); | ||||
extern bool fNameLookup; | |||||
/** A combination of a network address (CNetAddr) and a (TCP) port */ | |||||
class CSeederService : public CNetAddr { | |||||
protected: | |||||
unsigned short port; // host order | |||||
public: | |||||
CSeederService(); | |||||
CSeederService(const CNetAddr &ip, unsigned short port); | |||||
CSeederService(const struct in_addr &ipv4Addr, unsigned short port); | |||||
CSeederService(const struct sockaddr_in &addr); | |||||
explicit CSeederService(const char *pszIpPort, int portDefault, | |||||
bool fAllowLookup = false); | |||||
explicit CSeederService(const char *pszIpPort, bool fAllowLookup = false); | |||||
explicit CSeederService(const std::string &strIpPort, int portDefault, | |||||
bool fAllowLookup = false); | |||||
explicit CSeederService(const std::string &strIpPort, | |||||
bool fAllowLookup = false); | |||||
void Init(); | |||||
void SetPort(unsigned short portIn); | |||||
unsigned short GetPort() const; | |||||
bool GetSockAddr(struct sockaddr *paddr, socklen_t *addrlen) const; | |||||
bool SetSockAddr(const struct sockaddr *paddr); | |||||
friend bool operator==(const CSeederService &a, const CSeederService &b); | |||||
friend bool operator!=(const CSeederService &a, const CSeederService &b); | |||||
friend bool operator<(const CSeederService &a, const CSeederService &b); | |||||
std::vector<uint8_t> GetKey() const; | |||||
std::string ToString() const; | |||||
std::string ToStringPort() const; | |||||
std::string ToStringIPPort() const; | |||||
void print() const; | |||||
CSeederService(const struct in6_addr &ipv6Addr, unsigned short port); | |||||
CSeederService(const struct sockaddr_in6 &addr); | |||||
ADD_SERIALIZE_METHODS; | |||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
CSeederService *pthis = const_cast<CSeederService *>(this); | |||||
READWRITE(FLATDATA(ip)); | |||||
unsigned short portN = htons(port); | |||||
READWRITE(portN); | |||||
if (ser_action.ForRead()) { | |||||
pthis->port = ntohs(portN); | |||||
} | |||||
} | |||||
}; | |||||
bool SetProxy(enum Network net, CSeederService addrProxy, | |||||
int nSocksVersion = 5); | |||||
bool LookupHost(const char *pszName, std::vector<CNetAddr> &vIP, | bool LookupHost(const char *pszName, std::vector<CNetAddr> &vIP, | ||||
unsigned int nMaxSolutions = 0, bool fAllowLookup = true); | unsigned int nMaxSolutions = 0, bool fAllowLookup = true); | ||||
bool ConnectSocket(const CSeederService &addr, SOCKET &hSocketRet, | CService LookupNumeric(const char *pszName, int portDefault = 0); | ||||
bool ConnectSocket(const CService &addr, SOCKET &hSocketRet, | |||||
int nTimeout = nConnectTimeout); | int nTimeout = nConnectTimeout); | ||||
#endif | #endif |