Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3983,7 +3983,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)

pfrom->fSuccessfullyConnected = true;

printf("receive version message: %s: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", pfrom->cleanSubVer.c_str(), pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString().c_str(), addrFrom.ToString().c_str(), pfrom->addr.ToString().c_str());
printf("receive version message: %s: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", pfrom->cleanSubVer.c_str(), pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString().c_str(), addrFrom.ToString().c_str(), pfrom->id);

cPeerBlockCounts.input(pfrom->nStartingHeight);
}
Expand All @@ -4002,6 +4002,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
}

else if (strCommand == "misbehave") {
int howmuch;
vRecv >> howmuch;
printf("peer=%d says we are misbehaving %d\n", howmuch);
}

else if (strCommand == "dseg") { //DarkSend Election Get
if (pfrom->nVersion != darkSendPool.MIN_PEER_PROTO_VERSION) {
return false;
Expand Down
6 changes: 5 additions & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ CCriticalSection cs_setservAddNodeAddresses;
vector<std::string> vAddedNodes;
CCriticalSection cs_vAddedNodes;

NodeId nLastNodeId = 0;
CCriticalSection cs_nLastNodeId;

static CSemaphore *semOutbound = NULL;

void AddOneShot(string strDest)
Expand Down Expand Up @@ -544,7 +547,7 @@ void CNode::PushVersion()
CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
CAddress addrMe = GetLocalAddress(&addr);
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
printf("send version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), addrYou.ToString().c_str(), addr.ToString().c_str());
printf("send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), addrYou.ToString().c_str(), id);
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight);
}
Expand Down Expand Up @@ -586,6 +589,7 @@ bool CNode::Misbehaving(int howmuch)
}

nMisbehavior += howmuch;
PushMessage("misbehave", howmuch);
if (nMisbehavior >= GetArg("-banscore", 100))
{
int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
Expand Down
11 changes: 10 additions & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ void StartNode(boost::thread_group& threadGroup);
bool StopNode();
void SocketSendData(CNode *pnode);

typedef int NodeId;

enum
{
LOCAL_NONE, // unknown
Expand Down Expand Up @@ -87,7 +89,8 @@ extern limitedmap<CInv, int64> mapAlreadyAskedFor;
extern std::vector<std::string> vAddedNodes;
extern CCriticalSection cs_vAddedNodes;


extern NodeId nLastNodeId;
extern CCriticalSection cs_nLastNodeId;


class CNodeStats
Expand Down Expand Up @@ -200,6 +203,7 @@ class CNode
CCriticalSection cs_filter;
CBloomFilter* pfilter;
int nRefCount;
NodeId id;
protected:

// Denial-of-service detection/prevention
Expand Down Expand Up @@ -263,6 +267,11 @@ class CNode
setInventoryKnown.max_size(SendBufferSize() / 1000);
pfilter = new CBloomFilter();

{
LOCK(cs_nLastNodeId);
id = nLastNodeId++;
}

// Be shy and don't send version until we hear
if (hSocket != INVALID_SOCKET && !fInbound)
PushVersion();
Expand Down