redirect to same address but different port (includes fix

Archived discussion about features (predating the use of Bugzilla as a bug and feature tracker)

Moderator: Moderators

Locked
Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 09:32
Contact:

redirect to same address but different port (includes fix

Post by Sedulus » 2003-01-29 07:57

yes, I should/could have posted this in the bug tracker... but the formatting/readability is hell there.

when you are redirected to a different hub on the same address, dc++ only checks if it is the same address and does not check the port.
then it realises (falsly) that it's already connected, then disconnects and says "Redirect recieved to a hub that's already connected." (and reconnects after two minutes)

fix below:

client/Client.h

Code: Select all

--- client/orig/Client.h        2002-12-28 02:31:50.000000000 +0100
+++ client/Client.h     2003-01-29 13:24:58.000000000 +0100
@@ -166,6 +166,7 @@
        }

        const string& getIp() { return ((socket == NULL) || socket->getIp().empty()) ? server : socket->getIp(); };
+       const short getPort() { return port; }

        GETSETREF(string, nick, Nick);
        GETSET(bool, userInfo, UserInfo);
client/ClientManager.h

Code: Select all

--- client/orig/ClientManager.h 2002-12-28 02:31:50.000000000 +0100
+++ client/ClientManager.h      2003-01-29 13:31:54.000000000 +0100
@@ -54,11 +54,11 @@
                return c;
        }

-       bool isConnected(const string& aServer) {
+       bool isConnected(const string& aServer, short port /* = 411 */ ) {
                Lock l(cs);

                for(Client::Iter i = clients.begin(); i != clients.end(); ++i) {
-                       if((*i)->getServer() == aServer || (*i)->getIp() == aServer) {
+                       if(((*i)->getServer() == aServer || (*i)->getIp() == aServer) && (*i)->getPort() == port) {
                                return true;
                        }
                }
windows/HubFrame.cpp

Code: Select all

--- windows/orig/HubFrame.cpp   2003-01-05 13:09:36.000000000 +0100
+++ windows/HubFrame.cpp        2003-01-29 13:28:42.000000000 +0100
@@ -938,7 +938,7 @@
                string s, f;
                short p = 411;
                Util::decodeUrl(redirect, s, p, f);
-               if(ClientManager::getInstance()->isConnected(s)) {
+               if(ClientManager::getInstance()->isConnected(s, p)) {
                        addClientLine(STRING(REDIRECT_ALREADY_CONNECTED));
                        return 0;
                }
@@ -1014,7 +1014,7 @@
                                string s, f;
                                short p = 411;
                                Util::decodeUrl(line, s, p, f);
-                               if(ClientManager::getInstance()->isConnected(s)) {
+                               if(ClientManager::getInstance()->isConnected(s, p)) {
                                        speak(ADD_STATUS_LINE, STRING(REDIRECT_ALREADY_CONNECTED));
                                        return;
                                }
/sed
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)

Locked