Changes to enable a LAN Relay Test Environment.

NB: Reverse Most of these changes - before adding to Trunk!!!!

 * Added missing BitDht callback functions for test/example code.
 * Switch tests/example to OSX compile.
 * DISABLE_BAD_PEER_FILTER (as it doesn't like local net)
 * Reduced Minimum Peer Counts for DHT to be considered active.
 * Added LOCALNET_TESTING to rsinit.cc 
	- new Commandline Option -R <lport-uport> to restrict UDP ports.
	- Enables LocalNet in UdpStunner.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-dhtmods@4756 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-01-07 11:28:00 +00:00
parent 73471b2618
commit af5f23e0e7
8 changed files with 129 additions and 18 deletions

View file

@ -58,7 +58,7 @@
* #define DEBUG_MGR_PKT 1
***/
//#define DEBUG_MGR 1
#define DEBUG_MGR 1
//#define LOCAL_NET_FLAG (BITDHT_PEER_STATUS_DHT_APPL)
#define LOCAL_NET_FLAG (BITDHT_PEER_STATUS_DHT_ENGINE)
@ -312,11 +312,11 @@ void bdNodeManager::iteration()
*/
#define TRANSITION_OP_SPACE_SIZE 50 /* 1 query / sec, should take 12-15 secs */
#define MAX_FINDSELF_TIME 30
#define MIN_OP_SPACE_SIZE 10
//#define MAX_FINDSELF_TIME 30
//#define MIN_OP_SPACE_SIZE 10
// testing parameters.
//#define MAX_FINDSELF_TIME 10
//#define MIN_OP_SPACE_SIZE 2 // for testing. self + oneother.
#define MAX_FINDSELF_TIME 10
#define MIN_OP_SPACE_SIZE 2 // for testing. self + oneother.
{
uint32_t nodeSpaceSize = mNodeSpace.calcSpaceSize();
@ -403,7 +403,8 @@ void bdNodeManager::iteration()
/* run a random search for ourselves, from own App DHT peer */
QueryRandomLocalNet();
#define SEARCH_MAX_SIZE 10
//#define SEARCH_MAX_SIZE 10
#define SEARCH_MAX_SIZE 0
if (mBdNetworkSize < SEARCH_MAX_SIZE)
{
#ifdef DEBUG_MGR
@ -1434,3 +1435,26 @@ int bdDebugCallback::dhtConnectCallback(const bdId *srcId, const bdId *proxyId,
return 1;
}
int bdDebugCallback::dhtInfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info)
{
/* remove unused parameter warnings */
(void) id;
(void) type;
(void) flags;
(void) info;
#ifdef DEBUG_MGR
std::cerr << "bdDebugCallback::dhtInfoCallback() Type: " << type;
std::cerr << " Id: ";
bdStdPrintId(std::cerr, id);
std::cerr << " flags: " << flags;
std::cerr << " info: " << info;
std::cerr << std::endl;
#endif
return 1;
}

View file

@ -201,6 +201,7 @@ virtual int dhtPeerCallback(const bdId *id, uint32_t status);
virtual int dhtValueCallback(const bdNodeId *id, std::string key, uint32_t status);
virtual int dhtConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId *destId,
uint32_t mode, uint32_t point, uint32_t param, uint32_t cbtype, uint32_t errcode);
virtual int dhtInfoCallback(const bdId *id, uint32_t type, uint32_t flags, std::string info);
};

View file

@ -462,7 +462,7 @@ void bdNode::send_connect_msg(bdId *id, int msgtype, bdId *srcAddr, bdId *destAd
//#define DISABLE_BAD_PEER_FILTER 1
#define DISABLE_BAD_PEER_FILTER 1
void bdNode::checkPotentialPeer(bdId *id, bdId *src)
{
@ -488,6 +488,7 @@ void bdNode::checkPotentialPeer(bdId *id, bdId *src)
{
if (knownAddr.sin_addr.s_addr != id->addr.sin_addr.s_addr)
{
#ifndef DISABLE_BAD_PEER_FILTER
std::cerr << "bdNode::checkPotentialPeer(";
mFns->bdPrintId(std::cerr, id);
std::cerr << ") MASQARADING AS KNOWN PEER - FLAGGING AS BAD";
@ -496,7 +497,6 @@ void bdNode::checkPotentialPeer(bdId *id, bdId *src)
// Stores in queue for later callback and desemination around the network.
mBadPeerQueue.queuePeer(id, 0);
#ifndef DISABLE_BAD_PEER_FILTER
mFilterPeers->addPeerToFilter(id, 0);
std::list<struct sockaddr_in> filteredIPs;
@ -574,6 +574,7 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags)
{
if (knownAddr.sin_addr.s_addr != id->addr.sin_addr.s_addr)
{
#ifndef DISABLE_BAD_PEER_FILTER
std::cerr << "bdNode::addPeer(";
mFns->bdPrintId(std::cerr, id);
std::cerr << ", " << std::hex << peerflags << std::dec;
@ -584,13 +585,11 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags)
// Stores in queue for later callback and desemination around the network.
mBadPeerQueue.queuePeer(id, peerflags);
#ifndef DISABLE_BAD_PEER_FILTER
mFilterPeers->addPeerToFilter(id, peerflags);
std::list<struct sockaddr_in> filteredIPs;
mFilterPeers->filteredIPs(filteredIPs);
mStore.filterIpList(filteredIPs);
#endif
// DO WE EXPLICITLY NEED TO DO THIS, OR WILL THEY JUST BE DROPPED?
//mNodeSpace.remove_badpeer(id);
@ -599,7 +598,6 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags)
// FLAG in NodeSpace (Should be dropped very quickly anyway)
mNodeSpace.flagpeer(id, 0, BITDHT_PEER_EXFLAG_BADPEER);
#ifndef DISABLE_BAD_PEER_FILTER
return;
#endif
}