mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
More Plumbing changes.
* Forgot that RELAY connections need extra parameters. * Added proxyAddr, srcAddr and Bandwidth parameters to connection attempts. * Completed UDP connection callouts from p3bitdht. * Added TCP connection attempt initiation from p3bitdht. * Added PASSIVE / ACTIVE determination in p3bitdht. * completed UDP connection logic in pqissludp. * enabled UDPSTUN_ALLOW_LOCALNET for testing. * added CONSTs for TOU Receiver Indices. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-netupgrade@4446 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
22debbce34
commit
86bdc5dfd0
@ -96,6 +96,7 @@ class DhtPeerDetails
|
||||
#define PEERNET_ACTION_TYPE_START 3
|
||||
#define PEERNET_ACTION_TYPE_RESTARTREQ 4
|
||||
#define PEERNET_ACTION_TYPE_KILLREQ 5
|
||||
#define PEERNET_ACTION_TYPE_TCPATTEMPT 6
|
||||
|
||||
class PeerAction
|
||||
{
|
||||
@ -215,6 +216,14 @@ int removeRelayConnection(const bdId *srcId, const bdId *destId);
|
||||
void monitorConnections();
|
||||
|
||||
void ConnectCallout(const std::string &peerId, struct sockaddr_in addr, uint32_t connectMode);
|
||||
|
||||
void ConnectCalloutTCPAttempt(const std::string &peerId, struct sockaddr_in addr);
|
||||
void ConnectCalloutDirectOrProxy(const std::string &peerId, struct sockaddr_in raddr, uint32_t connectFlags, uint32_t delay);
|
||||
void ConnectCalloutRelay(const std::string &peerId, struct sockaddr_in srcaddr,
|
||||
struct sockaddr_in proxyaddr, struct sockaddr_in destaddr,
|
||||
uint32_t connectMode, uint32_t bandwidth);
|
||||
|
||||
|
||||
void Feedback_Connected(std::string pid);
|
||||
void Feedback_ConnectionFailed(std::string pid);
|
||||
void UdpConnectionFailed_locked(DhtPeerDetails *dpd);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "tcponudp/udprelay.h"
|
||||
|
||||
#include "pqi/p3netmgr.h"
|
||||
#include "pqi/pqimonitor.h"
|
||||
|
||||
#define PEERNET_CONNECT_TIMEOUT 45
|
||||
|
||||
@ -308,6 +309,7 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t status, DhtPeer
|
||||
}
|
||||
|
||||
bool connectOk = true;
|
||||
bool doTCPCallback = false;
|
||||
|
||||
/* work out network state */
|
||||
uint32_t connectFlags = dpd->mConnectLogic.connectCb(CSB_CONNECT_DIRECT,
|
||||
@ -322,6 +324,11 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t status, DhtPeer
|
||||
connectOk = false;
|
||||
}
|
||||
break;
|
||||
case CSB_ACTION_TCP_CONN:
|
||||
{
|
||||
connectOk = false;
|
||||
doTCPCallback = true;
|
||||
}
|
||||
case CSB_ACTION_DIRECT_CONN:
|
||||
{
|
||||
|
||||
@ -361,6 +368,24 @@ int p3BitDht::OnlinePeerCallback_locked(const bdId *id, uint32_t status, DhtPeer
|
||||
|
||||
mActions.push_back(ca);
|
||||
}
|
||||
|
||||
/* might need to make this an ACTION - leave for now */
|
||||
if (doTCPCallback)
|
||||
{
|
||||
std::cerr << "dhtPeerCallback. Peer Online, triggering TCP Connection for: ";
|
||||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* Push Back PeerAction */
|
||||
PeerAction ca;
|
||||
ca.mType = PEERNET_ACTION_TYPE_TCPATTEMPT;
|
||||
ca.mMode = BITDHT_CONNECT_MODE_DIRECT;
|
||||
ca.mDestId = *id;
|
||||
ca.mAnswer = BITDHT_CONNECT_ERROR_NONE;
|
||||
|
||||
//ConnectCalloutTCPAttempt(dpd->mRsId, id->addr);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1206,6 +1231,46 @@ int p3BitDht::doActions()
|
||||
}
|
||||
break;
|
||||
|
||||
case PEERNET_ACTION_TYPE_TCPATTEMPT:
|
||||
{
|
||||
/* connect attempt */
|
||||
std::cerr << "PeerAction. TCP Connection Attempt to: ";
|
||||
bdStdPrintId(std::cerr, &(action.mDestId));
|
||||
std::cerr << " mode: " << action.mMode;
|
||||
std::cerr << std::endl;
|
||||
|
||||
struct sockaddr_in laddr;
|
||||
sockaddr_clear(&laddr);
|
||||
uint32_t start = 0;
|
||||
mUdpBitDht->ConnectionRequest(&laddr, &(action.mDestId.id), action.mMode, start);
|
||||
|
||||
std::string peerRsId;
|
||||
bool foundPeerId = false;
|
||||
{
|
||||
RsStackMutex stack(dhtMtx); /********** LOCKED MUTEX ***************/
|
||||
|
||||
DhtPeerDetails *dpd = findInternalDhtPeer_locked(&(action.mDestId.id), RSDHT_PEERTYPE_ANY);
|
||||
if (dpd)
|
||||
{
|
||||
peerRsId = dpd->mRsId;
|
||||
foundPeerId = true;
|
||||
std::cerr << "PeerAction. TCP Connection Attempt. DoingCallback for RsID: ";
|
||||
std::cerr << peerRsId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "PeerAction. TCP Connection Attempt. ERROR unknown peer";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundPeerId)
|
||||
{
|
||||
ConnectCalloutTCPAttempt(peerRsId, action.mDestId.addr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -1364,12 +1429,59 @@ int p3BitDht::checkConnectionAllowed(const bdId *peerId, int mode)
|
||||
*/
|
||||
|
||||
|
||||
void p3BitDht::ConnectCallout(const std::string &peerId, struct sockaddr_in addr, uint32_t connectMode)
|
||||
void p3BitDht::ConnectCalloutTCPAttempt(const std::string &peerId, struct sockaddr_in raddr)
|
||||
{
|
||||
struct sockaddr_in proxyaddr;
|
||||
struct sockaddr_in srcaddr;
|
||||
|
||||
sockaddr_clear(&proxyaddr);
|
||||
sockaddr_clear(&srcaddr);
|
||||
|
||||
uint32_t source = RS_CB_DHT;
|
||||
uint32_t connectFlags = RS_CB_FLAG_ORDER_UNSPEC | RS_CB_FLAG_MODE_TCP;
|
||||
uint32_t delay = 0;
|
||||
uint32_t bandwidth = 0;
|
||||
|
||||
mConnCb->peerConnectRequest(peerId, raddr, proxyaddr, srcaddr, source, connectFlags, delay, bandwidth);
|
||||
}
|
||||
|
||||
|
||||
void p3BitDht::ConnectCalloutDirectOrProxy(const std::string &peerId, struct sockaddr_in raddr, uint32_t connectFlags, uint32_t delay)
|
||||
{
|
||||
struct sockaddr_in proxyaddr;
|
||||
struct sockaddr_in srcaddr;
|
||||
|
||||
sockaddr_clear(&proxyaddr);
|
||||
sockaddr_clear(&srcaddr);
|
||||
|
||||
uint32_t source = RS_CB_DHT;
|
||||
uint32_t bandwidth = 0;
|
||||
|
||||
mConnCb->peerConnectRequest(peerId, raddr, proxyaddr, srcaddr, source, connectFlags, delay, bandwidth);
|
||||
}
|
||||
|
||||
void p3BitDht::ConnectCalloutRelay(const std::string &peerId,
|
||||
struct sockaddr_in srcaddr, struct sockaddr_in proxyaddr, struct sockaddr_in destaddr,
|
||||
uint32_t connectFlags, uint32_t bandwidth)
|
||||
{
|
||||
|
||||
sockaddr_clear(&proxyaddr);
|
||||
sockaddr_clear(&srcaddr);
|
||||
|
||||
uint32_t source = RS_CB_DHT;
|
||||
uint32_t delay = 0;
|
||||
|
||||
mConnCb->peerConnectRequest(peerId, destaddr, proxyaddr, srcaddr, source, connectFlags, delay, bandwidth);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//virtual void peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
// struct sockaddr_in proxyaddr, struct sockaddr_in srcaddr,
|
||||
// uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth) = 0;
|
||||
|
||||
|
||||
void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const bdId *destId, uint32_t mode, uint32_t loc, uint32_t answer)
|
||||
{
|
||||
std::cerr << "p3BitDht::initiateConnection()";
|
||||
@ -1378,16 +1490,38 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
|
||||
|
||||
bdId peerConnectId;
|
||||
|
||||
uint32_t connectFlags = 0;
|
||||
uint32_t delay = 0;
|
||||
uint32_t bandwidth = 0;
|
||||
|
||||
/* determine who the actual destination is.
|
||||
* as we always specify the remote address, this is all we need.
|
||||
*/
|
||||
if (loc == BD_PROXY_CONNECTION_START_POINT)
|
||||
{
|
||||
peerConnectId = *destId;
|
||||
/* lowest is active */
|
||||
if (srcId < destId)
|
||||
{
|
||||
connectFlags |= RS_CB_FLAG_ORDER_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectFlags |= RS_CB_FLAG_ORDER_PASSIVE;
|
||||
}
|
||||
}
|
||||
else if (loc == BD_PROXY_CONNECTION_END_POINT)
|
||||
{
|
||||
peerConnectId = *srcId;
|
||||
/* lowest is active (we are now dest - in this case) */
|
||||
if (destId < srcId)
|
||||
{
|
||||
connectFlags |= RS_CB_FLAG_ORDER_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectFlags |= RS_CB_FLAG_ORDER_PASSIVE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1432,6 +1566,8 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
|
||||
default:
|
||||
case BITDHT_CONNECT_MODE_DIRECT:
|
||||
touConnectMode = RSDHT_TOU_MODE_DIRECT;
|
||||
connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT;
|
||||
delay = answer;
|
||||
break;
|
||||
|
||||
case BITDHT_CONNECT_MODE_PROXY:
|
||||
@ -1443,13 +1579,16 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
|
||||
std::cerr << " UseProxyPort? " << useProxyPort;
|
||||
std::cerr << std::endl;
|
||||
|
||||
delay = answer;
|
||||
if (useProxyPort)
|
||||
{
|
||||
touConnectMode = RSDHT_TOU_MODE_PROXY;
|
||||
connectFlags |= RS_CB_FLAG_MODE_UDP_PROXY;
|
||||
}
|
||||
else
|
||||
{
|
||||
touConnectMode = RSDHT_TOU_MODE_DIRECT;
|
||||
connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1457,6 +1596,8 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
|
||||
|
||||
case BITDHT_CONNECT_MODE_RELAY:
|
||||
touConnectMode = RSDHT_TOU_MODE_RELAY;
|
||||
connectFlags |= RS_CB_FLAG_MODE_UDP_DIRECT;
|
||||
bandwidth = answer;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1475,7 +1616,23 @@ void p3BitDht::initiateConnection(const bdId *srcId, const bdId *proxyId, const
|
||||
|
||||
/* finally we call out to start the connection (Outside of Mutex) */
|
||||
|
||||
ConnectCallout(rsId, peerConnectId.addr, touConnectMode);
|
||||
if ((mode == BITDHT_CONNECT_MODE_DIRECT) || (mode == BITDHT_CONNECT_MODE_PROXY))
|
||||
{
|
||||
ConnectCalloutDirectOrProxy(rsId, peerConnectId.addr, connectFlags, delay);
|
||||
}
|
||||
else if (mode == BITDHT_CONNECT_MODE_RELAY)
|
||||
{
|
||||
if (loc == BD_PROXY_CONNECTION_START_POINT)
|
||||
{
|
||||
ConnectCalloutRelay(rsId, srcId->addr, proxyId->addr, destId->addr, connectFlags, bandwidth);
|
||||
}
|
||||
else // END_POINT
|
||||
{
|
||||
/* reverse order connection call */
|
||||
ConnectCalloutRelay(rsId, destId->addr, proxyId->addr, srcId->addr, connectFlags, bandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -942,9 +942,9 @@ int p3DhtMgr::checkNotifyDHT()
|
||||
|
||||
/* feedback to say we started it! */
|
||||
#ifdef P3DHTMGR_USE_LOCAL_UDP_CONN
|
||||
mConnCb->peerConnectRequest(peer.id, peer.laddr, RS_CB_DHT, 0, 0);
|
||||
mConnCb->peerConnectRequest(peer.id, peer.laddr,peer.laddr,peer.laddr, RS_CB_DHT, 0, 0,0);
|
||||
#else
|
||||
mConnCb->peerConnectRequest(peer.id, peer.raddr, RS_CB_DHT, 0, 0);
|
||||
mConnCb->peerConnectRequest(peer.id, peer.raddr,peer.laddr,peer.laddr, RS_CB_DHT, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
return DHT_MIN_PERIOD;
|
||||
|
@ -586,8 +586,10 @@ const std::string p3LinkMgrIMPL::getOwnId()
|
||||
}
|
||||
|
||||
|
||||
bool p3LinkMgrIMPL::connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags)
|
||||
bool p3LinkMgrIMPL::connectAttempt(const std::string &id, struct sockaddr_in &raddr,
|
||||
struct sockaddr_in &proxyaddr,
|
||||
struct sockaddr_in &srcaddr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags, uint32_t &bandwidth)
|
||||
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
@ -626,19 +628,23 @@ bool p3LinkMgrIMPL::connectAttempt(const std::string &id, struct sockaddr_in &ad
|
||||
it->second.currentConnAddrAttempt = it->second.connAddrs.front();
|
||||
it->second.connAddrs.pop_front();
|
||||
|
||||
addr = it->second.currentConnAddrAttempt.addr;
|
||||
raddr = it->second.currentConnAddrAttempt.addr;
|
||||
delay = it->second.currentConnAddrAttempt.delay;
|
||||
period = it->second.currentConnAddrAttempt.period;
|
||||
type = it->second.currentConnAddrAttempt.type;
|
||||
flags = it->second.currentConnAddrAttempt.flags;
|
||||
|
||||
proxyaddr = it->second.currentConnAddrAttempt.proxyaddr;
|
||||
srcaddr = it->second.currentConnAddrAttempt.srcaddr;
|
||||
bandwidth = it->second.currentConnAddrAttempt.bandwidth;
|
||||
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() found an address: id: " << id << std::endl;
|
||||
std::cerr << " laddr: " << rs_inet_ntoa(addr.sin_addr) << " lport: " << ntohs(addr.sin_port) << " delay: " << delay << " period: " << period;
|
||||
std::cerr << " type: " << type << std::endl;
|
||||
#endif
|
||||
if (addr.sin_addr.s_addr == 0 || addr.sin_port == 0) {
|
||||
if (raddr.sin_addr.s_addr == 0 || raddr.sin_port == 0) {
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() WARNING: address or port is null" << std::endl;
|
||||
std::cerr << " type: " << type << std::endl;
|
||||
@ -1158,24 +1164,33 @@ void p3LinkMgrIMPL::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
|
||||
}
|
||||
|
||||
void p3LinkMgrIMPL::peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay)
|
||||
/* This has become very unwieldy - as extra arguments are required for UDP connections */
|
||||
void p3LinkMgrIMPL::peerConnectRequest(std::string id, struct sockaddr_in raddr, struct sockaddr_in proxyaddr, struct sockaddr_in srcaddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgrIMPL::peerConnectRequest() id: " << id;
|
||||
std::cerr << " raddr: " << rs_inet_ntoa(raddr.sin_addr) << ":" << ntohs(raddr.sin_port);
|
||||
std::cerr << " proxyaddr: " << rs_inet_ntoa(proxyaddr.sin_addr) << ":" << ntohs(proxyaddr.sin_port);
|
||||
std::cerr << " srcaddr: " << rs_inet_ntoa(srcaddr.sin_addr) << ":" << ntohs(srcaddr.sin_port);
|
||||
std::cerr << " source: " << source;
|
||||
std::cerr << " flags: " << flags;
|
||||
std::cerr << " delay: " << delay;
|
||||
std::cerr << " bandwidth: " << bandwidth;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgrIMPL::peerConnectRequest() id: " << id << " raddr: " << rs_inet_ntoa(raddr.sin_addr);
|
||||
out << ":" << ntohs(raddr.sin_port) << " source: " << source;
|
||||
out << "p3LinkMgrIMPL::peerConnectRequest() id: " << id;
|
||||
out << " raddr: " << rs_inet_ntoa(raddr.sin_addr) << ":" << ntohs(raddr.sin_port);
|
||||
std::cerr << " proxyaddr: " << rs_inet_ntoa(proxyaddr.sin_addr) << ":" << ntohs(proxyaddr.sin_port);
|
||||
std::cerr << " srcaddr: " << rs_inet_ntoa(srcaddr.sin_addr) << ":" << ntohs(srcaddr.sin_port);
|
||||
out << " source: " << source;
|
||||
out << " flags: " << flags;
|
||||
out << " delay: " << delay;
|
||||
out << " bandwidth: " << bandwidth;
|
||||
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
@ -1225,7 +1240,7 @@ void p3LinkMgrIMPL::peerConnectRequest(std::string id, struct sockaddr_in rad
|
||||
std::cerr << "p3LinkMgrIMPL::peerConnectRequest() DHT says CONNECT ==> tryConnectUDP()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
tryConnectUDP(id, raddr, flags, delay);
|
||||
tryConnectUDP(id, raddr, proxyaddr, srcaddr, flags, delay, bandwidth);
|
||||
|
||||
}
|
||||
return;
|
||||
@ -1262,7 +1277,10 @@ bool p3LinkMgrIMPL::retryConnect(const std::string &id)
|
||||
|
||||
|
||||
|
||||
bool p3LinkMgrIMPL::tryConnectUDP(const std::string &id, struct sockaddr_in &rUdpAddr, uint32_t flags, uint32_t delay)
|
||||
bool p3LinkMgrIMPL::tryConnectUDP(const std::string &id, struct sockaddr_in &rUdpAddr,
|
||||
struct sockaddr_in &proxyaddr, struct sockaddr_in &srcaddr,
|
||||
uint32_t flags, uint32_t delay, uint32_t bandwidth)
|
||||
|
||||
{
|
||||
RsStackMutex stack(mLinkMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
@ -1323,6 +1341,10 @@ bool p3LinkMgrIMPL::tryConnectUDP(const std::string &id, struct sockaddr_in &r
|
||||
pca.period = P3CONNMGR_UDP_DEFAULT_PERIOD;
|
||||
pca.flags = flags;
|
||||
|
||||
pca.proxyaddr = proxyaddr;
|
||||
pca.srcaddr = srcaddr;
|
||||
pca.bandwidth = bandwidth;
|
||||
|
||||
// Push address to the front... so it happens quickly (before any timings are lost).
|
||||
addAddressIfUnique(it->second.connAddrs, pca, true);
|
||||
}
|
||||
@ -1563,6 +1585,9 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_SpecificAddress(peerConnectState *pee
|
||||
pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY;
|
||||
pca.ts = time(NULL);
|
||||
pca.period = P3CONNMGR_TCP_DEFAULT_PERIOD;
|
||||
sockaddr_clear(&(pca.proxyaddr));
|
||||
sockaddr_clear(&(pca.srcaddr));
|
||||
pca.bandwidth = 0;
|
||||
|
||||
addAddressIfUnique(peer->connAddrs, pca, false);
|
||||
}
|
||||
@ -1592,6 +1617,9 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_CurrentAddresses(peerConnectState *pe
|
||||
pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY;
|
||||
pca.ts = time(NULL);
|
||||
pca.period = P3CONNMGR_TCP_DEFAULT_PERIOD;
|
||||
sockaddr_clear(&(pca.proxyaddr));
|
||||
sockaddr_clear(&(pca.srcaddr));
|
||||
pca.bandwidth = 0;
|
||||
|
||||
addAddressIfUnique(peer->connAddrs, pca, false);
|
||||
}
|
||||
@ -1611,6 +1639,9 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_CurrentAddresses(peerConnectState *pe
|
||||
pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY;
|
||||
pca.ts = time(NULL);
|
||||
pca.period = P3CONNMGR_TCP_DEFAULT_PERIOD;
|
||||
sockaddr_clear(&(pca.proxyaddr));
|
||||
sockaddr_clear(&(pca.srcaddr));
|
||||
pca.bandwidth = 0;
|
||||
|
||||
addAddressIfUnique(peer->connAddrs, pca, false);
|
||||
}
|
||||
@ -1648,6 +1679,9 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses(peerConnectState
|
||||
pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY;
|
||||
pca.ts = time(NULL);
|
||||
pca.period = P3CONNMGR_TCP_DEFAULT_PERIOD;
|
||||
sockaddr_clear(&(pca.proxyaddr));
|
||||
sockaddr_clear(&(pca.srcaddr));
|
||||
pca.bandwidth = 0;
|
||||
|
||||
addAddressIfUnique(peer->connAddrs, pca, false);
|
||||
}
|
||||
@ -1672,6 +1706,9 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_HistoricalAddresses(peerConnectState
|
||||
pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY;
|
||||
pca.ts = time(NULL);
|
||||
pca.period = P3CONNMGR_TCP_DEFAULT_PERIOD;
|
||||
sockaddr_clear(&(pca.proxyaddr));
|
||||
sockaddr_clear(&(pca.srcaddr));
|
||||
pca.bandwidth = 0;
|
||||
|
||||
addAddressIfUnique(peer->connAddrs, pca, false);
|
||||
}
|
||||
@ -1707,6 +1744,10 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_AddDynDNS(peerConnectState *peer, std
|
||||
pca.ts = time(NULL);
|
||||
pca.period = P3CONNMGR_TCP_DEFAULT_PERIOD;
|
||||
|
||||
sockaddr_clear(&(pca.proxyaddr));
|
||||
sockaddr_clear(&(pca.srcaddr));
|
||||
pca.bandwidth = 0;
|
||||
|
||||
/* check address validity */
|
||||
if (locked_CheckPotentialAddr(&(pca.addr), 0))
|
||||
{
|
||||
@ -1746,6 +1787,11 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_AddTunnel(peerConnectState *peer)
|
||||
|
||||
sockaddr_clear(&pca.addr);
|
||||
|
||||
sockaddr_clear(&(pca.proxyaddr));
|
||||
sockaddr_clear(&(pca.srcaddr));
|
||||
pca.bandwidth = 0;
|
||||
|
||||
|
||||
addAddressIfUnique(peer->connAddrs, pca, false);
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,11 @@ class peerConnectAddress
|
||||
uint32_t type;
|
||||
uint32_t flags; /* CB FLAGS defined in pqimonitor.h */
|
||||
time_t ts;
|
||||
|
||||
// Extra Parameters for Relay connections.
|
||||
struct sockaddr_in proxyaddr;
|
||||
struct sockaddr_in srcaddr;
|
||||
uint32_t bandwidth;
|
||||
};
|
||||
|
||||
class peerConnectState
|
||||
@ -169,8 +174,10 @@ virtual void addMonitor(pqiMonitor *mon) = 0;
|
||||
virtual void removeMonitor(pqiMonitor *mon) = 0;
|
||||
|
||||
/****************** Connections *******************/
|
||||
virtual bool connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags) = 0;
|
||||
virtual bool connectAttempt(const std::string &id, struct sockaddr_in &raddr,
|
||||
struct sockaddr_in &proxyaddr, struct sockaddr_in &srcaddr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags, uint32_t &bandwidth) = 0;
|
||||
|
||||
virtual bool connectResult(const std::string &id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address) = 0;
|
||||
virtual bool retryConnect(const std::string &id) = 0;
|
||||
|
||||
@ -194,7 +201,8 @@ virtual bool getTunnelConnection() = 0; // ONLY used by p3peermgr.cc & p3
|
||||
//virtual void peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
// uint32_t type, uint32_t flags, uint32_t source) = 0;
|
||||
//virtual void peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
// uint32_t source, uint32_t flags, uint32_t delay) = 0;
|
||||
// struct sockaddr_in proxyaddr, struct sockaddr_in srcaddr,
|
||||
// uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth) = 0;
|
||||
|
||||
/****************************************************************************/
|
||||
/****************************************************************************/
|
||||
@ -222,8 +230,10 @@ virtual void addMonitor(pqiMonitor *mon);
|
||||
virtual void removeMonitor(pqiMonitor *mon);
|
||||
|
||||
/****************** Connections *******************/
|
||||
virtual bool connectAttempt(const std::string &id, struct sockaddr_in &addr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags);
|
||||
virtual bool connectAttempt(const std::string &id, struct sockaddr_in &raddr,
|
||||
struct sockaddr_in &proxyaddr, struct sockaddr_in &srcaddr,
|
||||
uint32_t &delay, uint32_t &period, uint32_t &type, uint32_t &flags, uint32_t &bandwidth);
|
||||
|
||||
virtual bool connectResult(const std::string &id, bool success, uint32_t flags, struct sockaddr_in remote_peer_address);
|
||||
virtual bool retryConnect(const std::string &id);
|
||||
|
||||
@ -235,7 +245,8 @@ virtual struct sockaddr_in getLocalAddress();
|
||||
virtual void peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t flags, uint32_t source);
|
||||
virtual void peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay);
|
||||
struct sockaddr_in proxyaddr, struct sockaddr_in srcaddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth);
|
||||
|
||||
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
@ -281,7 +292,9 @@ void statusTick();
|
||||
void tickMonitors();
|
||||
|
||||
/* connect attempts UDP */
|
||||
bool tryConnectUDP(const std::string &id, struct sockaddr_in &rUdpAddr, uint32_t flags, uint32_t delay);
|
||||
bool tryConnectUDP(const std::string &id, struct sockaddr_in &rUdpAddr,
|
||||
struct sockaddr_in &proxyaddr, struct sockaddr_in &srcaddr,
|
||||
uint32_t flags, uint32_t delay, uint32_t bandwidth);
|
||||
|
||||
/* connect attempts TCP */
|
||||
bool retryConnectTCP(const std::string &id);
|
||||
|
@ -230,6 +230,10 @@ static const uint32_t NET_PARAM_CONNECT_DELAY = 1;
|
||||
static const uint32_t NET_PARAM_CONNECT_PERIOD = 2;
|
||||
static const uint32_t NET_PARAM_CONNECT_TIMEOUT = 3;
|
||||
static const uint32_t NET_PARAM_CONNECT_FLAGS = 4;
|
||||
static const uint32_t NET_PARAM_CONNECT_BANDWIDTH = 5;
|
||||
|
||||
static const uint32_t NET_PARAM_CONNECT_PROXY = 6;
|
||||
static const uint32_t NET_PARAM_CONNECT_SOURCE = 7;
|
||||
|
||||
|
||||
/*!
|
||||
@ -266,6 +270,7 @@ virtual std::string PeerId() { return peerId; }
|
||||
virtual int getConnectAddress(struct sockaddr_in &raddr) = 0;
|
||||
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value) = 0;
|
||||
virtual bool connect_additional_address(uint32_t type, struct sockaddr_in *addr) { return false; } // only needed by udp.
|
||||
|
||||
protected:
|
||||
PQInterface *parent() { return p; }
|
||||
|
@ -76,14 +76,22 @@ const uint32_t RS_STUN_FRIEND_OF_FRIEND = 0x0040;
|
||||
|
||||
|
||||
#define RS_CB_FLAG_MASK_MODE 0x00ff
|
||||
#define RS_CB_FLAG_MASK_CONN 0x00ff
|
||||
#define RS_CB_FLAG_MASK_ORDER 0xff00
|
||||
|
||||
#define RS_CB_FLAG_MODE_TCP 0x0001
|
||||
#define RS_CB_FLAG_MODE_UDP 0x0002
|
||||
#define RS_CB_FLAG_MODE_UDP_DIRECT 0x0002
|
||||
#define RS_CB_FLAG_MODE_UDP_PROXY 0x0004
|
||||
#define RS_CB_FLAG_MODE_UDP_RELAY 0x0008
|
||||
|
||||
#define RS_CB_FLAG_CONN_UNSPEC 0x0000
|
||||
#define RS_CB_FLAG_CONN_PASSIVE 0x0100
|
||||
#define RS_CB_FLAG_CONN_ACTIVE 0x0200
|
||||
#define RS_CB_FLAG_ORDER_UNSPEC 0x0100
|
||||
#define RS_CB_FLAG_ORDER_PASSIVE 0x0200
|
||||
#define RS_CB_FLAG_ORDER_ACTIVE 0x0400
|
||||
|
||||
#define RSUDP_NUM_TOU_RECVERS 3
|
||||
|
||||
#define RSUDP_TOU_RECVER_DIRECT_IDX 0
|
||||
#define RSUDP_TOU_RECVER_PROXY_IDX 1
|
||||
#define RSUDP_TOU_RECVER_RELAY_IDX 2
|
||||
|
||||
|
||||
class pqipeer
|
||||
@ -149,7 +157,8 @@ virtual void peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
uint32_t type, uint32_t flags, uint32_t source) = 0;
|
||||
|
||||
virtual void peerConnectRequest(std::string id, struct sockaddr_in raddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay) = 0;
|
||||
struct sockaddr_in proxyaddr, struct sockaddr_in srcaddr,
|
||||
uint32_t source, uint32_t flags, uint32_t delay, uint32_t bandwidth) = 0;
|
||||
|
||||
//virtual void stunStatus(std::string id, struct sockaddr_in raddr, uint32_t type, uint32_t flags) = 0;
|
||||
};
|
||||
|
@ -378,19 +378,23 @@ int pqiperson::stoplistening()
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pqiperson::connect(uint32_t type, struct sockaddr_in raddr, uint32_t delay, uint32_t period, uint32_t timeout, uint32_t flags)
|
||||
int pqiperson::connect(uint32_t type, struct sockaddr_in raddr,
|
||||
struct sockaddr_in &proxyaddr, struct sockaddr_in &srcaddr,
|
||||
uint32_t delay, uint32_t period, uint32_t timeout, uint32_t flags, uint32_t bandwidth)
|
||||
{
|
||||
#ifdef PERSON_DEBUG
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiperson::connect() Id: " << PeerId();
|
||||
out << " type: " << type;
|
||||
out << " addr: " << rs_inet_ntoa(raddr.sin_addr);
|
||||
out << ":" << ntohs(raddr.sin_port);
|
||||
out << " addr: " << rs_inet_ntoa(raddr.sin_addr) << ":" << ntohs(raddr.sin_port);
|
||||
out << " proxyaddr: " << rs_inet_ntoa(proxyaddr.sin_addr) << ":" << ntohs(proxyaddr.sin_port);
|
||||
out << " srcaddr: " << rs_inet_ntoa(srcaddr.sin_addr) << ":" << ntohs(srcaddr.sin_port);
|
||||
out << " delay: " << delay;
|
||||
out << " period: " << period;
|
||||
out << " timeout: " << timeout;
|
||||
out << " flags: " << flags;
|
||||
out << " bandwidth: " << bandwidth;
|
||||
out << std::endl;
|
||||
std::cerr << out.str();
|
||||
//pqioutput(PQL_DEBUG_BASIC, pqipersonzone, out.str());
|
||||
@ -430,6 +434,10 @@ int pqiperson::connect(uint32_t type, struct sockaddr_in raddr, uint32_t delay,
|
||||
(it->second)->connect_parameter(NET_PARAM_CONNECT_PERIOD, period);
|
||||
(it->second)->connect_parameter(NET_PARAM_CONNECT_TIMEOUT, timeout);
|
||||
(it->second)->connect_parameter(NET_PARAM_CONNECT_FLAGS, flags);
|
||||
(it->second)->connect_parameter(NET_PARAM_CONNECT_BANDWIDTH, bandwidth);
|
||||
|
||||
(it->second)->connect_additional_address(NET_PARAM_CONNECT_PROXY, &proxyaddr);
|
||||
(it->second)->connect_additional_address(NET_PARAM_CONNECT_SOURCE, &srcaddr);
|
||||
|
||||
(it->second)->connect(raddr);
|
||||
|
||||
|
@ -71,6 +71,10 @@ virtual int stoplistening() { return ni -> stoplistening(); }
|
||||
virtual int reset() { return ni -> reset(); }
|
||||
virtual int disconnect() { return ni -> reset(); }
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value) { return ni -> connect_parameter(type, value);}
|
||||
virtual bool connect_additional_address(uint32_t type, struct sockaddr_in *addr) { return ni -> connect_additional_address(type, addr);}
|
||||
|
||||
|
||||
|
||||
virtual int getConnectAddress(struct sockaddr_in &raddr){ return ni->getConnectAddress(raddr); }
|
||||
|
||||
// get the contact from the net side!
|
||||
@ -106,7 +110,11 @@ virtual ~pqiperson(); // must clean up children.
|
||||
int reset();
|
||||
int listen();
|
||||
int stoplistening();
|
||||
int connect(uint32_t type, struct sockaddr_in raddr, uint32_t delay, uint32_t period, uint32_t timeout, uint32_t flags);
|
||||
|
||||
int connect(uint32_t type, struct sockaddr_in raddr,
|
||||
struct sockaddr_in &proxyaddr, struct sockaddr_in &srcaddr,
|
||||
uint32_t delay, uint32_t period, uint32_t timeout, uint32_t flags, uint32_t bandwidth);
|
||||
|
||||
int receiveHeartbeat();
|
||||
// add in connection method.
|
||||
int addChildInterface(uint32_t type, pqiconnect *pqi);
|
||||
|
@ -550,7 +550,11 @@ int pqipersongrp::connectPeer(std::string id
|
||||
uint32_t type;
|
||||
uint32_t flags;
|
||||
|
||||
if (!mLinkMgr->connectAttempt(id, addr, delay, period, type, flags))
|
||||
struct sockaddr_in proxyaddr;
|
||||
struct sockaddr_in srcaddr;
|
||||
uint32_t bandwidth;
|
||||
|
||||
if (!mLinkMgr->connectAttempt(id, addr, proxyaddr, srcaddr, delay, period, type, flags, bandwidth))
|
||||
{
|
||||
#ifdef PGRP_DEBUG
|
||||
std::cerr << " pqipersongrp::connectPeer() No Net Address";
|
||||
@ -607,7 +611,7 @@ int pqipersongrp::connectPeer(std::string id
|
||||
return 0;
|
||||
}
|
||||
|
||||
p->connect(ptype, addr, delay, period, timeout, flags);
|
||||
p->connect(ptype, addr, proxyaddr, srcaddr, delay, period, timeout, flags, bandwidth);
|
||||
|
||||
} /* UNLOCKED */
|
||||
|
||||
|
@ -105,7 +105,26 @@ int pqissludp::attach()
|
||||
{
|
||||
// IN THE IMPROVED TOU LIBRARY, we need to be careful with the tou_socket PARAMETERS.
|
||||
// For now, this should do!
|
||||
sockfd = tou_socket(0,TOU_RECEIVER_TYPE_UDPPEER,0);
|
||||
sockfd = -1;
|
||||
|
||||
if (mConnectFlags & RS_CB_FLAG_MODE_UDP_DIRECT)
|
||||
{
|
||||
sockfd = tou_socket(RSUDP_TOU_RECVER_DIRECT_IDX,TOU_RECEIVER_TYPE_UDPPEER,0);
|
||||
}
|
||||
else if (mConnectFlags & RS_CB_FLAG_MODE_UDP_PROXY)
|
||||
{
|
||||
sockfd = tou_socket(RSUDP_TOU_RECVER_PROXY_IDX,TOU_RECEIVER_TYPE_UDPPEER,0);
|
||||
}
|
||||
else if (mConnectFlags & RS_CB_FLAG_MODE_UDP_RELAY)
|
||||
{
|
||||
sockfd = tou_socket(RSUDP_TOU_RECVER_RELAY_IDX,TOU_RECEIVER_TYPE_UDPRELAY,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "pqissludp::attach() ERROR unknown Connect Mode" << std::endl;
|
||||
sockfd = -1;
|
||||
}
|
||||
|
||||
if (0 > sockfd)
|
||||
{
|
||||
rslog(RSL_WARNING, pqissludpzone,
|
||||
@ -133,11 +152,11 @@ int pqissludp::Initiate_Connection()
|
||||
"pqissludp::Initiate_Connection() Attempting Outgoing Connection....");
|
||||
|
||||
/* decide if we're active or passive */
|
||||
if (mConnectFlags & RS_CB_FLAG_CONN_ACTIVE)
|
||||
if (mConnectFlags & RS_CB_FLAG_ORDER_ACTIVE)
|
||||
{
|
||||
sslmode = PQISSL_ACTIVE;
|
||||
}
|
||||
else if (mConnectFlags & RS_CB_FLAG_CONN_PASSIVE)
|
||||
else if (mConnectFlags & RS_CB_FLAG_ORDER_PASSIVE)
|
||||
{
|
||||
sslmode = PQISSL_PASSIVE;
|
||||
}
|
||||
@ -207,8 +226,21 @@ int pqissludp::Initiate_Connection()
|
||||
//std::cerr << " Connect Period is:" << mConnectPeriod << std::endl;
|
||||
|
||||
/* <===================== UDP Difference *******************/
|
||||
if (0 != (err = tou_connect(sockfd, (struct sockaddr *) &remote_addr,
|
||||
sizeof(remote_addr), mConnectPeriod)))
|
||||
|
||||
if (mConnectFlags & RS_CB_FLAG_MODE_UDP_DIRECT)
|
||||
{
|
||||
err = tou_connect(sockfd, (struct sockaddr *) &remote_addr, sizeof(remote_addr), mConnectPeriod);
|
||||
}
|
||||
else if (mConnectFlags & RS_CB_FLAG_MODE_UDP_PROXY)
|
||||
{
|
||||
err = tou_connect(sockfd, (struct sockaddr *) &remote_addr, sizeof(remote_addr), mConnectPeriod);
|
||||
}
|
||||
else if (mConnectFlags & RS_CB_FLAG_MODE_UDP_RELAY)
|
||||
{
|
||||
tou_connect_via_relay(sockfd, &(mConnectSrcAddr), &(mConnectProxyAddr), &(remote_addr));
|
||||
}
|
||||
|
||||
if (0 != err)
|
||||
/* <===================== UDP Difference *******************/
|
||||
{
|
||||
int tou_err = tou_errno(sockfd);
|
||||
@ -441,9 +473,49 @@ bool pqissludp::connect_parameter(uint32_t type, uint32_t value)
|
||||
mConnectFlags = value;
|
||||
return true;
|
||||
}
|
||||
else if (type == NET_PARAM_CONNECT_BANDWIDTH)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::connect_parameter() Peer: " << PeerId() << " BANDWIDTH: " << value;
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
mConnectFlags = value;
|
||||
return true;
|
||||
}
|
||||
return pqissl::connect_parameter(type, value);
|
||||
}
|
||||
|
||||
bool pqissludp::connect_additional_address(uint32_t type, struct sockaddr_in *addr)
|
||||
{
|
||||
struct sockaddr_in mConnectProxyAddr;
|
||||
struct sockaddr_in mConnectSrcAddr;
|
||||
if (type == NET_PARAM_CONNECT_PROXY)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::connect_parameter() Peer: " << PeerId() << " PROXYADDR: ";
|
||||
out << rs_inet_ntoa(addr->sin_addr) << ":" << ntohs(addr->sin_port);
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
mConnectProxyAddr = *addr;
|
||||
|
||||
std::cerr << out.str() << std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (type == NET_PARAM_CONNECT_SOURCE)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::connect_parameter() Peer: " << PeerId() << " SRCADDR: ";
|
||||
out << rs_inet_ntoa(addr->sin_addr) << ":" << ntohs(addr->sin_port);
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
mConnectSrcAddr = *addr;
|
||||
|
||||
std::cerr << out.str() << std::endl;
|
||||
return true;
|
||||
}
|
||||
return pqissl::connect_additional_address(type, addr);
|
||||
}
|
||||
|
||||
/********** PQI STREAMER OVERLOADING *********************************/
|
||||
|
||||
bool pqissludp::moretoread()
|
||||
|
@ -67,6 +67,7 @@ virtual int tick();
|
||||
virtual int reset();
|
||||
|
||||
virtual bool connect_parameter(uint32_t type, uint32_t value);
|
||||
virtual bool connect_additional_address(uint32_t type, struct sockaddr_in *addr);
|
||||
|
||||
// BinInterface.
|
||||
// These are reimplemented.
|
||||
@ -100,6 +101,10 @@ private:
|
||||
|
||||
uint32_t mConnectPeriod;
|
||||
uint32_t mConnectFlags;
|
||||
uint32_t mConnectBandwidth;
|
||||
|
||||
struct sockaddr_in mConnectProxyAddr;
|
||||
struct sockaddr_in mConnectSrcAddr;
|
||||
};
|
||||
|
||||
#endif // MRK_PQI_SSL_UDP_HEADER
|
||||
|
@ -1905,8 +1905,8 @@ int RsServer::StartupRetroShare()
|
||||
/* construct the rest of the stack, important to build them in the correct order! */
|
||||
/* MOST OF THIS IS COMMENTED OUT UNTIL THE REST OF libretroshare IS READY FOR IT! */
|
||||
|
||||
UdpSubReceiver *udpReceivers[3];
|
||||
int udpTypes[3];
|
||||
UdpSubReceiver *udpReceivers[RSUDP_NUM_TOU_RECVERS];
|
||||
int udpTypes[RSUDP_NUM_TOU_RECVERS];
|
||||
|
||||
// FIRST DHT STUNNER.
|
||||
UdpStunner *mDhtStunner = new UdpStunner(mDhtStack);
|
||||
@ -1920,14 +1920,14 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
// NEXT THE RELAY (NEED to keep a reference for installing RELAYS)
|
||||
UdpRelayReceiver *mRelay = new UdpRelayReceiver(mDhtStack);
|
||||
udpReceivers[2] = mRelay; /* RELAY Connections (DHT Port) */
|
||||
udpTypes[2] = TOU_RECEIVER_TYPE_UDPRELAY;
|
||||
mDhtStack->addReceiver(udpReceivers[2]);
|
||||
udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX] = mRelay; /* RELAY Connections (DHT Port) */
|
||||
udpTypes[RSUDP_TOU_RECVER_RELAY_IDX] = TOU_RECEIVER_TYPE_UDPRELAY;
|
||||
mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_RELAY_IDX]);
|
||||
|
||||
// LAST ON THIS STACK IS STANDARD DIRECT TOU
|
||||
udpReceivers[0] = new UdpPeerReceiver(mDhtStack); /* standard DIRECT Connections (DHT Port) */
|
||||
udpTypes[0] = TOU_RECEIVER_TYPE_UDPPEER;
|
||||
mDhtStack->addReceiver(udpReceivers[0]);
|
||||
udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX] = new UdpPeerReceiver(mDhtStack); /* standard DIRECT Connections (DHT Port) */
|
||||
udpTypes[RSUDP_TOU_RECVER_DIRECT_IDX] = TOU_RECEIVER_TYPE_UDPPEER;
|
||||
mDhtStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_DIRECT_IDX]);
|
||||
|
||||
// NOW WE BUILD THE SECOND STACK.
|
||||
// Create the Second UdpStack... Port should be random (but openable!).
|
||||
@ -1947,12 +1947,12 @@ int RsServer::StartupRetroShare()
|
||||
mProxyStack->addReceiver(mProxyStunner);
|
||||
|
||||
// FINALLY THE PROXY UDP CONNECTIONS
|
||||
udpReceivers[1] = new UdpPeerReceiver(mProxyStack); /* PROXY Connections (Alt UDP Port) */
|
||||
udpTypes[1] = TOU_RECEIVER_TYPE_UDPPEER;
|
||||
mProxyStack->addReceiver(udpReceivers[1]);
|
||||
udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX] = new UdpPeerReceiver(mProxyStack); /* PROXY Connections (Alt UDP Port) */
|
||||
udpTypes[RSUDP_TOU_RECVER_PROXY_IDX] = TOU_RECEIVER_TYPE_UDPPEER;
|
||||
mProxyStack->addReceiver(udpReceivers[RSUDP_TOU_RECVER_PROXY_IDX]);
|
||||
|
||||
// REAL INITIALISATION - WITH THREE MODES
|
||||
tou_init((void **) udpReceivers, udpTypes, 3);
|
||||
tou_init((void **) udpReceivers, udpTypes, RSUDP_NUM_TOU_RECVERS);
|
||||
|
||||
mBitDht->setupConnectBits(mDhtStunner, mProxyStunner, mRelay);
|
||||
|
||||
|
@ -68,9 +68,12 @@ class TouStunPeer
|
||||
};
|
||||
|
||||
/*
|
||||
* FOR TESTING ONLY.
|
||||
* #define UDPSTUN_ALLOW_LOCALNET 1
|
||||
*/
|
||||
|
||||
#define UDPSTUN_ALLOW_LOCALNET 1
|
||||
|
||||
class UdpStunner: public UdpSubReceiver
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user