linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #00700
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2121: another NAT-T no-op commit. define ENABLE_NAT_TRAVERSAL to try it, presumably (untested).
------------------------------------------------------------
revno: 2121
committer: cologic <ne5@xxxxxxxxxxx>
branch nick: dcplusplus
timestamp: Sun 2010-04-04 02:51:11 -0400
message:
another NAT-T no-op commit. define ENABLE_NAT_TRAVERSAL to try it, presumably (untested).
modified:
dcpp/AdcCommand.h
dcpp/AdcHub.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/AdcCommand.h'
--- dcpp/AdcCommand.h 2010-02-12 18:33:24 +0000
+++ dcpp/AdcCommand.h 2010-04-04 06:51:11 +0000
@@ -201,6 +201,10 @@
C(SND);
C(SID);
C(CMD);
+#ifdef ENABLE_NAT_TRAVERSAL
+ C(NAT);
+ C(RNT);
+#endif
default:
dcdebug("Unknown ADC command: %.50s\n", aLine.c_str());
break;
=== modified file 'dcpp/AdcHub.cpp'
--- dcpp/AdcHub.cpp 2010-02-25 18:56:41 +0000
+++ dcpp/AdcHub.cpp 2010-04-04 06:51:11 +0000
@@ -355,8 +355,10 @@
if(c.getParameters().size() < 2) {
return;
}
+#ifndef ENABLE_NAT_TRAVERSAL
if(!ClientManager::getInstance()->isActive())
return;
+#endif
OnlineUser* u = findUser(c.getFrom());
if(!u || u->getUser() == ClientManager::getInstance()->getMe())
return;
@@ -373,7 +375,24 @@
unknownProtocol(c.getFrom(), protocol, token);
return;
}
+#ifdef ENABLE_NAT_TRAVERSAL
+ if(ClientManager::getInstance()->isActive()) {
+ connect(*u, token, secure);
+ return;
+ }
+
+ if (!u->getIdentity().supports(NAT0_FEATURE))
+ return;
+
+ // Attempt to traverse NATs and/or firewalls with TCP.
+ // If they respond with their own, symmetric, RNT command, both
+ // clients call ConnectionManager::adcConnect.
+ send(AdcCommand(AdcCommand::CMD_NAT, u->getIdentity().getSID(), AdcCommand::TYPE_DIRECT).
+ addParam(protocol).addParam(Util::toString(sock->getLocalPort())).addParam(tok));
+ return;
+#else
connect(*u, token, secure);
+#endif
}
void AdcHub::handle(AdcCommand::CMD, AdcCommand& c) throw() {
@@ -805,6 +824,21 @@
su += ADCS_FEATURE + ",";
}
+#ifdef ENABLE_NAT_TRAVERSAL
+ // FIXME this was presumably the source of the A/P bug in StrongDC++, examine
+ if(BOOLSETTING(NO_IP_OVERRIDE) && !SETTING(EXTERNAL_IP).empty()) {
+ addParam(lastInfoMap, c, "I4", Socket::resolve(SETTING(EXTERNAL_IP)));
+ } else {
+ addParam(lastInfoMap, c, "I4", "0.0.0.0");
+ }
+ addParam(lastInfoMap, c, "U4", Util::toString(SearchManager::getInstance()->getPort()));
+ if(ClientManager::getInstance()->isActive()) {
+ su += TCP4_FEATURE + ",";
+ su += UDP4_FEATURE + ",";
+ } else {
+ su += NAT0_FEATURE + ",";
+ }
+#else
if(ClientManager::getInstance()->isActive()) {
if(BOOLSETTING(NO_IP_OVERRIDE) && !SETTING(EXTERNAL_IP).empty()) {
addParam(lastInfoMap, c, "I4", Socket::resolve(SETTING(EXTERNAL_IP)));
@@ -818,6 +852,7 @@
addParam(lastInfoMap, c, "I4", "");
addParam(lastInfoMap, c, "U4", "");
}
+#endif
if(!su.empty()) {
su.erase(su.size() - 1);