← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2591: More ipv6 stuff

 

------------------------------------------------------------
revno: 2591
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Thu 2011-08-11 15:02:19 +0200
message:
  More ipv6 stuff
modified:
  changelog.txt
  dcpp/AdcHub.cpp
  dcpp/AdcHub.h
  dcpp/BufferedSocket.cpp
  dcpp/BufferedSocket.h
  dcpp/Client.cpp
  dcpp/Client.h
  dcpp/ClientManager.cpp
  dcpp/ClientManager.h
  dcpp/ConnectionManager.cpp
  dcpp/ConnectionManager.h
  dcpp/FavoriteManager.cpp
  dcpp/HttpConnection.cpp
  dcpp/HttpConnection.h
  dcpp/NmdcHub.cpp
  dcpp/OnlineUser.h
  dcpp/SettingsManager.cpp
  dcpp/SettingsManager.h
  dcpp/Socket.cpp
  dcpp/Socket.h
  dcpp/User.cpp
  dcpp/UserConnection.cpp
  dcpp/UserConnection.h
  dcpp/Util.cpp
  dcpp/Util.h
  win32/WinUtil.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 'changelog.txt'
--- changelog.txt	2011-08-09 11:15:32 +0000
+++ changelog.txt	2011-08-11 13:02:19 +0000
@@ -38,6 +38,8 @@
 * Store the password (if available) using "Add to favorites" (thanks iceman50)
 * Fix queries in http downloads (thanks bigmuscle)
 * Update MiniUPnPc to version 1.6
+* [L#309402] Initial IPv6 support
+* Update boost to version 1.47
 
 -- 0.782 2011-03-05 --
 * Prevent a remote crash triggered via malformed user commands (poy)

=== modified file 'dcpp/AdcHub.cpp'
--- dcpp/AdcHub.cpp	2011-08-04 09:57:32 +0000
+++ dcpp/AdcHub.cpp	2011-08-11 13:02:19 +0000
@@ -47,7 +47,9 @@
 const string AdcHub::SECURE_CLIENT_PROTOCOL_TEST("ADCS/0.10");
 const string AdcHub::ADCS_FEATURE("ADC0");
 const string AdcHub::TCP4_FEATURE("TCP4");
+const string AdcHub::TCP6_FEATURE("TCP6");
 const string AdcHub::UDP4_FEATURE("UDP4");
+const string AdcHub::UDP6_FEATURE("UDP6");
 const string AdcHub::NAT0_FEATURE("NAT0");
 const string AdcHub::SEGA_FEATURE("SEGA");
 const string AdcHub::BASE_SUPPORT("ADBASE");
@@ -356,7 +358,7 @@
 		return;
 	}
 
-	ConnectionManager::getInstance()->adcConnect(*u, static_cast<uint16_t>(Util::toInt(port)), token, secure);
+	ConnectionManager::getInstance()->adcConnect(*u, port, token, secure);
 }
 
 void AdcHub::handle(AdcCommand::RCM, AdcCommand& c) noexcept {
@@ -426,7 +428,7 @@
 void AdcHub::sendUDP(const AdcCommand& cmd) noexcept {
 	string command;
 	string ip;
-	uint16_t port;
+	string port;
 	{
 		Lock l(cs);
 		SIDMap::const_iterator i = users.find(cmd.getTo());
@@ -439,7 +441,7 @@
 			return;
 		}
 		ip = ou.getIdentity().getIp();
-		port = static_cast<uint16_t>(Util::toInt(ou.getIdentity().getUdpPort()));
+		port = ou.getIdentity().getUdpPort();
 		command = cmd.toString(ou.getUser()->getCID());
 	}
 	try {
@@ -601,12 +603,13 @@
 	}
 
 	// Trigger connection attempt sequence locally ...
+	auto localPort = Util::toString(sock->getLocalPort());
 	dcdebug("triggering connecting attempt in NAT: remote port = %s, local IP = %s, local port = %d\n", port.c_str(), sock->getLocalIp().c_str(), sock->getLocalPort());
-	ConnectionManager::getInstance()->adcConnect(*u, static_cast<uint16_t>(Util::toInt(port)), sock->getLocalPort(), BufferedSocket::NAT_CLIENT, token, secure);
+	ConnectionManager::getInstance()->adcConnect(*u, port, localPort, BufferedSocket::NAT_CLIENT, token, secure);
 
 	// ... and signal other client to do likewise.
 	send(AdcCommand(AdcCommand::CMD_RNT, u->getIdentity().getSID(), AdcCommand::TYPE_DIRECT).addParam(protocol).
-		addParam(Util::toString(sock->getLocalPort())).addParam(token));
+		addParam(localPort).addParam(token));
 }
 
 void AdcHub::handle(AdcCommand::RNT, AdcCommand& c) noexcept {
@@ -632,7 +635,7 @@
 
 	// Trigger connection attempt sequence locally
 	dcdebug("triggering connecting attempt in RNT: remote port = %s, local IP = %s, local port = %d\n", port.c_str(), sock->getLocalIp().c_str(), sock->getLocalPort());
-	ConnectionManager::getInstance()->adcConnect(*u, static_cast<uint16_t>(Util::toInt(port)), sock->getLocalPort(), BufferedSocket::NAT_SERVER, token, secure);
+	ConnectionManager::getInstance()->adcConnect(*u, port, Util::toString(sock->getLocalPort()), BufferedSocket::NAT_SERVER, token, secure);
 }
 
 void AdcHub::connect(const OnlineUser& user, const string& token) {
@@ -993,7 +996,6 @@
 		addParam(lastInfoMap, c, "KP", "SHA256/" + Encoder::toBase32(&kp[0], kp.size()));
 	}
 
