mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-13 03:22:34 -04:00
Reworking of networking code to enable Net Restart.
* Stun code now runs continually - to check external network state. * Udpsorter controls DHT stun is on/off. (via p3ConnectMgr) * added code to enable threads to join/restart * enabled NetRestart for UDP and TCP. * tweaked networking code for faster startup (now ~30 seconds - can still be improved). * tweaked debug messages for testing networking * Added test for checking external IP address determination. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1492 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d5581629ef
commit
2bf94b909a
22 changed files with 774 additions and 81 deletions
|
@ -49,10 +49,20 @@ class TouStunPeer
|
|||
{
|
||||
public:
|
||||
TouStunPeer()
|
||||
:response(false), lastsend(0), failCount(0) { return; }
|
||||
:response(false), lastsend(0), failCount(0)
|
||||
{
|
||||
eaddr.sin_addr.s_addr = 0;
|
||||
eaddr.sin_port = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
TouStunPeer(std::string id_in, const struct sockaddr_in &addr)
|
||||
:id(id_in), remote(addr), response(false), lastsend(0), failCount(0) { return; }
|
||||
:id(id_in), remote(addr), response(false), lastsend(0), failCount(0)
|
||||
{
|
||||
eaddr.sin_addr.s_addr = 0;
|
||||
eaddr.sin_port = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string id;
|
||||
struct sockaddr_in remote, eaddr;
|
||||
|
@ -69,13 +79,20 @@ class UdpSorter: public UdpReceiver
|
|||
UdpSorter(struct sockaddr_in &local);
|
||||
virtual ~UdpSorter() { return; }
|
||||
|
||||
bool resetAddress(struct sockaddr_in &local);
|
||||
|
||||
/* add a TCPonUDP stream */
|
||||
int addUdpPeer(UdpPeer *peer, const struct sockaddr_in &raddr);
|
||||
int removeUdpPeer(UdpPeer *peer);
|
||||
|
||||
bool setStunKeepAlive(uint32_t required);
|
||||
bool addStunPeer(const struct sockaddr_in &remote, const char *peerid);
|
||||
bool getStunPeer(int idx, std::string &id,
|
||||
struct sockaddr_in &remote, struct sockaddr_in &eaddr,
|
||||
uint32_t &failCount, time_t &lastSend);
|
||||
|
||||
bool checkStunKeepAlive();
|
||||
bool needStunPeers();
|
||||
|
||||
bool externalAddr(struct sockaddr_in &remote, uint8_t &stable);
|
||||
|
||||
|
@ -109,7 +126,7 @@ bool locked_printStunList();
|
|||
bool locked_recvdStun(const struct sockaddr_in &remote, const struct sockaddr_in &extaddr);
|
||||
bool locked_checkExternalAddress();
|
||||
|
||||
bool storeStunPeer(const struct sockaddr_in &remote, const char *peerid);
|
||||
bool storeStunPeer(const struct sockaddr_in &remote, const char *peerid, bool sent);
|
||||
|
||||
UdpLayer *udpLayer;
|
||||
|
||||
|
@ -120,6 +137,7 @@ bool storeStunPeer(const struct sockaddr_in &remote, const char *peerid);
|
|||
struct sockaddr_in eaddr; /* external addr */
|
||||
bool eaddrKnown;
|
||||
bool eaddrStable; /* if true then usable. if false -> Symmettric NAT */
|
||||
time_t eaddrTime;
|
||||
|
||||
bool mStunKeepAlive;
|
||||
time_t mStunLastRecv;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue