mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
add new option to qmake to enable dht stunner
removed dht stunner code when option is not set
This commit is contained in:
parent
ddce43b282
commit
4d2d825d5b
@ -30,7 +30,9 @@
|
|||||||
#include "bitdht/bdstddht.h"
|
#include "bitdht/bdstddht.h"
|
||||||
|
|
||||||
#include "tcponudp/udprelay.h"
|
#include "tcponudp/udprelay.h"
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
#include "tcponudp/udpstunner.h"
|
#include "tcponudp/udpstunner.h"
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
#include <openssl/sha.h>
|
#include <openssl/sha.h>
|
||||||
|
|
||||||
@ -86,8 +88,10 @@ p3BitDht::p3BitDht(const RsPeerId& id, pqiConnectCb *cb, p3NetMgr *nm,
|
|||||||
UdpStack *udpstack, std::string bootstrapfile,const std::string& filteredipfile)
|
UdpStack *udpstack, std::string bootstrapfile,const std::string& filteredipfile)
|
||||||
:p3Config(), pqiNetAssistConnect(id, cb), mNetMgr(nm), dhtMtx("p3BitDht")
|
:p3Config(), pqiNetAssistConnect(id, cb), mNetMgr(nm), dhtMtx("p3BitDht")
|
||||||
{
|
{
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
mDhtStunner = NULL;
|
mDhtStunner = NULL;
|
||||||
mProxyStunner = NULL;
|
mProxyStunner = NULL;
|
||||||
|
#endif
|
||||||
mRelay = NULL;
|
mRelay = NULL;
|
||||||
|
|
||||||
mPeerSharer = NULL;
|
mPeerSharer = NULL;
|
||||||
@ -168,13 +172,19 @@ bool p3BitDht::getOwnDhtId(std::string &ownDhtId)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
void p3BitDht::setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay)
|
void p3BitDht::setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay)
|
||||||
{
|
{
|
||||||
mDhtStunner = dhtStunner;
|
mDhtStunner = dhtStunner;
|
||||||
mProxyStunner = proxyStunner;
|
mProxyStunner = proxyStunner;
|
||||||
mRelay = relay;
|
mRelay = relay;
|
||||||
}
|
}
|
||||||
|
#else // RS_USE_DHT_STUNNER
|
||||||
|
void p3BitDht::setupConnectBits(UdpRelayReceiver *relay)
|
||||||
|
{
|
||||||
|
mRelay = relay;
|
||||||
|
}
|
||||||
|
#endif //RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
void p3BitDht::setupPeerSharer(pqiNetAssistPeerShare *sharer)
|
void p3BitDht::setupPeerSharer(pqiNetAssistPeerShare *sharer)
|
||||||
{
|
{
|
||||||
|
@ -136,7 +136,9 @@ class p3BitDhtRelayHandler
|
|||||||
|
|
||||||
|
|
||||||
class UdpRelayReceiver;
|
class UdpRelayReceiver;
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
class UdpStunner;
|
class UdpStunner;
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
class p3NetMgr;
|
class p3NetMgr;
|
||||||
|
|
||||||
class p3BitDht: public p3Config, public pqiNetAssistConnect, public RsDht
|
class p3BitDht: public p3Config, public pqiNetAssistConnect, public RsDht
|
||||||
@ -174,8 +176,11 @@ public:
|
|||||||
********** External RsDHT Interface (defined in libretroshare/src/retroshare/rsdht.h) *********
|
********** External RsDHT Interface (defined in libretroshare/src/retroshare/rsdht.h) *********
|
||||||
************************************************************************************************/
|
************************************************************************************************/
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
void setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay);
|
void setupConnectBits(UdpStunner *dhtStunner, UdpStunner *proxyStunner, UdpRelayReceiver *relay);
|
||||||
|
#else // RS_USE_DHT_STUNNER
|
||||||
|
void setupConnectBits(UdpRelayReceiver *relay);
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
void setupPeerSharer(pqiNetAssistPeerShare *sharer);
|
void setupPeerSharer(pqiNetAssistPeerShare *sharer);
|
||||||
void modifyNodesPerBucket(uint16_t count);
|
void modifyNodesPerBucket(uint16_t count);
|
||||||
|
|
||||||
@ -359,8 +364,10 @@ private:
|
|||||||
int removeTranslation_locked(const RsPeerId& pid);
|
int removeTranslation_locked(const RsPeerId& pid);
|
||||||
|
|
||||||
UdpBitDht *mUdpBitDht; /* has own mutex, is static except for creation/destruction */
|
UdpBitDht *mUdpBitDht; /* has own mutex, is static except for creation/destruction */
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
UdpStunner *mDhtStunner;
|
UdpStunner *mDhtStunner;
|
||||||
UdpStunner *mProxyStunner;
|
UdpStunner *mProxyStunner;
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
UdpRelayReceiver *mRelay;
|
UdpRelayReceiver *mRelay;
|
||||||
|
|
||||||
p3NetMgr *mNetMgr;
|
p3NetMgr *mNetMgr;
|
||||||
|
@ -152,7 +152,7 @@ std::string p3BitDht::getUdpAddressString()
|
|||||||
|
|
||||||
struct sockaddr_in extAddr;
|
struct sockaddr_in extAddr;
|
||||||
uint8_t extStable;
|
uint8_t extStable;
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
if (mDhtStunner->externalAddr(extAddr, extStable))
|
if (mDhtStunner->externalAddr(extAddr, extStable))
|
||||||
{
|
{
|
||||||
rs_sprintf_append(out, " DhtExtAddr: %s:%u", rs_inet_ntoa(extAddr.sin_addr).c_str(), ntohs(extAddr.sin_port));
|
rs_sprintf_append(out, " DhtExtAddr: %s:%u", rs_inet_ntoa(extAddr.sin_addr).c_str(), ntohs(extAddr.sin_port));
|
||||||
@ -187,7 +187,10 @@ std::string p3BitDht::getUdpAddressString()
|
|||||||
{
|
{
|
||||||
out += " ProxyExtAddr: Unknown ";
|
out += " ProxyExtAddr: Unknown ";
|
||||||
}
|
}
|
||||||
|
#else // RS_USE_DHT_STUNNER
|
||||||
|
// whitespaces taken from above
|
||||||
|
out = " DhtExtAddr: Unknown ProxyExtAddr: Unknown ";
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ int p3BitDht::InfoCallback(const bdId *id, uint32_t /*type*/, uint32_t /*flags*/
|
|||||||
mPeerSharer->updatePeer(rsid, tmpaddr, outtype, outreason, outage);
|
mPeerSharer->updatePeer(rsid, tmpaddr, outtype, outreason, outage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
/* call to the Stunners to drop the address as well */
|
/* call to the Stunners to drop the address as well */
|
||||||
/* IDEALLY these addresses should all be filtered at UdpLayer level instead! */
|
/* IDEALLY these addresses should all be filtered at UdpLayer level instead! */
|
||||||
if (mDhtStunner)
|
if (mDhtStunner)
|
||||||
@ -91,6 +92,7 @@ int p3BitDht::InfoCallback(const bdId *id, uint32_t /*type*/, uint32_t /*flags*/
|
|||||||
{
|
{
|
||||||
mProxyStunner->dropStunPeer(addr);
|
mProxyStunner->dropStunPeer(addr);
|
||||||
}
|
}
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -135,7 +137,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
if ((mProxyStunner) && (mProxyStunner->needStunPeers()))
|
if ((mProxyStunner) && (mProxyStunner->needStunPeers()))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BITDHT_COMMON
|
#ifdef DEBUG_BITDHT_COMMON
|
||||||
@ -156,6 +158,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||||||
#endif
|
#endif
|
||||||
mDhtStunner->addStunPeer(id->addr, NULL);
|
mDhtStunner->addStunPeer(id->addr, NULL);
|
||||||
}
|
}
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -731,6 +734,7 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
UdpStunner *stunner = mProxyStunner;
|
UdpStunner *stunner = mProxyStunner;
|
||||||
if (!proxyPort)
|
if (!proxyPort)
|
||||||
{
|
{
|
||||||
@ -849,6 +853,9 @@ int p3BitDht::ConnectCallback(const bdId *srcId, const bdId *proxyId, const bdId
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#else // RS_USE_DHT_STUNNER
|
||||||
|
connectionAllowed = BITDHT_CONNECT_ERROR_TEMPUNAVAIL;
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
}
|
}
|
||||||
|
|
||||||
ca.mMode = mode;
|
ca.mMode = mode;
|
||||||
@ -1234,6 +1241,7 @@ int p3BitDht::doActions()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
UdpStunner *stunner = mProxyStunner;
|
UdpStunner *stunner = mProxyStunner;
|
||||||
if (!proxyPort)
|
if (!proxyPort)
|
||||||
{
|
{
|
||||||
@ -1333,6 +1341,10 @@ int p3BitDht::doActions()
|
|||||||
connectionReqFailed = true;
|
connectionReqFailed = true;
|
||||||
failReason = CSB_UPDATE_RETRY_ATTEMPT;
|
failReason = CSB_UPDATE_RETRY_ATTEMPT;
|
||||||
}
|
}
|
||||||
|
#else // RS_USE_DHT_STUNNER
|
||||||
|
connectionReqFailed = true;
|
||||||
|
failReason = CSB_UPDATE_RETRY_ATTEMPT;
|
||||||
|
#endif //RS_USE_DHT_STUNNER
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doConnectionRequest)
|
if (doConnectionRequest)
|
||||||
@ -1416,7 +1428,9 @@ int p3BitDht::doActions()
|
|||||||
{
|
{
|
||||||
std::cerr << "PeerAction: ERROR ERROR, we grabd Exclusive Port to do this, trying emergency release";
|
std::cerr << "PeerAction: ERROR ERROR, we grabd Exclusive Port to do this, trying emergency release";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
mProxyStunner->releaseExclusiveMode(pid,false);
|
mProxyStunner->releaseExclusiveMode(pid,false);
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2378,6 +2392,7 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrCh
|
|||||||
|
|
||||||
if (dpd->mExclusiveProxyLock)
|
if (dpd->mExclusiveProxyLock)
|
||||||
{
|
{
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
if (mProxyStunner->releaseExclusiveMode(pid, addrChgLikely))
|
if (mProxyStunner->releaseExclusiveMode(pid, addrChgLikely))
|
||||||
{
|
{
|
||||||
dpd->mExclusiveProxyLock = false;
|
dpd->mExclusiveProxyLock = false;
|
||||||
@ -2389,6 +2404,7 @@ void p3BitDht::ReleaseProxyExclusiveMode_locked(DhtPeerDetails *dpd, bool addrCh
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
{
|
{
|
||||||
dpd->mExclusiveProxyLock = false;
|
dpd->mExclusiveProxyLock = false;
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ int p3BitDht::addBadPeer(const struct sockaddr_storage &addr, uint32_t /*reason*
|
|||||||
addrv4.sin_addr = ap->sin_addr;
|
addrv4.sin_addr = ap->sin_addr;
|
||||||
addrv4.sin_port = ap->sin_port;
|
addrv4.sin_port = ap->sin_port;
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
if (mDhtStunner)
|
if (mDhtStunner)
|
||||||
{
|
{
|
||||||
mDhtStunner->dropStunPeer(addrv4);
|
mDhtStunner->dropStunPeer(addrv4);
|
||||||
@ -211,7 +211,7 @@ int p3BitDht::addBadPeer(const struct sockaddr_storage &addr, uint32_t /*reason*
|
|||||||
{
|
{
|
||||||
mProxyStunner->dropStunPeer(addrv4);
|
mProxyStunner->dropStunPeer(addrv4);
|
||||||
}
|
}
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@ DESTDIR = lib
|
|||||||
|
|
||||||
#CONFIG += dsdv
|
#CONFIG += dsdv
|
||||||
|
|
||||||
|
# the dht stunner is used to obtain RS' external ip addr. when it is natted
|
||||||
|
# this system is unreliable and rs supports a newer and better one (asking connected peers)
|
||||||
|
# CONFIG += useDhtStunner
|
||||||
|
|
||||||
profiling {
|
profiling {
|
||||||
QMAKE_CXXFLAGS -= -fomit-frame-pointer
|
QMAKE_CXXFLAGS -= -fomit-frame-pointer
|
||||||
QMAKE_CXXFLAGS *= -pg -g -fno-omit-frame-pointer
|
QMAKE_CXXFLAGS *= -pg -g -fno-omit-frame-pointer
|
||||||
@ -47,8 +51,7 @@ SOURCES *= serialiser/rstlvdsdv.cc \
|
|||||||
bitdht {
|
bitdht {
|
||||||
|
|
||||||
HEADERS += dht/p3bitdht.h \
|
HEADERS += dht/p3bitdht.h \
|
||||||
dht/connectstatebox.h \
|
dht/connectstatebox.h
|
||||||
dht/stunaddrassist.h
|
|
||||||
|
|
||||||
SOURCES += dht/p3bitdht.cc \
|
SOURCES += dht/p3bitdht.cc \
|
||||||
dht/p3bitdht_interface.cc \
|
dht/p3bitdht_interface.cc \
|
||||||
@ -62,7 +65,6 @@ HEADERS += tcponudp/udppeer.h \
|
|||||||
tcponudp/tcppacket.h \
|
tcponudp/tcppacket.h \
|
||||||
tcponudp/tcpstream.h \
|
tcponudp/tcpstream.h \
|
||||||
tcponudp/tou.h \
|
tcponudp/tou.h \
|
||||||
tcponudp/udpstunner.h \
|
|
||||||
tcponudp/udprelay.h \
|
tcponudp/udprelay.h \
|
||||||
|
|
||||||
SOURCES += tcponudp/udppeer.cc \
|
SOURCES += tcponudp/udppeer.cc \
|
||||||
@ -70,9 +72,17 @@ SOURCES += tcponudp/udppeer.cc \
|
|||||||
tcponudp/tcpstream.cc \
|
tcponudp/tcpstream.cc \
|
||||||
tcponudp/tou.cc \
|
tcponudp/tou.cc \
|
||||||
tcponudp/bss_tou.c \
|
tcponudp/bss_tou.c \
|
||||||
tcponudp/udpstunner.cc \
|
|
||||||
tcponudp/udprelay.cc \
|
tcponudp/udprelay.cc \
|
||||||
|
|
||||||
|
useDhtStunner {
|
||||||
|
HEADERS += dht/stunaddrassist.h \
|
||||||
|
tcponudp/udpstunner.h
|
||||||
|
|
||||||
|
SOURCES += tcponudp/udpstunner.cc
|
||||||
|
|
||||||
|
DEFINES += RS_USE_DHT_STUNNER
|
||||||
|
}
|
||||||
|
|
||||||
DEFINES *= RS_USE_BITDHT
|
DEFINES *= RS_USE_BITDHT
|
||||||
|
|
||||||
BITDHT_DIR = ../../libbitdht/src
|
BITDHT_DIR = ../../libbitdht/src
|
||||||
|
@ -169,12 +169,13 @@ void p3NetMgrIMPL::setManagers(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr)
|
|||||||
// mDhtMgr = dhtMgr;
|
// mDhtMgr = dhtMgr;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
void p3NetMgrIMPL::setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun)
|
void p3NetMgrIMPL::setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun)
|
||||||
{
|
{
|
||||||
mDhtStunner = dhtStun;
|
mDhtStunner = dhtStun;
|
||||||
mProxyStunner = proxyStun;
|
mProxyStunner = proxyStun;
|
||||||
}
|
}
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
|
|
||||||
/***** Framework / initial implementation for a connection manager.
|
/***** Framework / initial implementation for a connection manager.
|
||||||
@ -445,6 +446,7 @@ void p3NetMgrIMPL::slowTick()
|
|||||||
netAssistTick();
|
netAssistTick();
|
||||||
updateNetStateBox_temporal();
|
updateNetStateBox_temporal();
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
if (mDhtStunner)
|
if (mDhtStunner)
|
||||||
{
|
{
|
||||||
mDhtStunner->tick();
|
mDhtStunner->tick();
|
||||||
@ -454,7 +456,7 @@ void p3NetMgrIMPL::slowTick()
|
|||||||
{
|
{
|
||||||
mProxyStunner->tick();
|
mProxyStunner->tick();
|
||||||
}
|
}
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
}
|
}
|
||||||
|
|
||||||
#define STARTUP_DELAY 5
|
#define STARTUP_DELAY 5
|
||||||
@ -1739,6 +1741,7 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
|
|||||||
struct sockaddr_storage tmpaddr;
|
struct sockaddr_storage tmpaddr;
|
||||||
sockaddr_storage_clear(tmpaddr);
|
sockaddr_storage_clear(tmpaddr);
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
if (mDhtStunner)
|
if (mDhtStunner)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1776,6 +1779,7 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1789,7 +1793,7 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
|
|||||||
|
|
||||||
/* now we check if a WebIP address is required? */
|
/* now we check if a WebIP address is required? */
|
||||||
|
|
||||||
|
#ifdef NETMGR_DEBUG_STATEBOX
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
RsStackMutex stack(mNetMtx); /****** STACK LOCK MUTEX *******/
|
||||||
|
|
||||||
@ -1805,7 +1809,6 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
|
|||||||
std::string nattypestr = NetStateNatTypeString(natType);
|
std::string nattypestr = NetStateNatTypeString(natType);
|
||||||
std::string netmodestr = NetStateNetworkModeString(netMode);
|
std::string netmodestr = NetStateNetworkModeString(netMode);
|
||||||
|
|
||||||
#ifdef NETMGR_DEBUG_STATEBOX
|
|
||||||
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() NetStateBox Thinking";
|
std::cerr << "p3NetMgrIMPL::updateNetStateBox_temporal() NetStateBox Thinking";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "\tNetState: " << netstatestr;
|
std::cerr << "\tNetState: " << netstatestr;
|
||||||
@ -1818,10 +1821,9 @@ void p3NetMgrIMPL::updateNetStateBox_temporal()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "\tNatType: " << nattypestr;
|
std::cerr << "\tNatType: " << nattypestr;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
updateNatSetting();
|
updateNatSetting();
|
||||||
|
|
||||||
@ -1869,7 +1871,7 @@ void p3NetMgrIMPL::updateNatSetting()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
switch(natType)
|
switch(natType)
|
||||||
{
|
{
|
||||||
case RSNET_NATTYPE_RESTRICTED_CONE:
|
case RSNET_NATTYPE_RESTRICTED_CONE:
|
||||||
@ -1894,7 +1896,7 @@ void p3NetMgrIMPL::updateNatSetting()
|
|||||||
mProxyStunner->setRefreshPeriod(NET_STUNNER_PERIOD_SLOW);
|
mProxyStunner->setRefreshPeriod(NET_STUNNER_PERIOD_SLOW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
/* This controls the Attach mode of the DHT...
|
/* This controls the Attach mode of the DHT...
|
||||||
* which effectively makes the DHT "attach" to Open Nodes.
|
* which effectively makes the DHT "attach" to Open Nodes.
|
||||||
|
@ -209,7 +209,9 @@ virtual bool getDHTEnabled();
|
|||||||
/************************************************************************************************/
|
/************************************************************************************************/
|
||||||
|
|
||||||
void setManagers(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr);
|
void setManagers(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr);
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
void setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun);
|
void setAddrAssist(pqiAddrAssist *dhtStun, pqiAddrAssist *proxyStun);
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
|
|
||||||
@ -319,8 +321,10 @@ private:
|
|||||||
p3LinkMgr *mLinkMgr;
|
p3LinkMgr *mLinkMgr;
|
||||||
|
|
||||||
//p3BitDht *mBitDht;
|
//p3BitDht *mBitDht;
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
pqiAddrAssist *mDhtStunner;
|
pqiAddrAssist *mDhtStunner;
|
||||||
pqiAddrAssist *mProxyStunner;
|
pqiAddrAssist *mProxyStunner;
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
RsMutex mNetMtx; /* protects below */
|
RsMutex mNetMtx; /* protects below */
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ virtual void updatePeer(const RsPeerId& id, const struct sockaddr_storage &addr
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
/* this is for the Stunners
|
/* this is for the Stunners
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -132,7 +133,7 @@ virtual void setRefreshPeriod(int32_t period) = 0;
|
|||||||
virtual int tick() = 0; /* for internal accounting */
|
virtual int tick() = 0; /* for internal accounting */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
#define NETASSIST_KNOWN_PEER_OFFLINE 0x0001
|
#define NETASSIST_KNOWN_PEER_OFFLINE 0x0001
|
||||||
#define NETASSIST_KNOWN_PEER_ONLINE 0x0002
|
#define NETASSIST_KNOWN_PEER_ONLINE 0x0002
|
||||||
|
@ -77,7 +77,9 @@
|
|||||||
#include "grouter/p3grouter.h"
|
#include "grouter/p3grouter.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
#include "tcponudp/udpstunner.h"
|
#include "tcponudp/udpstunner.h"
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
// #define GPG_DEBUG
|
// #define GPG_DEBUG
|
||||||
// #define AUTHSSL_DEBUG
|
// #define AUTHSSL_DEBUG
|
||||||
@ -901,7 +903,9 @@ RsGRouter *rsGRouter = NULL ;
|
|||||||
|
|
||||||
#ifdef RS_USE_BITDHT
|
#ifdef RS_USE_BITDHT
|
||||||
#include "dht/p3bitdht.h"
|
#include "dht/p3bitdht.h"
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
#include "dht/stunaddrassist.h"
|
#include "dht/stunaddrassist.h"
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
#include "udp/udpstack.h"
|
#include "udp/udpstack.h"
|
||||||
#include "tcponudp/udppeer.h"
|
#include "tcponudp/udppeer.h"
|
||||||
@ -1137,6 +1141,7 @@ int RsServer::StartupRetroShare()
|
|||||||
UdpSubReceiver *udpReceivers[RSUDP_NUM_TOU_RECVERS];
|
UdpSubReceiver *udpReceivers[RSUDP_NUM_TOU_RECVERS];
|
||||||
int udpTypes[RSUDP_NUM_TOU_RECVERS];
|
int udpTypes[RSUDP_NUM_TOU_RECVERS];
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
// FIRST DHT STUNNER.
|
// FIRST DHT STUNNER.
|
||||||
UdpStunner *mDhtStunner = new UdpStunner(mDhtStack);
|
UdpStunner *mDhtStunner = new UdpStunner(mDhtStack);
|
||||||
mDhtStunner->setTargetStunPeriod(300); /* slow (5mins) */
|
mDhtStunner->setTargetStunPeriod(300); /* slow (5mins) */
|
||||||
@ -1145,9 +1150,11 @@ int RsServer::StartupRetroShare()
|
|||||||
#ifdef LOCALNET_TESTING
|
#ifdef LOCALNET_TESTING
|
||||||
mDhtStunner->SetAcceptLocalNet();
|
mDhtStunner->SetAcceptLocalNet();
|
||||||
#endif
|
#endif
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
|
|
||||||
// NEXT BITDHT.
|
// NEXT BITDHT.
|
||||||
p3BitDht *mBitDht = new p3BitDht(ownId, mLinkMgr, mNetMgr, mDhtStack, bootstrapfile, filteredipfile);
|
p3BitDht *mBitDht = new p3BitDht(ownId, mLinkMgr, mNetMgr, mDhtStack, bootstrapfile, filteredipfile);
|
||||||
|
|
||||||
/* install external Pointer for Interface */
|
/* install external Pointer for Interface */
|
||||||
rsDht = mBitDht;
|
rsDht = mBitDht;
|
||||||
@ -1188,6 +1195,7 @@ int RsServer::StartupRetroShare()
|
|||||||
rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(sndladdr);
|
rsFixedUdpStack *mProxyStack = new rsFixedUdpStack(sndladdr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
// FIRSTLY THE PROXY STUNNER.
|
// FIRSTLY THE PROXY STUNNER.
|
||||||
UdpStunner *mProxyStunner = new UdpStunner(mProxyStack);
|
UdpStunner *mProxyStunner = new UdpStunner(mProxyStack);
|
||||||
mProxyStunner->setTargetStunPeriod(300); /* slow (5mins) */
|
mProxyStunner->setTargetStunPeriod(300); /* slow (5mins) */
|
||||||
@ -1196,6 +1204,7 @@ int RsServer::StartupRetroShare()
|
|||||||
#ifdef LOCALNET_TESTING
|
#ifdef LOCALNET_TESTING
|
||||||
mProxyStunner->SetAcceptLocalNet();
|
mProxyStunner->SetAcceptLocalNet();
|
||||||
#endif
|
#endif
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
|
|
||||||
// FINALLY THE PROXY UDP CONNECTIONS
|
// FINALLY THE PROXY UDP CONNECTIONS
|
||||||
@ -1206,9 +1215,15 @@ int RsServer::StartupRetroShare()
|
|||||||
// REAL INITIALISATION - WITH THREE MODES
|
// REAL INITIALISATION - WITH THREE MODES
|
||||||
tou_init((void **) udpReceivers, udpTypes, RSUDP_NUM_TOU_RECVERS);
|
tou_init((void **) udpReceivers, udpTypes, RSUDP_NUM_TOU_RECVERS);
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
mBitDht->setupConnectBits(mDhtStunner, mProxyStunner, mRelay);
|
mBitDht->setupConnectBits(mDhtStunner, mProxyStunner, mRelay);
|
||||||
|
#else // RS_USE_DHT_STUNNER
|
||||||
|
mBitDht->setupConnectBits(mRelay);
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
|
|
||||||
|
#ifdef RS_USE_DHT_STUNNER
|
||||||
mNetMgr->setAddrAssist(new stunAddrAssist(mDhtStunner), new stunAddrAssist(mProxyStunner));
|
mNetMgr->setAddrAssist(new stunAddrAssist(mDhtStunner), new stunAddrAssist(mProxyStunner));
|
||||||
|
#endif // RS_USE_DHT_STUNNER
|
||||||
#else
|
#else
|
||||||
/* install NULL Pointer for rsDht Interface */
|
/* install NULL Pointer for rsDht Interface */
|
||||||
rsDht = NULL;
|
rsDht = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user