diff options
Diffstat (limited to 'src/net.h')
| -rw-r--r-- | src/net.h | 31 |
1 files changed, 11 insertions, 20 deletions
| @@ -22,12 +22,10 @@ enum | |||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet); | ||
| 26 | bool GetMyExternalIP(unsigned int& ipRet); | 25 | bool GetMyExternalIP(unsigned int& ipRet); |
| 27 | bool AddAddress(CAddrDB& addrdb, const CAddress& addr); | ||
| 28 | CNode* FindNode(unsigned int ip); | ||
| 29 | CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0); | ||
| 30 | CNode* ConnectNodeBtf(const string& strBtfAddr); | 26 | CNode* ConnectNodeBtf(const string& strBtfAddr); |
| 27 | CNode* ConnectNodeBtfResolved(const string& strBtfAddr, const string& strMeeting, | ||
| 28 | const unsigned char enc_pub[32]); | ||
| 31 | void ThreadBtfAccept(void* parg); | 29 | void ThreadBtfAccept(void* parg); |
| 32 | void ThreadBtfConnect(void* parg); | 30 | void ThreadBtfConnect(void* parg); |
| 33 | extern string strBtfConnect; | 31 | extern string strBtfConnect; |
| @@ -120,7 +118,7 @@ public: | |||
| 120 | // Message size | 118 | // Message size |
| 121 | if (nMessageSize > 0x10000000) | 119 | if (nMessageSize > 0x10000000) |
| 122 | { | 120 | { |
| 123 | printf("CMessageHeader::IsValid() : nMessageSize too large %u\n", nMessageSize); | 121 | if (LogAcceptsCategory("net")) printf("CMessageHeader::IsValid() : nMessageSize too large %u\n", nMessageSize); |
| 124 | return false; | 122 | return false; |
| 125 | } | 123 | } |
| 126 | 124 | ||
| @@ -294,7 +292,7 @@ public: | |||
| 294 | 292 | ||
| 295 | void print() const | 293 | void print() const |
| 296 | { | 294 | { |
| 297 | printf("CAddress(%s)\n", ToString().c_str()); | 295 | if (LogAcceptsCategory("net")) printf("CAddress(%s)\n", ToString().c_str()); |
| 298 | } | 296 | } |
| 299 | }; | 297 | }; |
| 300 | 298 | ||
| @@ -387,7 +385,7 @@ public: | |||
| 387 | 385 | ||
| 388 | void print() const | 386 | void print() const |
| 389 | { | 387 | { |
| 390 | printf("CInv(%s)\n", ToString().c_str()); | 388 | if (LogAcceptsCategory("net")) printf("CInv(%s)\n", ToString().c_str()); |
| 391 | } | 389 | } |
| 392 | }; | 390 | }; |
| 393 | 391 | ||
| @@ -426,13 +424,10 @@ extern bool fShutdown; | |||
| 426 | extern array<bool, 10> vfThreadRunning; | 424 | extern array<bool, 10> vfThreadRunning; |
| 427 | extern vector<CNode*> vNodes; | 425 | extern vector<CNode*> vNodes; |
| 428 | extern CCriticalSection cs_vNodes; | 426 | extern CCriticalSection cs_vNodes; |
| 429 | extern map<vector<unsigned char>, CAddress> mapAddresses; | ||
| 430 | extern CCriticalSection cs_mapAddresses; | ||
| 431 | extern map<CInv, CDataStream> mapRelay; | 427 | extern map<CInv, CDataStream> mapRelay; |
| 432 | extern deque<pair<int64, CInv> > vRelayExpiration; | 428 | extern deque<pair<int64, CInv> > vRelayExpiration; |
| 433 | extern CCriticalSection cs_mapRelay; | 429 | extern CCriticalSection cs_mapRelay; |
| 434 | extern map<CInv, int64> mapAlreadyAskedFor; | 430 | extern map<CInv, int64> mapAlreadyAskedFor; |
| 435 | extern CAddress addrProxy; | ||
| 436 | 431 | ||
| 437 | 432 | ||
| 438 | 433 | ||
| @@ -462,10 +457,6 @@ public: | |||
| 462 | map<uint256, CRequestTracker> mapRequests; | 457 | map<uint256, CRequestTracker> mapRequests; |
| 463 | CCriticalSection cs_mapRequests; | 458 | CCriticalSection cs_mapRequests; |
| 464 | 459 | ||
| 465 | // flood | ||
| 466 | vector<CAddress> vAddrToSend; | ||
| 467 | set<CAddress> setAddrKnown; | ||
| 468 | |||
| 469 | // inventory based relay | 460 | // inventory based relay |
| 470 | set<CInv> setInventoryKnown; | 461 | set<CInv> setInventoryKnown; |
| 471 | set<CInv> setInventoryKnown2; | 462 | set<CInv> setInventoryKnown2; |
| @@ -555,7 +546,7 @@ public: | |||
| 555 | // We're using mapAskFor as a priority queue, | 546 | // We're using mapAskFor as a priority queue, |
| 556 | // the key is the earliest time the request can be sent | 547 | // the key is the earliest time the request can be sent |
| 557 | int64& nRequestTime = mapAlreadyAskedFor[inv]; | 548 | int64& nRequestTime = mapAlreadyAskedFor[inv]; |
| 558 | printf("askfor %s %lld\n", inv.ToString().c_str(), nRequestTime); | 549 | if (LogAcceptsCategory("net")) printf("askfor %s %lld\n", inv.ToString().c_str(), nRequestTime); |
| 559 | 550 | ||
| 560 | // Make sure not to reuse time indexes to keep things in the same order | 551 | // Make sure not to reuse time indexes to keep things in the same order |
| 561 | int64 nNow = (GetTime() - 1) * 1000000; | 552 | int64 nNow = (GetTime() - 1) * 1000000; |
| @@ -576,7 +567,7 @@ public: | |||
| 576 | AbortMessage(); | 567 | AbortMessage(); |
| 577 | nPushPos = vSend.size(); | 568 | nPushPos = vSend.size(); |
| 578 | vSend << CMessageHeader(pszCommand, 0); | 569 | vSend << CMessageHeader(pszCommand, 0); |
| 579 | printf("sending: %-12s ", pszCommand); | 570 | if (LogAcceptsCategory("net")) printf("sending: %-12s ", pszCommand); |
| 580 | } | 571 | } |
| 581 | 572 | ||
| 582 | void AbortMessage() | 573 | void AbortMessage() |
| @@ -586,7 +577,7 @@ public: | |||
| 586 | vSend.resize(nPushPos); | 577 | vSend.resize(nPushPos); |
| 587 | nPushPos = -1; | 578 | nPushPos = -1; |
| 588 | LeaveCriticalSection(&cs_vSend); | 579 | LeaveCriticalSection(&cs_vSend); |
| 589 | printf("(aborted)\n"); | 580 | if (LogAcceptsCategory("net")) printf("(aborted)\n"); |
| 590 | } | 581 | } |
| 591 | 582 | ||
| 592 | void EndMessage() | 583 | void EndMessage() |
| @@ -594,7 +585,7 @@ public: | |||
| 594 | extern int nDropMessagesTest; | 585 | extern int nDropMessagesTest; |
| 595 | if (nDropMessagesTest > 0 && GetRand(nDropMessagesTest) == 0) | 586 | if (nDropMessagesTest > 0 && GetRand(nDropMessagesTest) == 0) |
| 596 | { | 587 | { |
| 597 | printf("dropmessages DROPPING SEND MESSAGE\n"); | 588 | if (LogAcceptsCategory("net")) printf("dropmessages DROPPING SEND MESSAGE\n"); |
| 598 | AbortMessage(); | 589 | AbortMessage(); |
| 599 | return; | 590 | return; |
| 600 | } | 591 | } |
| @@ -606,10 +597,10 @@ public: | |||
| 606 | unsigned int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader); | 597 | unsigned int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader); |
| 607 | memcpy((char*)&vSend[nPushPos] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize)); | 598 | memcpy((char*)&vSend[nPushPos] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize)); |
| 608 | 599 | ||
| 609 | printf("(%d bytes) ", nSize); | 600 | if (LogAcceptsCategory("net")) printf("(%d bytes) ", nSize); |
| 610 | //for (int i = nPushPos+sizeof(CMessageHeader); i < min(vSend.size(), nPushPos+sizeof(CMessageHeader)+20U); i++) | 601 | //for (int i = nPushPos+sizeof(CMessageHeader); i < min(vSend.size(), nPushPos+sizeof(CMessageHeader)+20U); i++) |
| 611 | // printf("%02x ", vSend[i] & 0xff); | 602 | // printf("%02x ", vSend[i] & 0xff); |
| 612 | printf("\n"); | 603 | if (LogAcceptsCategory("net")) printf("\n"); |
| 613 | 604 | ||
| 614 | nPushPos = -1; | 605 | nPushPos = -1; |
| 615 | LeaveCriticalSection(&cs_vSend); | 606 | LeaveCriticalSection(&cs_vSend); |