Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/netbase.h
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | public: | ||||
CNetAddr(const struct in6_addr &pipv6Addr); | CNetAddr(const struct in6_addr &pipv6Addr); | ||||
bool GetIn6Addr(struct in6_addr *pipv6Addr) const; | bool GetIn6Addr(struct in6_addr *pipv6Addr) const; | ||||
friend bool operator==(const CNetAddr &a, const CNetAddr &b); | friend bool operator==(const CNetAddr &a, const CNetAddr &b); | ||||
friend bool operator!=(const CNetAddr &a, const CNetAddr &b); | friend bool operator!=(const CNetAddr &a, const CNetAddr &b); | ||||
friend bool operator<(const CNetAddr &a, const CNetAddr &b); | friend bool operator<(const CNetAddr &a, const CNetAddr &b); | ||||
IMPLEMENT_SERIALIZE(READWRITE(FLATDATA(ip));) | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(FLATDATA(ip)); | |||||
} | |||||
}; | }; | ||||
/** A combination of a network address (CNetAddr) and a (TCP) port */ | /** A combination of a network address (CNetAddr) and a (TCP) port */ | ||||
class CService : public CNetAddr { | class CService : public CNetAddr { | ||||
protected: | protected: | ||||
unsigned short port; // host order | unsigned short port; // host order | ||||
public: | public: | ||||
Show All 19 Lines | public: | ||||
std::string ToString() const; | std::string ToString() const; | ||||
std::string ToStringPort() const; | std::string ToStringPort() const; | ||||
std::string ToStringIPPort() const; | std::string ToStringIPPort() const; | ||||
void print() const; | void print() const; | ||||
CService(const struct in6_addr &ipv6Addr, unsigned short port); | CService(const struct in6_addr &ipv6Addr, unsigned short port); | ||||
CService(const struct sockaddr_in6 &addr); | CService(const struct sockaddr_in6 &addr); | ||||
IMPLEMENT_SERIALIZE(CService *pthis = const_cast<CService *>(this); | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
CService *pthis = const_cast<CService *>(this); | |||||
READWRITE(FLATDATA(ip)); | READWRITE(FLATDATA(ip)); | ||||
unsigned short portN = htons(port); READWRITE(portN); | unsigned short portN = htons(port); | ||||
if (fRead) pthis->port = ntohs(portN);) | READWRITE(portN); | ||||
if (ser_action.ForRead()) { | |||||
pthis->port = ntohs(portN); | |||||
} | |||||
} | |||||
}; | }; | ||||
enum Network ParseNetwork(std::string net); | enum Network ParseNetwork(std::string net); | ||||
void SplitHostPort(std::string in, int &portOut, std::string &hostOut); | void SplitHostPort(std::string in, int &portOut, std::string &hostOut); | ||||
bool SetProxy(enum Network net, CService addrProxy, int nSocksVersion = 5); | bool SetProxy(enum Network net, CService addrProxy, int nSocksVersion = 5); | ||||
bool GetProxy(enum Network net, CService &addrProxy); | bool GetProxy(enum Network net, CService &addrProxy); | ||||
bool IsProxy(const CNetAddr &addr); | bool IsProxy(const CNetAddr &addr); | ||||
bool SetNameProxy(CService addrProxy, int nSocksVersion = 5); | bool SetNameProxy(CService addrProxy, int nSocksVersion = 5); | ||||
Show All 18 Lines |