mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-05 23:55:35 -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
|
@ -63,7 +63,19 @@ static int tou_tick_all();
|
|||
int tou_init(const struct sockaddr *my_addr, socklen_t addrlen)
|
||||
{
|
||||
if (tou_inited)
|
||||
{
|
||||
struct sockaddr_in *addr = (struct sockaddr_in *) my_addr;
|
||||
udps->resetAddress(*addr);
|
||||
if (!(udps->okay()))
|
||||
{
|
||||
std::cerr << "tou_init() FATAL ERROR: Cannot reset Udp Socket to: "
|
||||
<< inet_ntoa(addr->sin_addr) << ":" << ntohs(addr->sin_port);
|
||||
std::cerr << std::endl;
|
||||
|
||||
exit(1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
tou_streams.resize(kInitStreamTable);
|
||||
|
||||
|
@ -101,6 +113,36 @@ int tou_stunkeepalive(int required)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int tou_getstunpeer(int i, struct sockaddr *remote_addr, socklen_t *raddrlen,
|
||||
struct sockaddr *ext_addr, socklen_t *eaddrlen,
|
||||
uint32_t *failCount, time_t *lastSend)
|
||||
{
|
||||
if (!tou_inited)
|
||||
return -1;
|
||||
|
||||
std::string id;
|
||||
|
||||
bool ret = udps->getStunPeer(i, id,
|
||||
*((struct sockaddr_in *) remote_addr),
|
||||
*((struct sockaddr_in *) ext_addr),
|
||||
*failCount, *lastSend);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int tou_needstunpeers()
|
||||
{
|
||||
if (!tou_inited)
|
||||
return -1;
|
||||
|
||||
if (udps->needStunPeers())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int tou_tick_stunkeepalive()
|
||||
{
|
||||
if (!tou_inited)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue