mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-12 02:55:18 -04:00
Added Bandwidth and Delay parameters to BitDHT Connect Messages.
* Bandwidth are for RELAY connections. * Delays are for Exclusive NAT Proxy connections. * Lots of changes to achieve this. (Mainly added "param" to msgs). * Various Bugfixes too. * Updated BITDHT Version to 01 as we've changed Message Format. * Increased Connection Timeout to 180 * Added extra checks to kill duplicate connections early. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4462 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c33b415ef4
commit
551e2594bb
11 changed files with 371 additions and 147 deletions
|
@ -380,14 +380,14 @@ void bdNode::send_query(bdId *id, bdNodeId *targetNodeId)
|
|||
}
|
||||
|
||||
|
||||
void bdNode::send_connect_msg(bdId *id, int msgtype, bdId *srcAddr, bdId *destAddr, int mode, int status)
|
||||
void bdNode::send_connect_msg(bdId *id, int msgtype, bdId *srcAddr, bdId *destAddr, int mode, int param, int status)
|
||||
{
|
||||
/* push out query */
|
||||
bdToken transId;
|
||||
genNewTransId(&transId);
|
||||
//registerOutgoingMsg(&id, &transId, BITDHT_MSG_TYPE_FIND_NODE);
|
||||
|
||||
msgout_connect_genmsg(id, &transId, msgtype, srcAddr, destAddr, mode, status);
|
||||
msgout_connect_genmsg(id, &transId, msgtype, srcAddr, destAddr, mode, param, status);
|
||||
|
||||
#ifdef DEBUG_NODE_MSGS
|
||||
std::cerr << "bdNode::send_connect_msg() to: ";
|
||||
|
@ -1190,12 +1190,14 @@ void bdNode::recvPkt(char *msg, int len, struct sockaddr_in addr)
|
|||
bdId connSrcAddr;
|
||||
bdId connDestAddr;
|
||||
uint32_t connMode;
|
||||
uint32_t connParam = 0;
|
||||
uint32_t connStatus;
|
||||
uint32_t connType;
|
||||
|
||||
be_node *be_ConnSrcAddr = NULL;
|
||||
be_node *be_ConnDestAddr = NULL;
|
||||
be_node *be_ConnMode = NULL;
|
||||
be_node *be_ConnParam = NULL;
|
||||
be_node *be_ConnStatus = NULL;
|
||||
be_node *be_ConnType = NULL;
|
||||
if (beType == BITDHT_MSG_TYPE_CONNECT)
|
||||
|
@ -1236,6 +1238,18 @@ void bdNode::recvPkt(char *msg, int len, struct sockaddr_in addr)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Param */
|
||||
be_ConnParam = beMsgGetDictNode(be_data, "param");
|
||||
if (!be_ConnParam)
|
||||
{
|
||||
#ifdef DEBUG_NODE_PARSE
|
||||
std::cerr << "bdNode::recvPkt() CONNECT Missing Param. Dropping Msg";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
be_free(node);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Status */
|
||||
be_ConnStatus = beMsgGetDictNode(be_data, "status");
|
||||
if (!be_ConnStatus)
|
||||
|
@ -1276,6 +1290,11 @@ void bdNode::recvPkt(char *msg, int len, struct sockaddr_in addr)
|
|||
beMsgGetUInt32(be_ConnMode, &connMode);
|
||||
}
|
||||
|
||||
if (be_ConnParam)
|
||||
{
|
||||
beMsgGetUInt32(be_ConnParam, &connParam);
|
||||
}
|
||||
|
||||
if (be_ConnStatus)
|
||||
{
|
||||
beMsgGetUInt32(be_ConnStatus, &connStatus);
|
||||
|
@ -1409,7 +1428,7 @@ void bdNode::recvPkt(char *msg, int len, struct sockaddr_in addr)
|
|||
//#endif
|
||||
msgin_connect_genmsg(&srcId, &transId, connType,
|
||||
&connSrcAddr, &connDestAddr,
|
||||
connMode, connStatus);
|
||||
connMode, connParam, connStatus);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1788,7 +1807,7 @@ std::string getConnectMsgType(int msgtype)
|
|||
}
|
||||
}
|
||||
|
||||
void bdNode::msgout_connect_genmsg(bdId *id, bdToken *transId, int msgtype, bdId *srcAddr, bdId *destAddr, int mode, int status)
|
||||
void bdNode::msgout_connect_genmsg(bdId *id, bdToken *transId, int msgtype, bdId *srcAddr, bdId *destAddr, int mode, int param, int status)
|
||||
{
|
||||
std::cerr << "bdConnectManager::msgout_connect_genmsg() Type: " << getConnectMsgType(msgtype);
|
||||
std::cerr << " TransId: ";
|
||||
|
@ -1800,6 +1819,7 @@ void bdNode::msgout_connect_genmsg(bdId *id, bdToken *transId, int msgtype, bdId
|
|||
std::cerr << " DestAddr: ";
|
||||
mFns->bdPrintId(std::cerr, destAddr);
|
||||
std::cerr << " Mode: " << mode;
|
||||
std::cerr << " Param: " << param;
|
||||
std::cerr << " Status: " << status;
|
||||
std::cerr << std::endl;
|
||||
#ifdef DEBUG_NODE_MSGOUT
|
||||
|
@ -1828,13 +1848,13 @@ void bdNode::msgout_connect_genmsg(bdId *id, bdToken *transId, int msgtype, bdId
|
|||
char msg[10240];
|
||||
int avail = 10240;
|
||||
|
||||
int blen = bitdht_connect_genmsg(transId, &(mOwnId), msgtype, srcAddr, destAddr, mode, status, msg, avail-1);
|
||||
int blen = bitdht_connect_genmsg(transId, &(mOwnId), msgtype, srcAddr, destAddr, mode, param, status, msg, avail-1);
|
||||
sendPkt(msg, blen, id->addr);
|
||||
}
|
||||
|
||||
|
||||
void bdNode::msgin_connect_genmsg(bdId *id, bdToken *transId, int msgtype,
|
||||
bdId *srcAddr, bdId *destAddr, int mode, int status)
|
||||
bdId *srcAddr, bdId *destAddr, int mode, int param, int status)
|
||||
{
|
||||
std::list<bdId>::iterator it;
|
||||
|
||||
|
@ -1848,6 +1868,7 @@ void bdNode::msgin_connect_genmsg(bdId *id, bdToken *transId, int msgtype,
|
|||
std::cerr << " DestAddr: ";
|
||||
mFns->bdPrintId(std::cerr, destAddr);
|
||||
std::cerr << " Mode: " << mode;
|
||||
std::cerr << " Param: " << param;
|
||||
std::cerr << " Status: " << status;
|
||||
std::cerr << std::endl;
|
||||
#ifdef DEBUG_NODE_MSGS
|
||||
|
@ -1864,21 +1885,21 @@ void bdNode::msgin_connect_genmsg(bdId *id, bdToken *transId, int msgtype,
|
|||
mAccount.incCounter(BDACCOUNT_MSG_CONNECTREQUEST, false);
|
||||
|
||||
|
||||
mConnMgr->recvedConnectionRequest(id, srcAddr, destAddr, mode);
|
||||
mConnMgr->recvedConnectionRequest(id, srcAddr, destAddr, mode, param);
|
||||
|
||||
break;
|
||||
case BITDHT_MSG_TYPE_CONNECT_REPLY:
|
||||
peerflags = BITDHT_PEER_STATUS_RECV_CONNECT_MSG;
|
||||
mAccount.incCounter(BDACCOUNT_MSG_CONNECTREPLY, false);
|
||||
|
||||
mConnMgr->recvedConnectionReply(id, srcAddr, destAddr, mode, status);
|
||||
mConnMgr->recvedConnectionReply(id, srcAddr, destAddr, mode, param, status);
|
||||
|
||||
break;
|
||||
case BITDHT_MSG_TYPE_CONNECT_START:
|
||||
peerflags = BITDHT_PEER_STATUS_RECV_CONNECT_MSG;
|
||||
mAccount.incCounter(BDACCOUNT_MSG_CONNECTSTART, false);
|
||||
|
||||
mConnMgr->recvedConnectionStart(id, srcAddr, destAddr, mode, status);
|
||||
mConnMgr->recvedConnectionStart(id, srcAddr, destAddr, mode, param);
|
||||
|
||||
break;
|
||||
case BITDHT_MSG_TYPE_CONNECT_ACK:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue