aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-01-03 23:33:31 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-01-06 18:55:37 +0100
commit67a42f929b1434f647c63922fd02dc2b93b28060 (patch)
tree9c4313e815bd77e817f2dc5b796347d343458d0e /src/net.h
parent7486c64dd8436febbe59e82dbb875e83ad6b5194 (diff)
downloadbitcoin-67a42f929b1434f647c63922fd02dc2b93b28060.tar.xz
Network stack refactor
This introduces CNetAddr and CService, respectively wrapping an (IPv6) IP address and an IP+port combination. This functionality used to be part of CAddress, which also contains network flags and connection attempt information. These extra fields are however not always necessary. These classes, along with logic for creating connections and doing name lookups, are moved to netbase.{h,cpp}, which does not depend on headers.h. Furthermore, CNetAddr is mostly IPv6-ready, though IPv6 functionality is not yet enabled for the application itself.
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/net.h b/src/net.h
index c2637dc6ac..61daf0378c 100644
--- a/src/net.h
+++ b/src/net.h
@@ -14,6 +14,7 @@
#include <arpa/inet.h>
#endif
+#include "netbase.h"
#include "protocol.h"
class CAddrDB;
@@ -21,7 +22,6 @@ class CRequestTracker;
class CNode;
class CBlockIndex;
extern int nBestHeight;
-extern int nConnectTimeout;
@@ -29,13 +29,11 @@ inline unsigned int ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer"
inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 10*1000); }
static const unsigned int PUBLISH_HOPS = 5;
-bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout=nConnectTimeout);
-bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
-bool Lookup(const char *pszName, CAddress& addr, int nServices, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
-bool GetMyExternalIP(unsigned int& ipRet);
+bool GetMyExternalIP(CNetAddr& ipRet);
bool AddAddress(CAddress addr, int64 nTimePenalty=0, CAddrDB *pAddrDB=NULL);
-void AddressCurrentlyConnected(const CAddress& addr);
-CNode* FindNode(unsigned int ip);
+void AddressCurrentlyConnected(const CService& addr);
+CNode* FindNode(const CNetAddr& ip);
+CNode* FindNode(const CService& ip);
CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);
void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
bool AnySubscribed(unsigned int nChannel);
@@ -88,9 +86,6 @@ extern std::deque<std::pair<int64, CInv> > vRelayExpiration;
extern CCriticalSection cs_mapRelay;
extern std::map<CInv, int64> mapAlreadyAskedFor;
-// Settings
-extern int fUseProxy;
-extern CAddress addrProxy;
@@ -126,7 +121,7 @@ protected:
// Denial-of-service detection/prevention
// Key is ip address, value is banned-until-time
- static std::map<unsigned int, int64> setBanned;
+ static std::map<CNetAddr, int64> setBanned;
static CCriticalSection cs_setBanned;
int nMisbehavior;
@@ -355,7 +350,6 @@ public:
-
void PushVersion();
@@ -581,7 +575,7 @@ public:
// between nodes running old code and nodes running
// new code.
static void ClearBanned(); // needed for unit testing
- static bool IsBanned(unsigned int ip);
+ static bool IsBanned(CNetAddr ip);
bool Misbehaving(int howmuch); // 1 == a little, 100 == a lot
};