Added udpstunner back into libretroshare. Fixed a couple of bugs to make it compile.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-peernet@4254 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2011-06-13 12:43:40 +00:00
parent e2a18750c1
commit 006a5f3011
2 changed files with 8 additions and 4 deletions

View File

@ -74,12 +74,14 @@ HEADERS += tcponudp/udppeer.h \
tcponudp/tcppacket.h \
tcponudp/tcpstream.h \
tcponudp/tou.h \
tcponudp/udpstunner.h \
SOURCES += tcponudp/udppeer.cc \
tcponudp/tcppacket.cc \
tcponudp/tcpstream.cc \
tcponudp/tou.cc \
tcponudp/bss_tou.c \
tcponudp/udpstunner.cc \
# These two aren't actually used (and don't compile) ....
# but could be useful later

View File

@ -27,13 +27,16 @@
#include <iostream>
#include <sstream>
#include "util/rsprint.h"
static const int STUN_TTL = 64;
#define TOU_STUN_MIN_PEERS 5
/*
* #define DEBUG_UDP_STUN 1
* #define DEBUG_UDP_STUNNER 1
*/
//#define DEBUG_UDP_STUNNER 1
const int32_t TOU_STUN_MAX_FAIL_COUNT = 3; /* 3 tries (could be higher?) */
const int32_t TOU_STUN_MAX_SEND_RATE = 5; /* every 5 seconds */
@ -144,7 +147,7 @@ bool UdpStunner::locked_handleStunPkt(void *data, int size, struct sockaddr_in &
#ifdef DEBUG_UDP_STUNNER
std::cerr << "UdpStunner::handleStunPkt() got Ext Addr: ";
std::cerr << inet_ntoa(eAddr.sin_addr) << ":" << ntohs(eAddr.sin_port);
out << " from: " << from;
std::cerr << " from: " << from;
std::cerr << std::endl;
#endif
locked_recvdStun(from, eAddr);
@ -233,8 +236,7 @@ int UdpStunner::doStun(struct sockaddr_in stun_addr)
#ifdef DEBUG_UDP_STUNNER
std::ostringstream out;
out << "UdpStunner::doStun() Sent Stun Packet(" << sentlen << ") from:";
out << inet_ntoa(laddr.sin_addr) << ":" << ntohs(laddr.sin_port);
out << "UdpStunner::doStun() Sent Stun Packet(" << sentlen << ") ";
out << " to:";
out << inet_ntoa(stun_addr.sin_addr) << ":" << ntohs(stun_addr.sin_port);