-#ifndef DISABLE_NAT_TRAVERSAL
 	if(BOOLSETTING(NO_IP_OVERRIDE) && !SETTING(EXTERNAL_IP).empty()) {
 		addParam(lastInfoMap, c, "I4", Socket::resolve(SETTING(EXTERNAL_IP), AF_INET));
 	} else {
@@ -1007,21 +1009,6 @@
 		addParam(lastInfoMap, c, "U4", "");
 		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)));
-		} else {
-			addParam(lastInfoMap, c, "I4", "0.0.0.0");
-		}
-		addParam(lastInfoMap, c, "U4", Util::toString(SearchManager::getInstance()->getPort()));
-		su += "," + TCP4_FEATURE;
-		su += "," + UDP4_FEATURE;
-	} else {
-		addParam(lastInfoMap, c, "I4", "");
-		addParam(lastInfoMap, c, "U4", "");
-	}
-#endif
 
 	addParam(lastInfoMap, c, "SU", su);
 

=== modified file 'dcpp/AdcHub.h'
--- dcpp/AdcHub.h	2011-03-29 20:40:28 +0000
+++ dcpp/AdcHub.h	2011-08-11 13:02:19 +0000
@@ -59,7 +59,9 @@
 	static const string SECURE_CLIENT_PROTOCOL_TEST;
 	static const string ADCS_FEATURE;
 	static const string TCP4_FEATURE;
+	static const string TCP6_FEATURE;
 	static const string UDP4_FEATURE;
+	static const string UDP6_FEATURE;
 	static const string NAT0_FEATURE;
 	static const string SEGA_FEATURE;
 	static const string BASE_SUPPORT;

=== modified file 'dcpp/BufferedSocket.cpp'
--- dcpp/BufferedSocket.cpp	2011-08-04 09:57:32 +0000
+++ dcpp/BufferedSocket.cpp	2011-08-11 13:02:19 +0000
@@ -100,15 +100,16 @@
 	addTask(ACCEPTED, 0);
 }
 
-void BufferedSocket::connect(const string& aAddress, uint16_t aPort, bool secure, bool allowUntrusted, bool proxy) {
-	connect(aAddress, aPort, 0, NAT_NONE, secure, allowUntrusted, proxy);
+void BufferedSocket::connect(const string& aAddress, const string& aPort, bool secure, bool allowUntrusted, bool proxy) {
+	connect(aAddress, aPort, Util::emptyString, NAT_NONE, secure, allowUntrusted, proxy);
 }
 
-void BufferedSocket::connect(const string& aAddress, uint16_t aPort, uint16_t localPort, NatRoles natRole, bool secure, bool allowUntrusted, bool proxy) {
+void BufferedSocket::connect(const string& aAddress, const string& aPort, const string& localPort, NatRoles natRole, bool secure, bool allowUntrusted, bool proxy) {
 	dcdebug("BufferedSocket::connect() %p\n", (void*)this);
 	std::unique_ptr<Socket> s(secure ? (natRole == NAT_SERVER ? CryptoManager::getInstance()->getServerSocket(allowUntrusted) : CryptoManager::getInstance()->getClientSocket(allowUntrusted)) : new Socket);
 
 	s->setLocalIp4(SETTING(BIND_ADDRESS));
+	s->setLocalIp6(SETTING(BIND_ADDRESS6));
 
 	setSocket(move(s));
 
@@ -118,17 +119,16 @@
 
 #define LONG_TIMEOUT 30000
 #define SHORT_TIMEOUT 1000
-void BufferedSocket::threadConnect(const string& aAddr, uint16_t aPort, uint16_t localPort, NatRoles natRole, bool proxy) {
+void BufferedSocket::threadConnect(const string& aAddr, const string& aPort, const string& localPort, NatRoles natRole, bool proxy) {
 	dcassert(state == STARTING);
 
-	dcdebug("threadConnect %s:%d/%d\n", aAddr.c_str(), (int)localPort, (int)aPort);
 	fire(BufferedSocketListener::Connecting());
 
 	const uint64_t endTime = GET_TICK() + LONG_TIMEOUT;
 	state = RUNNING;
 
 	while (GET_TICK() < endTime) {
-		dcdebug("threadConnect attempt to addr \"%s\"\n", aAddr.c_str());
+		dcdebug("threadConnect attempt %s %s:%s\n", localPort.c_str(), aAddr.c_str(), aPort.c_str());
 		try {
 			if(proxy) {
 				sock->socksConnect(aAddr, aPort, LONG_TIMEOUT);

=== modified file 'dcpp/BufferedSocket.h'
--- dcpp/BufferedSocket.h	2011-08-04 09:57:32 +0000
+++ dcpp/BufferedSocket.h	2011-08-11 13:02:19 +0000
@@ -74,8 +74,8 @@
 	}
 
 	void accept(const Socket& srv, bool secure, bool allowUntrusted);
-	void connect(const string& aAddress, uint16_t aPort, bool secure, bool allowUntrusted, bool proxy);
-	void connect(const string& aAddress, uint16_t aPort, uint16_t localPort, NatRoles natRole, bool secure, bool allowUntrusted, bool proxy);
+	void connect(const string& aAddress, const string& aPort, bool secure, bool allowUntrusted, bool proxy);
+	void connect(const string& aAddress, const string& aPort, const string& localPort, NatRoles natRole, bool secure, bool allowUntrusted, bool proxy);
 
 	/** Sets data mode for aBytes bytes. Must be called within onLine. */
 	void setDataMode(int64_t aBytes = -1) { mode = MODE_DATA; dataBytes = aBytes; }
@@ -129,10 +129,10 @@
 		virtual ~TaskData() { }
 	};
 	struct ConnectInfo : public TaskData {
-		ConnectInfo(string addr_, uint16_t port_, uint16_t localPort_, NatRoles natRole_, bool proxy_) : addr(addr_), port(port_), localPort(localPort_), natRole(natRole_), proxy(proxy_) { }
+		ConnectInfo(string addr_, string port_, string localPort_, NatRoles natRole_, bool proxy_) : addr(addr_), port(port_), localPort(localPort_), natRole(natRole_), proxy(proxy_) { }
 		string addr;
-		uint16_t port;
-		uint16_t localPort;
+		string port;
+		string localPort;
 		NatRoles natRole;
 		bool proxy;
 	};
@@ -165,7 +165,7 @@
 
 	virtual int run();
 
-	void threadConnect(const string& aAddr, uint16_t aPort, uint16_t localPort, NatRoles natRole, bool proxy);
+	void threadConnect(const string& aAddr, const string& aPort, const string& localPort, NatRoles natRole, bool proxy);
 	void threadAccept();
 	void threadRead();
 	void threadSendFile(InputStream* is);

=== modified file 'dcpp/Client.cpp'
--- dcpp/Client.cpp	2011-08-04 09:57:32 +0000
+++ dcpp/Client.cpp	2011-08-11 13:02:19 +0000
@@ -33,7 +33,7 @@
 	myIdentity(ClientManager::getInstance()->getMe(), 0),
 	reconnDelay(120), lastActivity(GET_TICK()), registered(false), autoReconnect(false),
 	encoding(Text::systemCharset), state(STATE_DISCONNECTED), sock(0),
-	hubUrl(hubURL), port(0), separator(separator_),
+	hubUrl(hubURL),separator(separator_),
 	secure(secure_), countType(COUNT_UNCOUNTED)
 {
 	string file, proto, query, fragment;

=== modified file 'dcpp/Client.h'
--- dcpp/Client.h	2011-04-13 19:16:51 +0000
+++ dcpp/Client.h	2011-08-11 13:02:19 +0000
@@ -65,11 +65,11 @@
 
 	bool isOp() const { return getMyIdentity().isOp(); }
 
-	uint16_t getPort() const { return port; }
+	const string& getPort() const { return port; }
 	const string& getAddress() const { return address; }
 
 	const string& getIp() const { return ip; }
-	string getIpPort() const { return getIp() + ':' + Util::toString(port); }
+	string getIpPort() const { return getIp() + ':' + port; }
 	string getLocalIp() const;
 
 	void updated(const OnlineUser& aUser) { fire(ClientListener::UserUpdated(), this, aUser); }
@@ -164,8 +164,7 @@
 	string ip;
 	string localIp;
 	string keyprint;
-
-	uint16_t port;
+	string port;
 	char separator;
 	bool secure;
 	CountType countType;

=== modified file 'dcpp/ClientManager.cpp'
--- dcpp/ClientManager.cpp	2011-08-04 09:57:32 +0000
+++ dcpp/ClientManager.cpp	2011-08-11 13:02:19 +0000
@@ -209,13 +209,13 @@
 	Lock l(cs);
 
 	string ip;
-	uint16_t port = 411;
-	string::size_type i = ipPort.find(':');
+	string port = "411";
+	string::size_type i = ipPort.rfind(':');
 	if(i == string::npos) {
 		ip = ipPort;
 	} else {
 		ip = ipPort.substr(0, i);
-		port = static_cast<uint16_t>(Util::toInt(ipPort.substr(i+1)));
+		port = ipPort.substr(i+1);
 	}
 
 	string url;
@@ -444,7 +444,7 @@
 			u.getClient().send(cmd);
 		} else {
 			try {
-				udp.writeTo(u.getIdentity().getIp(), static_cast<uint16_t>(Util::toInt(u.getIdentity().getUdpPort())), cmd.toString(getMe()->getCID()));
+				udp.writeTo(u.getIdentity().getIp(), u.getIdentity().getUdpPort(), cmd.toString(getMe()->getCID()));
 			} catch(const SocketException&) {
 				dcdebug("Socket exception sending ADC UDP command\n");
 			}
@@ -494,15 +494,14 @@
 
 		} else {
 			try {
-				string ip, file, proto, query, fragment;
-				uint16_t port = 0;
+				string ip, port, file, proto, query, fragment;
 
 				Util::decodeUrl(aSeeker, proto, ip, port, file, query, fragment);
 				ip = Socket::resolve(ip, AF_INET);
 				if(static_cast<NmdcHub*>(aClient)->isProtectedIP(ip))
 					return;
-				if(port == 0)
-					port = 412;
+				if(port.empty())
+					port = "412";
 				for(SearchResultList::const_iterator i = l.begin(); i != l.end(); ++i) {
 					const SearchResultPtr& sr = *i;
 					udp.writeTo(ip, port, sr->toSR(*aClient));
@@ -582,6 +581,10 @@
 	return me;
 }
 
+bool ClientManager::isActive() const {
+	return SETTING(INCOMING_CONNECTIONS) != SettingsManager::INCOMING_FIREWALL_PASSIVE;
+}
+
 const CID& ClientManager::getMyPID() {
 	if(pid.isZero())
 		pid = CID(SETTING(PRIVATE_ID));

=== modified file 'dcpp/ClientManager.h'
--- dcpp/ClientManager.h	2011-04-13 19:16:51 +0000
+++ dcpp/ClientManager.h	2011-08-11 13:02:19 +0000
@@ -25,7 +25,6 @@
 #include "TimerManager.h"
 
 #include "Singleton.h"
-#include "SettingsManager.h"
 #include "OnlineUser.h"
 #include "Socket.h"
 #include "CID.h"
@@ -116,9 +115,7 @@
 	void connect(const HintedUser& user, const string& token);
 	void privateMessage(const HintedUser& user, const string& msg, bool thirdPerson);
 	void userCommand(const HintedUser& user, const UserCommand& uc, StringMap& params, bool compatibility);
-
-	bool isActive() { return SETTING(INCOMING_CONNECTIONS) != SettingsManager::INCOMING_FIREWALL_PASSIVE; }
-
+	bool isActive() const;
 	Lock lock() { return Lock(cs); }
 
 	const ClientList& getClients() const { return clients; }

=== modified file 'dcpp/ConnectionManager.cpp'
--- dcpp/ConnectionManager.cpp	2011-08-04 09:57:32 +0000
+++ dcpp/ConnectionManager.cpp	2011-08-11 13:02:19 +0000
@@ -297,7 +297,7 @@
 	}
 }
 
-void ConnectionManager::nmdcConnect(const string& aServer, uint16_t aPort, const string& aNick, const string& hubUrl, const string& encoding) {
+void ConnectionManager::nmdcConnect(const string& aServer, const string& aPort, const string& aNick, const string& hubUrl, const string& encoding) {
 	if(shuttingDown)
 		return;
 
@@ -308,18 +308,18 @@
 	uc->setState(UserConnection::STATE_CONNECT);
 	uc->setFlag(UserConnection::FLAG_NMDC);
 	try {
-		uc->connect(aServer, aPort, 0, BufferedSocket::NAT_NONE);
+		uc->connect(aServer, aPort, Util::emptyString, BufferedSocket::NAT_NONE);
 	} catch(const Exception&) {
 		putConnection(uc);
 		delete uc;
 	}
 }
 
-void ConnectionManager::adcConnect(const OnlineUser& aUser, uint16_t aPort, const string& aToken, bool secure) {
-	adcConnect(aUser, aPort, 0, BufferedSocket::NAT_NONE, aToken, secure);
+void ConnectionManager::adcConnect(const OnlineUser& aUser, const string& aPort, const string& aToken, bool secure) {
+	adcConnect(aUser, aPort, Util::emptyString, BufferedSocket::NAT_NONE, aToken, secure);
 }
 
-void ConnectionManager::adcConnect(const OnlineUser& aUser, uint16_t aPort, uint16_t localPort, BufferedSocket::NatRoles natRole, const string& aToken, bool secure) {
+void ConnectionManager::adcConnect(const OnlineUser& aUser, const string& aPort, const string& localPort, BufferedSocket::NatRoles natRole, const string& aToken, bool secure) {
 	if(shuttingDown)
 		return;
 

=== modified file 'dcpp/ConnectionManager.h'
--- dcpp/ConnectionManager.h	2011-08-04 09:57:32 +0000
+++ dcpp/ConnectionManager.h	2011-08-11 13:02:19 +0000
@@ -101,9 +101,9 @@
 		expectedConnections.add(aNick, aMyNick, aHubUrl);
 	}
 
-	void nmdcConnect(const string& aServer, uint16_t aPort, const string& aMyNick, const string& hubUrl, const string& encoding);
-	void adcConnect(const OnlineUser& aUser, uint16_t aPort, const string& aToken, bool secure);
-	void adcConnect(const OnlineUser& aUser, uint16_t aPort, uint16_t localPort, BufferedSocket::NatRoles natRole, const string& aToken, bool secure);
+	void nmdcConnect(const string& aServer, const string& aPort, const string& aMyNick, const string& hubUrl, const string& encoding);
+	void adcConnect(const OnlineUser& aUser, const string& aPort, const string& aToken, bool secure);
+	void adcConnect(const OnlineUser& aUser, const string& aPort, const string& localPort, BufferedSocket::NatRoles natRole, const string& aToken, bool secure);
 
 	void getDownloadConnection(const HintedUser& aUser);
 	void force(const UserPtr& aUser);

=== modified file 'dcpp/FavoriteManager.cpp'
--- dcpp/FavoriteManager.cpp	2011-04-13 19:16:51 +0000
+++ dcpp/FavoriteManager.cpp	2011-08-11 13:02:19 +0000
@@ -664,9 +664,7 @@
 		return Util::emptyString;
 
 	// get the host
-	string server;
-	uint16_t port = 0;
-	string file, query, proto, fragment;
+	string server, port, file, query, proto, fragment;
 	Util::decodeUrl(publicListServer, proto, server, port, file, query, fragment);
 	// only keep the last 2 words (example.com)
 	size_t pos = server.rfind('.');

=== modified file 'dcpp/HttpConnection.cpp'
--- dcpp/HttpConnection.cpp	2011-08-03 21:03:49 +0000
+++ dcpp/HttpConnection.cpp	2011-08-11 13:02:19 +0000
@@ -76,8 +76,8 @@
 
 	}
 
-	if(port == 0)
-		port = 80;
+	if(port.empty())
+		port = "80";
 
 	if(!socket) {
 		socket = BufferedSocket::getSocket(0x0a);
@@ -98,8 +98,7 @@
 	string sRemoteServer = server;
 	if(!SETTING(HTTP_PROXY).empty())
 	{
-		string tfile, proto, query, fragment;
-		uint16_t tport;
+		string tfile, tport, proto, query, fragment;
 		Util::decodeUrl(file, proto, sRemoteServer, tport, tfile, query, fragment);
 	}
 	socket->write("Host: " + sRemoteServer + "\r\n");
@@ -146,8 +145,8 @@
 				string proto, query, fragment;
 				Util::decodeUrl(currentUrl, proto, server, port, file, query, fragment);
 				string tmp = "http://"; + server;
-				if(port != 80)
-					tmp += ':' + Util::toString(port);
+				if(port != "80")
+					tmp += ':' + port;
 				location302 = tmp + location302;
 			} else {
 				string::size_type i = currentUrl.rfind('/');

=== modified file 'dcpp/HttpConnection.h'
--- dcpp/HttpConnection.h	2011-03-29 20:40:28 +0000
+++ dcpp/HttpConnection.h	2011-08-11 13:02:19 +0000
@@ -51,7 +51,7 @@
 {
 public:
 	void downloadFile(const string& aUrl);
-	HttpConnection() : ok(false), port(80), size(-1), moved302(false), coralizeState(CST_DEFAULT), socket(NULL) { }
+	HttpConnection() : ok(false), port("80"), size(-1), moved302(false), coralizeState(CST_DEFAULT), socket(NULL) { }
 	virtual ~HttpConnection() {
 		if(socket) {
 			socket->removeListener(this);
@@ -68,7 +68,7 @@
 	string file;
 	string server;
 	bool ok;
-	uint16_t port;
+	string port;
 	int64_t size;
 	bool moved302;
 

=== modified file 'dcpp/NmdcHub.cpp'
--- dcpp/NmdcHub.cpp	2011-08-04 09:57:32 +0000
+++ dcpp/NmdcHub.cpp	2011-08-11 13:02:19 +0000
@@ -435,7 +435,7 @@
 		}
 		string port = param.substr(j+1);
 		// For simplicity, we make the assumption that users on a hub have the same character encoding
-		ConnectionManager::getInstance()->nmdcConnect(server, (uint16_t)Util::toInt(port), getMyNick(), getHubUrl(), getEncoding());
+		ConnectionManager::getInstance()->nmdcConnect(server, port, getMyNick(), getHubUrl(), getEncoding());
 	} else if(cmd == "$RevConnectToMe") {
 		if(state != STATE_NORMAL) {
 			return;
@@ -610,7 +610,7 @@
 				if(!u)
 					continue;
 
-				u->getIdentity().setIp(it->substr(j+1));
+				u->getIdentity().setIp4(it->substr(j+1));
 				if(u->getUser() == getMyIdentity().getUser()) {
 					setMyIdentity(u->getIdentity());
 				}

=== modified file 'dcpp/OnlineUser.h'
--- dcpp/OnlineUser.h	2011-07-03 17:15:51 +0000
+++ dcpp/OnlineUser.h	2011-08-11 13:02:19 +0000
@@ -65,8 +65,10 @@
 #define GS(n, x) string get##n() const { return get(x); } void set##n(const string& v) { set(x, v); }
 	GS(Nick, "NI")
 	GS(Description, "DE")
-	GS(Ip, "I4")
-	GS(UdpPort, "U4")
+	GS(Ip4, "I4")
+	GS(Ip6, "I6")
+	GS(Udp4Port, "U4")
+	GS(Udp6Port, "U6")
 	GS(Email, "EM")
 	GS(Connection, "CO")
 
@@ -88,7 +90,14 @@
 	bool isBot() const { return isClientType(CT_BOT) || isSet("BO"); }
 	bool isAway() const { return isSet("AW"); }
 	bool isTcpActive() const;
+	bool isTcp4Active() const;
+	bool isTcp6Active() const;
 	bool isUdpActive() const;
+	bool isUdp4Active() const;
+	bool isUdp6Active() const;
+	string getIp() const;
+	string getUdpPort() const;
+
 	std::map<string, string> getInfo() const;
 	string get(const char* name) const;
 	void set(const char* name, const string& val);

=== modified file 'dcpp/SettingsManager.cpp'
--- dcpp/SettingsManager.cpp	2011-08-04 09:57:32 +0000
+++ dcpp/SettingsManager.cpp	2011-08-11 13:02:19 +0000
@@ -35,7 +35,7 @@
 const string SettingsManager::settingTags[] =
 {
 	// Strings
-	"Nick", "UploadSpeed", "Description", "DownloadDirectory", "EMail", "ExternalIp",
+	"Nick", "UploadSpeed", "Description", "DownloadDirectory", "EMail", "ExternalIp", "ExternalIp6",
 	"MainFont", "TextViewerFont",
 	"ConnectionsOrder", "ConnectionsWidths", "HubFrameOrder", "HubFrameWidths",
 	"SearchFrameOrder", "SearchFrameWidths", "FavHubsFrameOrder", "FavHubsFrameWidths",
@@ -44,7 +44,7 @@
 	"FinishedULFilesOrder", "FinishedULFilesWidths", "FinishedULUsersOrder", "FinishedULUsersWidths",
 	"UsersFrameOrder", "UsersFrameWidths", "HttpProxy", "LogDirectory", "LogFormatPostDownload",
 	"LogFormatPostFinishedDownload", "LogFormatPostUpload", "LogFormatMainChat", "LogFormatPrivateChat",
-	"TempDownloadDirectory", "BindAddress", "SocksServer", "SocksUser", "SocksPassword", "ConfigVersion",
+	"TempDownloadDirectory", "BindAddress", "BindAddress6", "SocksServer", "SocksUser", "SocksPassword", "ConfigVersion",
 	"DefaultAwayMessage", "TimeStampsFormat", "ADLSearchFrameOrder", "ADLSearchFrameWidths",
 	"CID", "SpyFrameWidths", "SpyFrameOrder", "LogFileMainChat", "LogFilePrivateChat",
 	"LogFileStatus", "LogFileUpload", "LogFileDownload", "LogFileFinishedDownload", "LogFileSystem",

=== modified file 'dcpp/SettingsManager.h'
--- dcpp/SettingsManager.h	2011-07-30 08:51:53 +0000
+++ dcpp/SettingsManager.h	2011-08-11 13:02:19 +0000
@@ -55,7 +55,7 @@
 	static StringList connectionSpeeds;
 
 	enum StrSetting { STR_FIRST,
-		NICK = STR_FIRST, UPLOAD_SPEED, DESCRIPTION, DOWNLOAD_DIRECTORY, EMAIL, EXTERNAL_IP,
+		NICK = STR_FIRST, UPLOAD_SPEED, DESCRIPTION, DOWNLOAD_DIRECTORY, EMAIL, EXTERNAL_IP, EXTERNAL_IP6,
 		MAIN_FONT, TEXT_VIEWER_FONT,
 		CONNECTIONS_ORDER, CONNECTIONS_WIDTHS, HUBFRAME_ORDER, HUBFRAME_WIDTHS,
 		SEARCHFRAME_ORDER, SEARCHFRAME_WIDTHS, FAVHUBSFRAME_ORDER, FAVHUBSFRAME_WIDTHS,
@@ -64,7 +64,7 @@
 		FINISHED_UL_FILES_ORDER, FINISHED_UL_FILES_WIDTHS, FINISHED_UL_USERS_ORDER, FINISHED_UL_USERS_WIDTHS,
 		USERSFRAME_ORDER, USERSFRAME_WIDTHS, HTTP_PROXY, LOG_DIRECTORY, LOG_FORMAT_POST_DOWNLOAD,
 		LOG_FORMAT_POST_FINISHED_DOWNLOAD, LOG_FORMAT_POST_UPLOAD, LOG_FORMAT_MAIN_CHAT, LOG_FORMAT_PRIVATE_CHAT,
-		TEMP_DOWNLOAD_DIRECTORY, BIND_ADDRESS, SOCKS_SERVER, SOCKS_USER, SOCKS_PASSWORD, CONFIG_VERSION,
+		TEMP_DOWNLOAD_DIRECTORY, BIND_ADDRESS, BIND_ADDRESS6, SOCKS_SERVER, SOCKS_USER, SOCKS_PASSWORD, CONFIG_VERSION,
 		DEFAULT_AWAY_MESSAGE, TIME_STAMPS_FORMAT, ADLSEARCHFRAME_ORDER, ADLSEARCHFRAME_WIDTHS,
 		PRIVATE_ID, SPYFRAME_WIDTHS, SPYFRAME_ORDER, LOG_FILE_MAIN_CHAT,
 		LOG_FILE_PRIVATE_CHAT, LOG_FILE_STATUS, LOG_FILE_UPLOAD, LOG_FILE_DOWNLOAD, LOG_FILE_FINISHED_DOWNLOAD,

=== modified file 'dcpp/Socket.cpp'
--- dcpp/Socket.cpp	2011-08-04 09:57:32 +0000
+++ dcpp/Socket.cpp	2011-08-11 13:02:19 +0000
@@ -305,14 +305,14 @@
 	}
 }
 
-void Socket::socksConnect(const string& aAddr, uint16_t aPort, uint32_t timeout) {
+void Socket::socksConnect(const string& aAddr, const string& aPort, uint32_t timeout) {
 	if(SETTING(SOCKS_SERVER).empty() || SETTING(SOCKS_PORT) == 0) {
 		throw SocketException(_("The socks server failed establish a connection"));
 	}
 
 	uint64_t start = GET_TICK();
 
-	connect(SETTING(SOCKS_SERVER), static_cast<uint16_t>(SETTING(SOCKS_PORT)));
+	connect(SETTING(SOCKS_SERVER), Util::toString(SETTING(SOCKS_PORT)));
 
 	if(wait(timeLeft(start, timeout), WAIT_CONNECT) != WAIT_CONNECT) {
 		throw SocketException(_("The socks server failed establish a connection"));
@@ -338,7 +338,7 @@
 		connStr.insert(connStr.end(), paddr, paddr+4);
 	}
 
-	uint16_t port = htons(aPort);
+	uint16_t port = htons(static_cast<uint16_t>(Util::toInt(aPort)));
 	uint8_t* pport = (uint8_t*)&port;
 	connStr.push_back(pport[0]);
 	connStr.push_back(pport[1]);
@@ -519,11 +519,11 @@
  * @param aLen Data length
  * @throw SocketExcpetion Send failed.
  */
-void Socket::writeTo(const string& aAddr, uint16_t aPort, const void* aBuffer, int aLen, bool proxy) {
+void Socket::writeTo(const string& aAddr, const string& aPort, const void* aBuffer, int aLen, bool proxy) {
 	if(aLen <= 0)
 		return;
 
-	if(aAddr.empty() || aPort == 0) {
+	if(aAddr.empty() || aPort.empty()) {
 		throw SocketException(EADDRNOTAVAIL);
 	}
 
@@ -548,7 +548,7 @@
 			connStr.push_back((uint8_t)aAddr.size());
 			connStr.insert(connStr.end(), aAddr.begin(), aAddr.end());
 		} else {
-			auto ai = resolveAddr(aAddr, Util::toString(aPort));
+			auto ai = resolveAddr(aAddr, aPort);
 
 			if(ai->ai_family == AF_INET) {
 				connStr.push_back(1);		// Address type: IPv4
@@ -565,7 +565,7 @@
 
 		sent = check([&] { return ::sendto(getSock(), (const char*)&connStr[0], (int)connStr.size(), 0, &udpAddr.sa, udpAddrLen); });
 	} else {
-		auto ai = resolveAddr(aAddr, Util::toString(aPort));
+		auto ai = resolveAddr(aAddr, aPort);
 		sent = check([&] { return ::sendto(getSock(), (const char*)aBuffer, (int)aLen, 0, ai->ai_addr, ai->ai_addrlen); });
 	}
 

=== modified file 'dcpp/Socket.h'
--- dcpp/Socket.h	2011-08-04 09:57:32 +0000
+++ dcpp/Socket.h	2011-08-11 13:02:19 +0000
@@ -112,7 +112,7 @@
 	/**
 	 * Same as connect(), but through the SOCKS5 server
 	 */
-	void socksConnect(const string& aIp, uint16_t aPort, uint32_t timeout = 0);
+	void socksConnect(const string& aIp, const string& aPort, uint32_t timeout = 0);
 
 	/**
 	 * Sends data, will block until all data has been sent or an exception occurs
@@ -123,8 +123,8 @@
 	void writeAll(const void* aBuffer, int aLen, uint32_t timeout = 0);
 	virtual int write(const void* aBuffer, int aLen);
 	int write(const string& aData) { return write(aData.data(), (int)aData.length()); }
-	virtual void writeTo(const string& aIp, uint16_t aPort, const void* aBuffer, int aLen, bool proxy = true);
-	void writeTo(const string& aIp, uint16_t aPort, const string& aData) { writeTo(aIp, aPort, aData.data(), (int)aData.length()); }
+	virtual void writeTo(const string& aIp, const string& aPort, const void* aBuffer, int aLen, bool proxy = true);
+	void writeTo(const string& aIp, const string& aPort, const string& aData) { writeTo(aIp, aPort, aData.data(), (int)aData.length()); }
 	virtual void shutdown() noexcept;
 	virtual void close() noexcept;
 	void disconnect() noexcept;

=== modified file 'dcpp/User.cpp'
--- dcpp/User.cpp	2011-07-03 17:15:51 +0000
+++ dcpp/User.cpp	2011-08-11 13:02:19 +0000
@@ -32,15 +32,51 @@
 }
 
 bool Identity::isTcpActive() const {
-	return (!user->isSet(User::NMDC)) ?
-		!getIp().empty() && supports(AdcHub::TCP4_FEATURE) :
-		!user->isSet(User::PASSIVE);
+	return isTcp4Active() || isTcp6Active();
+}
+
+bool Identity::isTcp4Active() const {
+	if(getIp4().empty())
+		return false;
+	return user->isSet(User::NMDC) ? !user->isSet(User::PASSIVE) : supports(AdcHub::TCP4_FEATURE);
+}
+
+bool Identity::isTcp6Active() const {
+	if(getIp6().empty())
+		return false;
+	return user->isSet(User::NMDC) ? false : supports(AdcHub::TCP6_FEATURE);
 }
 
 bool Identity::isUdpActive() const {
-	if(getIp().empty() || getUdpPort().empty())
-		return false;
-	return (!user->isSet(User::NMDC)) ? supports(AdcHub::UDP4_FEATURE) : !user->isSet(User::PASSIVE);
+	return isUdp4Active() || isUdp6Active();
+}
+
+bool Identity::isUdp4Active() const {
+	if(getIp4().empty() || getUdp4Port().empty())
+		return false;
+	return user->isSet(User::NMDC) ? !user->isSet(User::PASSIVE) : supports(AdcHub::UDP4_FEATURE);
+}
+
+bool Identity::isUdp6Active() const {
+	if(getIp6().empty() || getUdp6Port().empty())
+		return false;
+	return user->isSet(User::NMDC) ? false : supports(AdcHub::UDP6_FEATURE);
+}
+
+string Identity::getUdpPort() const {
+	if(getIp6().empty() || getUdp6Port().empty()) {
+		return getUdp4Port();
+	}
+
+	return getUdp6Port();
+}
+
+string Identity::getIp() const {
+	if(getIp6().empty() || getUdp6Port().empty()) {
+		return getIp4();
+	}
+
+	return getIp6();
 }
 
 void Identity::getParams(StringMap& sm, const string& prefix, bool compatibility) const {

=== modified file 'dcpp/UserConnection.cpp'
--- dcpp/UserConnection.cpp	2011-04-13 19:16:51 +0000
+++ dcpp/UserConnection.cpp	2011-08-11 13:02:19 +0000
@@ -25,6 +25,7 @@
 #include "AdcCommand.h"
 #include "Transfer.h"
 #include "format.h"
+#include "SettingsManager.h"
 
 namespace dcpp {
 
@@ -133,7 +134,7 @@
 	}
 }
 
-void UserConnection::connect(const string& aServer, uint16_t aPort, uint16_t localPort, BufferedSocket::NatRoles natRole) {
+void UserConnection::connect(const string& aServer, const string& aPort, const string& localPort, BufferedSocket::NatRoles natRole) {
 	dcassert(!socket);
 
 	socket = BufferedSocket::getSocket(0);

=== modified file 'dcpp/UserConnection.h'
--- dcpp/UserConnection.h	2011-04-13 19:16:51 +0000
+++ dcpp/UserConnection.h	2011-08-11 13:02:19 +0000
@@ -123,7 +123,7 @@
 	void setDataMode(int64_t aBytes = -1) { dcassert(socket); socket->setDataMode(aBytes); }
 	void setLineMode(size_t rollback) { dcassert(socket); socket->setLineMode(rollback); }
 
-	void connect(const string& aServer, uint16_t aPort, uint16_t localPort, const BufferedSocket::NatRoles natRole);
+	void connect(const string& aServer, const string& aPort, const string& localPort, const BufferedSocket::NatRoles natRole);
 	void accept(const Socket& aServer);
 
 	void updated() { if(socket) socket->updated(); }

=== modified file 'dcpp/Util.cpp'
--- dcpp/Util.cpp	2011-04-24 11:27:49 +0000
+++ dcpp/Util.cpp	2011-08-11 13:02:19 +0000
@@ -428,7 +428,7 @@
  * http:// -> port 80
  * dchub:// -> port 411
  */
-void Util::decodeUrl(const string& url, string& protocol, string& host, uint16_t& port, string& path, string& query, string& fragment) {
+void Util::decodeUrl(const string& url, string& protocol, string& host, string& port, string& path, string& query, string& fragment) {
 	auto fragmentEnd = url.size();
 	auto fragmentStart = url.rfind('#');
 
@@ -502,15 +502,15 @@
 
 		if(portStart == string::npos) {
 			if(protocol == "http") {
-				port = 80;
+				port = "80";
 			} else if(protocol == "https") {
-				port = 443;
+				port = "443";
 			} else if(protocol == "dchub"  || protocol.empty()) {
-				port = 411;
+				port = "411";
 			}
 		} else {
 			dcdebug("p");
-			port = static_cast<uint16_t>(Util::toInt(url.substr(portStart, authorityEnd - portStart)));
+			port = url.substr(portStart, authorityEnd - portStart);
 		}
 	}
 

=== modified file 'dcpp/Util.h'
--- dcpp/Util.h	2011-04-15 20:53:17 +0000
+++ dcpp/Util.h	2011-08-11 13:02:19 +0000
@@ -213,7 +213,7 @@
 		replace(string_t(search), string_t(replacement), str);
 	}
 
-	static void decodeUrl(const string& aUrl, string& protocol, string& host, uint16_t& port, string& path, string& query, string& fragment);
+	static void decodeUrl(const string& aUrl, string& protocol, string& host, string& port, string& path, string& query, string& fragment);
 	static map<string, string> decodeQuery(const string& query);
 
 	static string validateFileName(string aFile);

=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp	2011-06-28 20:07:49 +0000
+++ win32/WinUtil.cpp	2011-08-11 13:02:19 +0000
@@ -1174,8 +1174,7 @@
 
 bool WinUtil::parseDBLClick(const tstring& str) {
 	auto url = Text::fromT(str);
-	string proto, host, file, query, fragment;
-	uint16_t port;
+	string proto, host, port, file, query, fragment;
 	Util::decodeUrl(url, proto, host, port, file, query, fragment);
 
 	if(Util::stricmp(proto.c_str(), "adc") == 0 ||