mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 07:59:29 -05:00
Important changes to tighten up the connection methods:
* Switched to miniupnpc-1.0 * modified miniupnpc to add lease duration. * set lease duration to 1 Hr. * Modified configure scripts to use miniupnpc-1.0 * added TIMEOUT to all connections (5 sec for TCP - Important!) * reduced TCP offset delay to 2 seconds. * BUGFIX: Added missing connect_parameter wrapper function. * added reset to other connection methods when connection is made. * Added Connection Type (TCP/UDP) information to feedback/GUI * Increased default Data Rates: from 50/50 to 100/500 kB/s * Removed Default Bootstrap Ids. (only automatic now!) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@423 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8079660291
commit
8d3f9a3ec6
@ -59,7 +59,7 @@ const uint32_t MAX_UPNP_INIT = 30; /* seconds UPnP timeout */
|
|||||||
|
|
||||||
#define CONN_DEBUG 1
|
#define CONN_DEBUG 1
|
||||||
|
|
||||||
const uint32_t P3CONNMGR_TCP_DEFAULT_DELAY = 10; /* 10 Seconds should be enough! */
|
const uint32_t P3CONNMGR_TCP_DEFAULT_DELAY = 2; /* 2 Seconds? is it be enough! */
|
||||||
const uint32_t P3CONNMGR_UDP_DHT_DELAY = DHT_NOTIFY_PERIOD + 60; /* + 1 minute for DHT POST */
|
const uint32_t P3CONNMGR_UDP_DHT_DELAY = DHT_NOTIFY_PERIOD + 60; /* + 1 minute for DHT POST */
|
||||||
const uint32_t P3CONNMGR_UDP_PROXY_DELAY = 30; /* 30 seconds (NOT IMPLEMENTED YET!) */
|
const uint32_t P3CONNMGR_UDP_PROXY_DELAY = 30; /* 30 seconds (NOT IMPLEMENTED YET!) */
|
||||||
|
|
||||||
@ -86,6 +86,7 @@ peerConnectState::peerConnectState()
|
|||||||
:id("unknown"),
|
:id("unknown"),
|
||||||
netMode(RS_NET_MODE_UNKNOWN), visState(RS_VIS_STATE_STD),
|
netMode(RS_NET_MODE_UNKNOWN), visState(RS_VIS_STATE_STD),
|
||||||
lastcontact(0),
|
lastcontact(0),
|
||||||
|
connecttype(0),
|
||||||
lastavailable(0),
|
lastavailable(0),
|
||||||
lastattempt(0),
|
lastattempt(0),
|
||||||
name("nameless"), state(0), actions(0),
|
name("nameless"), state(0), actions(0),
|
||||||
@ -1328,6 +1329,7 @@ bool p3ConnectMgr::connectResult(std::string id, bool success, uint32_t flags)
|
|||||||
it->second.actions |= RS_PEER_CONNECTED;
|
it->second.actions |= RS_PEER_CONNECTED;
|
||||||
mStatusChanged = true;
|
mStatusChanged = true;
|
||||||
it->second.lastcontact = time(NULL); /* time of connect */
|
it->second.lastcontact = time(NULL); /* time of connect */
|
||||||
|
it->second.connecttype = flags;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2774,12 +2776,7 @@ bool p3ConnectMgr::addBootstrapStunPeers()
|
|||||||
struct sockaddr_in dummyaddr;
|
struct sockaddr_in dummyaddr;
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
|
|
||||||
// Two Defaults for The Initial Release.
|
/* only use the Bootstrap system now */
|
||||||
id = "7ad672ea4d4af8560d5230aff3c88b59";
|
|
||||||
stunCollect(RsUtil::HashId(id, false), dummyaddr, flags);
|
|
||||||
|
|
||||||
id = "8ad7c08e7778e0289de04843bf57a6ae";
|
|
||||||
stunCollect(RsUtil::HashId(id, false), dummyaddr, flags);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,8 @@ const uint32_t RS_NET_FLAGS_ONLINE = 0x0004;
|
|||||||
const uint32_t RS_NET_FLAGS_EXTERNAL_ADDR = 0x0008;
|
const uint32_t RS_NET_FLAGS_EXTERNAL_ADDR = 0x0008;
|
||||||
const uint32_t RS_NET_FLAGS_STABLE_UDP = 0x0010;
|
const uint32_t RS_NET_FLAGS_STABLE_UDP = 0x0010;
|
||||||
|
|
||||||
|
const uint32_t RS_TCP_STD_TIMEOUT_PERIOD = 5; /* 5 seconds! */
|
||||||
|
|
||||||
class peerAddrInfo
|
class peerAddrInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -126,6 +128,8 @@ class peerConnectState
|
|||||||
time_t lastcontact;
|
time_t lastcontact;
|
||||||
|
|
||||||
/***** Below here not stored permanently *****/
|
/***** Below here not stored permanently *****/
|
||||||
|
|
||||||
|
uint32_t connecttype; // RS_NET_CONN_TCP_ALL / RS_NET_CONN_UDP_ALL
|
||||||
time_t lastavailable;
|
time_t lastavailable;
|
||||||
time_t lastattempt;
|
time_t lastattempt;
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "pqi/pqinetwork.h"
|
#include "pqi/pqinetwork.h"
|
||||||
|
|
||||||
@ -345,8 +346,9 @@ static const int NET_CONNECT_UNREACHABLE = 3;
|
|||||||
static const int NET_CONNECT_FIREWALLED = 4;
|
static const int NET_CONNECT_FIREWALLED = 4;
|
||||||
static const int NET_CONNECT_FAILED = 5;
|
static const int NET_CONNECT_FAILED = 5;
|
||||||
|
|
||||||
static const uint32_t NET_PARAM_CONNECT_DELAY = 1;
|
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_PERIOD = 2;
|
||||||
|
static const uint32_t NET_PARAM_CONNECT_TIMEOUT = 3;
|
||||||
|
|
||||||
class NetInterface
|
class NetInterface
|
||||||
{
|
{
|
||||||
@ -366,7 +368,7 @@ virtual int disconnect() = 0;
|
|||||||
virtual int reset() = 0;
|
virtual int reset() = 0;
|
||||||
virtual std::string PeerId() { return peerId; }
|
virtual std::string PeerId() { return peerId; }
|
||||||
|
|
||||||
virtual bool connect_parameter(uint32_t type, uint32_t value) { return false; }
|
virtual bool connect_parameter(uint32_t type, uint32_t value) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PQInterface *parent() { return p; }
|
PQInterface *parent() { return p; }
|
||||||
|
@ -135,6 +135,7 @@ virtual int listen();
|
|||||||
virtual int stoplistening();
|
virtual int stoplistening();
|
||||||
virtual int disconnect();
|
virtual int disconnect();
|
||||||
virtual int reset();
|
virtual int reset();
|
||||||
|
virtual bool connect_parameter(uint32_t type, uint32_t value) { return false; }
|
||||||
|
|
||||||
// Bin Interface.
|
// Bin Interface.
|
||||||
virtual int tick();
|
virtual int tick();
|
||||||
|
@ -148,6 +148,7 @@ int pqiperson::notifyEvent(NetInterface *ni, int newState)
|
|||||||
|
|
||||||
/* find the pqi, */
|
/* find the pqi, */
|
||||||
pqiconnect *pqi = NULL;
|
pqiconnect *pqi = NULL;
|
||||||
|
uint32_t type = 0;
|
||||||
std::map<uint32_t, pqiconnect *>::iterator it;
|
std::map<uint32_t, pqiconnect *>::iterator it;
|
||||||
|
|
||||||
/* start again */
|
/* start again */
|
||||||
@ -167,6 +168,7 @@ int pqiperson::notifyEvent(NetInterface *ni, int newState)
|
|||||||
if ((it->second)->thisNetInterface(ni))
|
if ((it->second)->thisNetInterface(ni))
|
||||||
{
|
{
|
||||||
pqi = (it->second);
|
pqi = (it->second);
|
||||||
|
type = (it->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +186,7 @@ int pqiperson::notifyEvent(NetInterface *ni, int newState)
|
|||||||
|
|
||||||
/* notify */
|
/* notify */
|
||||||
if (pqipg)
|
if (pqipg)
|
||||||
pqipg->notifyConnect(PeerId(), true);
|
pqipg->notifyConnect(PeerId(), type, true);
|
||||||
|
|
||||||
if ((active) && (activepqi != pqi)) // already connected - trouble
|
if ((active) && (activepqi != pqi)) // already connected - trouble
|
||||||
{
|
{
|
||||||
@ -202,13 +204,20 @@ int pqiperson::notifyEvent(NetInterface *ni, int newState)
|
|||||||
{
|
{
|
||||||
|
|
||||||
pqioutput(PQL_WARNING, pqipersonzone,
|
pqioutput(PQL_WARNING, pqipersonzone,
|
||||||
"CONNECT_SUCCESS->marking so!");
|
"CONNECT_SUCCESS->marking so! (resetting others)");
|
||||||
// mark as active.
|
// mark as active.
|
||||||
active = true;
|
active = true;
|
||||||
activepqi = pqi;
|
activepqi = pqi;
|
||||||
|
|
||||||
|
|
||||||
inConnectAttempt = false;
|
inConnectAttempt = false;
|
||||||
|
|
||||||
|
/* reset all other children? (clear up long UDP attempt) */
|
||||||
|
for(it = kids.begin(); it != kids.end(); it++)
|
||||||
|
{
|
||||||
|
if (it->second != activepqi)
|
||||||
|
{
|
||||||
|
it->second->reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -243,7 +252,7 @@ int pqiperson::notifyEvent(NetInterface *ni, int newState)
|
|||||||
|
|
||||||
/* notify up (But not if we are actually active: rtn -1 case above) */
|
/* notify up (But not if we are actually active: rtn -1 case above) */
|
||||||
if (pqipg)
|
if (pqipg)
|
||||||
pqipg->notifyConnect(PeerId(), false);
|
pqipg->notifyConnect(PeerId(), type, false);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -334,7 +343,7 @@ int pqiperson::stoplistening()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pqiperson::connect(uint32_t type, struct sockaddr_in raddr, uint32_t delay, uint32_t period)
|
int pqiperson::connect(uint32_t type, struct sockaddr_in raddr, uint32_t delay, uint32_t period, uint32_t timeout)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
@ -342,6 +351,9 @@ int pqiperson::connect(uint32_t type, struct sockaddr_in raddr, uint32_t delay,
|
|||||||
out << " type: " << type;
|
out << " type: " << type;
|
||||||
out << " addr: " << inet_ntoa(raddr.sin_addr);
|
out << " addr: " << inet_ntoa(raddr.sin_addr);
|
||||||
out << ":" << ntohs(raddr.sin_port);
|
out << ":" << ntohs(raddr.sin_port);
|
||||||
|
out << " delay: " << delay;
|
||||||
|
out << " period: " << period;
|
||||||
|
out << " timeout: " << timeout;
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
std::cerr << out.str();
|
std::cerr << out.str();
|
||||||
//pqioutput(PQL_DEBUG_BASIC, pqipersonzone, out.str());
|
//pqioutput(PQL_DEBUG_BASIC, pqipersonzone, out.str());
|
||||||
@ -363,8 +375,12 @@ int pqiperson::connect(uint32_t type, struct sockaddr_in raddr, uint32_t delay,
|
|||||||
|
|
||||||
/* set the parameters */
|
/* set the parameters */
|
||||||
(it->second)->reset();
|
(it->second)->reset();
|
||||||
|
|
||||||
|
std::cerr << "pqiperson::connect() setting connect_parameters" << std::endl;
|
||||||
(it->second)->connect_parameter(NET_PARAM_CONNECT_DELAY, delay);
|
(it->second)->connect_parameter(NET_PARAM_CONNECT_DELAY, delay);
|
||||||
(it->second)->connect_parameter(NET_PARAM_CONNECT_PERIOD, period);
|
(it->second)->connect_parameter(NET_PARAM_CONNECT_PERIOD, period);
|
||||||
|
(it->second)->connect_parameter(NET_PARAM_CONNECT_TIMEOUT, timeout);
|
||||||
|
|
||||||
(it->second)->connect(raddr);
|
(it->second)->connect(raddr);
|
||||||
|
|
||||||
// flag if we started a new connectionAttempt.
|
// flag if we started a new connectionAttempt.
|
||||||
|
@ -68,6 +68,7 @@ virtual int listen() { return ni -> listen(); }
|
|||||||
virtual int stoplistening() { return ni -> stoplistening(); }
|
virtual int stoplistening() { return ni -> stoplistening(); }
|
||||||
virtual int reset() { return ni -> reset(); }
|
virtual int reset() { return ni -> reset(); }
|
||||||
virtual int disconnect() { 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);}
|
||||||
|
|
||||||
// get the contact from the net side!
|
// get the contact from the net side!
|
||||||
virtual std::string PeerId()
|
virtual std::string PeerId()
|
||||||
@ -102,7 +103,7 @@ virtual ~pqiperson(); // must clean up children.
|
|||||||
int reset();
|
int reset();
|
||||||
int listen();
|
int listen();
|
||||||
int stoplistening();
|
int stoplistening();
|
||||||
int connect(uint32_t type, struct sockaddr_in raddr, uint32_t delay, uint32_t period);
|
int connect(uint32_t type, struct sockaddr_in raddr, uint32_t delay, uint32_t period, uint32_t timeout);
|
||||||
|
|
||||||
// add in connection method.
|
// add in connection method.
|
||||||
int addChildInterface(uint32_t type, pqiconnect *pqi);
|
int addChildInterface(uint32_t type, pqiconnect *pqi);
|
||||||
|
@ -206,10 +206,10 @@ int pqipersongrp::load_config()
|
|||||||
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone,
|
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone,
|
||||||
"pqipersongrp::load_config() Loading Default Rates!");
|
"pqipersongrp::load_config() Loading Default Rates!");
|
||||||
|
|
||||||
setMaxRate(true, 50.0);
|
setMaxRate(true, 500.0);
|
||||||
setMaxRate(false,50.0);
|
setMaxRate(false, 500.0);
|
||||||
setMaxIndivRate(true, 50.0);
|
setMaxIndivRate(true, 100.0);
|
||||||
setMaxIndivRate(false, 50.0);
|
setMaxIndivRate(false, 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -332,6 +332,7 @@ int pqipersongrp::connectPeer(std::string id)
|
|||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
uint32_t delay;
|
uint32_t delay;
|
||||||
uint32_t period;
|
uint32_t period;
|
||||||
|
uint32_t timeout;
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
|
|
||||||
if (!mConnMgr->connectAttempt(id, addr, delay, period, type))
|
if (!mConnMgr->connectAttempt(id, addr, delay, period, type))
|
||||||
@ -352,29 +353,42 @@ int pqipersongrp::connectPeer(std::string id)
|
|||||||
uint32_t ptype;
|
uint32_t ptype;
|
||||||
if (type & RS_NET_CONN_TCP_ALL)
|
if (type & RS_NET_CONN_TCP_ALL)
|
||||||
{
|
{
|
||||||
std::cerr << " pqipersongrp::connectPeer() connecting with TCP";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
ptype = PQI_CONNECT_TCP;
|
ptype = PQI_CONNECT_TCP;
|
||||||
|
timeout = RS_TCP_STD_TIMEOUT_PERIOD;
|
||||||
|
std::cerr << " pqipersongrp::connectPeer() connecting with TCP: Timeout :" << timeout;
|
||||||
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
else if (type & RS_NET_CONN_UDP_ALL)
|
else if (type & RS_NET_CONN_UDP_ALL)
|
||||||
{
|
{
|
||||||
std::cerr << " pqipersongrp::connectPeer() connecting with UDP";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
ptype = PQI_CONNECT_UDP;
|
ptype = PQI_CONNECT_UDP;
|
||||||
|
timeout = period * 2;
|
||||||
|
std::cerr << " pqipersongrp::connectPeer() connecting with UDP: Timeout :" << timeout;
|
||||||
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
p->connect(ptype, addr, delay, period);
|
p->connect(ptype, addr, delay, period, timeout);
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pqipersongrp::notifyConnect(std::string id, bool success)
|
bool pqipersongrp::notifyConnect(std::string id, uint32_t ptype, bool success)
|
||||||
{
|
{
|
||||||
|
uint32_t type = 0;
|
||||||
|
if (ptype == PQI_CONNECT_TCP)
|
||||||
|
{
|
||||||
|
type = RS_NET_CONN_TCP_ALL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = RS_NET_CONN_UDP_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mConnMgr)
|
if (mConnMgr)
|
||||||
mConnMgr->connectResult(id, success, 0);
|
mConnMgr->connectResult(id, success, type);
|
||||||
|
|
||||||
return (NULL != mConnMgr);
|
return (NULL != mConnMgr);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ int removePeer(std::string id);
|
|||||||
int connectPeer(std::string id);
|
int connectPeer(std::string id);
|
||||||
|
|
||||||
/*** callback from children ****/
|
/*** callback from children ****/
|
||||||
bool notifyConnect(std::string id, bool success);
|
bool notifyConnect(std::string id, uint32_t type, bool success);
|
||||||
|
|
||||||
// tick interfaces.
|
// tick interfaces.
|
||||||
virtual int tick();
|
virtual int tick();
|
||||||
|
@ -97,6 +97,7 @@ pqissl::pqissl(pqissllistener *l, PQInterface *parent, p3AuthMgr *am, p3ConnectM
|
|||||||
net_attempt(0), net_failure(0), net_unreachable(0),
|
net_attempt(0), net_failure(0), net_unreachable(0),
|
||||||
sameLAN(false), n_read_zero(0),
|
sameLAN(false), n_read_zero(0),
|
||||||
mConnectDelay(0), mConnectTS(0),
|
mConnectDelay(0), mConnectTS(0),
|
||||||
|
mConnectTimeout(0), mTimeoutTS(0),
|
||||||
|
|
||||||
/**************** PQI_USE_XPGP ******************/
|
/**************** PQI_USE_XPGP ******************/
|
||||||
#if defined(PQI_USE_XPGP)
|
#if defined(PQI_USE_XPGP)
|
||||||
@ -250,12 +251,21 @@ int pqissl::reset()
|
|||||||
|
|
||||||
bool pqissl::connect_parameter(uint32_t type, uint32_t value)
|
bool pqissl::connect_parameter(uint32_t type, uint32_t value)
|
||||||
{
|
{
|
||||||
|
std::cerr << "pqissl::connect_parameter() type: " << type << "value: " << value << std::endl;
|
||||||
if (type == NET_PARAM_CONNECT_DELAY)
|
if (type == NET_PARAM_CONNECT_DELAY)
|
||||||
{
|
{
|
||||||
|
std::cerr << "pqissl::connect_parameter() DELAY: " << value << std::endl;
|
||||||
mConnectDelay = value;
|
mConnectDelay = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return NetInterface::connect_parameter(type, value);
|
else if (type == NET_PARAM_CONNECT_TIMEOUT)
|
||||||
|
{
|
||||||
|
std::cerr << "pqissl::connect_parameter() TIMEOUT: " << value << std::endl;
|
||||||
|
mConnectTimeout = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
//return NetInterface::connect_parameter(type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -587,6 +597,9 @@ int pqissl::Initiate_Connection()
|
|||||||
pqioutput(PQL_DEBUG_BASIC, pqisslzone, out.str());
|
pqioutput(PQL_DEBUG_BASIC, pqisslzone, out.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mTimeoutTS = time(NULL) + mConnectTimeout;
|
||||||
|
std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
|
||||||
|
|
||||||
if (0 != (err = unix_connect(osock, (struct sockaddr *) &addr, sizeof(addr))))
|
if (0 != (err = unix_connect(osock, (struct sockaddr *) &addr, sizeof(addr))))
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
@ -675,6 +688,22 @@ int pqissl::Basic_Connection_Complete()
|
|||||||
pqioutput(PQL_DEBUG_BASIC, pqisslzone,
|
pqioutput(PQL_DEBUG_BASIC, pqisslzone,
|
||||||
"pqissl::Basic_Connection_Complete()...");
|
"pqissl::Basic_Connection_Complete()...");
|
||||||
|
|
||||||
|
/* new TimeOut code. */
|
||||||
|
if (time(NULL) > mTimeoutTS)
|
||||||
|
{
|
||||||
|
pqioutput(PQL_DEBUG_BASIC, pqisslzone,
|
||||||
|
"pqissl::Basic_Connection_Complete() Connection Timed Out!");
|
||||||
|
/* as sockfd is valid, this should close it all up */
|
||||||
|
|
||||||
|
std::cerr << "pqissl::Basic_Connection_Complete() Connection Timed Out!";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "pqissl::Basic_Connection_Complete() Timeout Period: " << mConnectTimeout;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
reset();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (waiting != WAITING_SOCK_CONNECT)
|
if (waiting != WAITING_SOCK_CONNECT)
|
||||||
{
|
{
|
||||||
pqioutput(PQL_DEBUG_BASIC, pqisslzone,
|
pqioutput(PQL_DEBUG_BASIC, pqisslzone,
|
||||||
|
@ -196,6 +196,8 @@ virtual int net_internal_fcntl_nonblock(int fd) { return unix_fcntl_nonblock(fd)
|
|||||||
|
|
||||||
uint32_t mConnectDelay;
|
uint32_t mConnectDelay;
|
||||||
time_t mConnectTS;
|
time_t mConnectTS;
|
||||||
|
uint32_t mConnectTimeout;
|
||||||
|
time_t mTimeoutTS;
|
||||||
|
|
||||||
/**************** PQI_USE_XPGP ******************/
|
/**************** PQI_USE_XPGP ******************/
|
||||||
#if defined(PQI_USE_XPGP)
|
#if defined(PQI_USE_XPGP)
|
||||||
|
@ -48,7 +48,6 @@ const int pqissludpzone = 3144;
|
|||||||
* This is long as the udp connect can take some time.
|
* This is long as the udp connect can take some time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const uint32_t PQI_SSLUDP_CONNECT_TIMEOUT = 600; /* 10 minutes - give it longer! */
|
|
||||||
static const uint32_t PQI_SSLUDP_DEF_CONN_PERIOD = 300; /* 5 minutes? */
|
static const uint32_t PQI_SSLUDP_DEF_CONN_PERIOD = 300; /* 5 minutes? */
|
||||||
|
|
||||||
/********** PQI SSL UDP STUFF **************************************/
|
/********** PQI SSL UDP STUFF **************************************/
|
||||||
@ -187,7 +186,10 @@ int pqissludp::Initiate_Connection()
|
|||||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone, out.str());
|
pqioutput(PQL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
udp_connect_timeout = time(NULL) + PQI_SSLUDP_CONNECT_TIMEOUT;
|
mTimeoutTS = time(NULL) + mConnectTimeout;
|
||||||
|
std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
|
||||||
|
std::cerr << " Connect Period is:" << mConnectPeriod << std::endl;
|
||||||
|
|
||||||
/* <===================== UDP Difference *******************/
|
/* <===================== UDP Difference *******************/
|
||||||
if (0 != (err = tou_connect(sockfd, (struct sockaddr *) &remote_addr,
|
if (0 != (err = tou_connect(sockfd, (struct sockaddr *) &remote_addr,
|
||||||
sizeof(remote_addr), mConnectPeriod)))
|
sizeof(remote_addr), mConnectPeriod)))
|
||||||
@ -250,7 +252,7 @@ int pqissludp::Basic_Connection_Complete()
|
|||||||
"pqissludp::Basic_Connection_Complete()...");
|
"pqissludp::Basic_Connection_Complete()...");
|
||||||
|
|
||||||
|
|
||||||
if (time(NULL) > udp_connect_timeout)
|
if (time(NULL) > mTimeoutTS)
|
||||||
{
|
{
|
||||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||||
"pqissludp::Basic_Connection_Complete() Connection Timed Out!");
|
"pqissludp::Basic_Connection_Complete() Connection Timed Out!");
|
||||||
@ -258,7 +260,10 @@ int pqissludp::Basic_Connection_Complete()
|
|||||||
|
|
||||||
std::cerr << "pqissludp::Basic_Connection_Complete() Connection Timed Out!";
|
std::cerr << "pqissludp::Basic_Connection_Complete() Connection Timed Out!";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "pqissludp::Basic_Connection_Complete() Timeout Period: " << mConnectTimeout;
|
||||||
|
std::cerr << std::endl;
|
||||||
reset();
|
reset();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -396,8 +401,10 @@ int pqissludp::stoplistening()
|
|||||||
|
|
||||||
bool pqissludp::connect_parameter(uint32_t type, uint32_t value)
|
bool pqissludp::connect_parameter(uint32_t type, uint32_t value)
|
||||||
{
|
{
|
||||||
|
std::cerr << "pqissludp::connect_parameter() type: " << type << "value: " << value << std::endl;
|
||||||
if (type == NET_PARAM_CONNECT_PERIOD)
|
if (type == NET_PARAM_CONNECT_PERIOD)
|
||||||
{
|
{
|
||||||
|
std::cerr << "pqissludp::connect_parameter() PERIOD: " << value << std::endl;
|
||||||
mConnectPeriod = value;
|
mConnectPeriod = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -93,9 +93,8 @@ private:
|
|||||||
|
|
||||||
BIO *tou_bio; // specific to ssludp.
|
BIO *tou_bio; // specific to ssludp.
|
||||||
|
|
||||||
int remote_timeout;
|
//int remote_timeout;
|
||||||
int proxy_timeout;
|
//int proxy_timeout;
|
||||||
int udp_connect_timeout;
|
|
||||||
|
|
||||||
long listen_checktime;
|
long listen_checktime;
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
|
|||||||
break;
|
break;
|
||||||
case RS_NET_CONN_UDP_DHT_SYNC:
|
case RS_NET_CONN_UDP_DHT_SYNC:
|
||||||
autostr << "UDP (ETA: ";
|
autostr << "UDP (ETA: ";
|
||||||
autostr << 360 - (time(NULL) - pcs.currentConnAddr.ts);
|
autostr << 420 - (time(NULL) - pcs.currentConnAddr.ts);
|
||||||
autostr << ")";
|
autostr << ")";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -352,6 +352,21 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (pcs.state & RS_PEER_S_CONNECTED)
|
||||||
|
{
|
||||||
|
if (pcs.connecttype == RS_NET_CONN_TCP_ALL)
|
||||||
|
{
|
||||||
|
autostr << "TCP";
|
||||||
|
}
|
||||||
|
else if (pcs.connecttype == RS_NET_CONN_UDP_ALL)
|
||||||
|
{
|
||||||
|
autostr << "UDP";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
autostr << "Unknown Connect Method!";
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
autostr << "Idle";
|
autostr << "Idle";
|
||||||
|
@ -14,8 +14,7 @@ PQI_USE_XPGP = 1
|
|||||||
#USE_FILELOOK = 1
|
#USE_FILELOOK = 1
|
||||||
|
|
||||||
SSL_DIR=../../../../../src/openssl-0.9.7g-xpgp-0.1c
|
SSL_DIR=../../../../../src/openssl-0.9.7g-xpgp-0.1c
|
||||||
KADC_DIR=../../../../../src/KadC
|
UPNPC_DIR=../../../../../src/miniupnpc-1.0
|
||||||
UPNPC_DIR=../../../../../src/miniupnpc-20070515
|
|
||||||
|
|
||||||
include $(RS_TOP_DIR)/scripts/checks.mk
|
include $(RS_TOP_DIR)/scripts/checks.mk
|
||||||
|
|
||||||
@ -73,7 +72,6 @@ ifdef PQI_USE_XPGP
|
|||||||
LIBS += -L$(SSL_DIR)
|
LIBS += -L$(SSL_DIR)
|
||||||
endif
|
endif
|
||||||
LIBS += -lssl -lcrypto -lpthread
|
LIBS += -lssl -lcrypto -lpthread
|
||||||
#LIBS += -L$(KADC_DIR) -lKadC
|
|
||||||
LIBS += -L$(UPNPC_DIR) -lminiupnpc
|
LIBS += -L$(UPNPC_DIR) -lminiupnpc
|
||||||
LIBS += $(XLIB) -ldl -lz
|
LIBS += $(XLIB) -ldl -lz
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ PQI_USE_XPGP = 1
|
|||||||
#USE_FILELOOK = 1
|
#USE_FILELOOK = 1
|
||||||
|
|
||||||
SSL_DIR=../../../../../src/openssl-0.9.7g-xpgp-0.1c
|
SSL_DIR=../../../../../src/openssl-0.9.7g-xpgp-0.1c
|
||||||
UPNPC_DIR=../../../../../src/miniupnpc-20070515
|
UPNPC_DIR=../../../../../src/miniupnpc-1.0
|
||||||
|
|
||||||
include $(RS_TOP_DIR)/scripts/checks.mk
|
include $(RS_TOP_DIR)/scripts/checks.mk
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ bool SetRedirectAndTest(struct UPNPUrls * urls,
|
|||||||
char externalIPAddress[16];
|
char externalIPAddress[16];
|
||||||
char intClient[16];
|
char intClient[16];
|
||||||
char intPort[6];
|
char intPort[6];
|
||||||
char leaseDuration[] = "600"; /* 10 mins */
|
char leaseDuration[] = "3600"; /* 60 mins */
|
||||||
int r;
|
int r;
|
||||||
int ok = 1;
|
int ok = 1;
|
||||||
|
|
||||||
@ -141,11 +141,11 @@ bool SetRedirectAndTest(struct UPNPUrls * urls,
|
|||||||
printf("GetExternalIPAddress failed.\n");
|
printf("GetExternalIPAddress failed.\n");
|
||||||
|
|
||||||
// Unix at the moment!
|
// Unix at the moment!
|
||||||
// r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
|
|
||||||
// eport, iport, iaddr, 0, leaseDuration, proto);
|
|
||||||
|
|
||||||
r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
|
r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
|
||||||
eport, iport, iaddr, 0, proto);
|
eport, iport, iaddr, 0, leaseDuration, proto);
|
||||||
|
|
||||||
|
// r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
|
||||||
|
// eport, iport, iaddr, 0, proto);
|
||||||
if(r==0)
|
if(r==0)
|
||||||
{
|
{
|
||||||
printf("AddPortMapping(%s, %s, %s) failed\n", eport, iport, iaddr);
|
printf("AddPortMapping(%s, %s, %s) failed\n", eport, iport, iaddr);
|
||||||
|
Loading…
Reference in New Issue
Block a user