diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-16 14:49:10 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2004-04-16 14:49:10 +0000 |
commit | 8f9a385d0c512daa0dee38cb37c4d45c9f195e23 (patch) | |
tree | 6661bb2d74a17ecddbca16b745c53b86130946ae | |
parent | 4b62dbed78d9dca711b2eaffb239232fbe8d0709 (diff) |
Mesh cookie linking fixes (was giving remote port to servers and not local port)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@618 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/connection.h | 3 | ||||
-rw-r--r-- | src/connection.cpp | 12 | ||||
-rw-r--r-- | src/inspircd.cpp | 11 |
3 files changed, 19 insertions, 7 deletions
diff --git a/include/connection.h b/include/connection.h index 3316bd6c0..1550d4704 100644 --- a/include/connection.h +++ b/include/connection.h @@ -77,6 +77,7 @@ class ircd_connector : public classbase std::string GetDescription(); void SetDescription(std::string desc); int GetServerPort(); + void SetServerPort(int p); bool SetHostAndPort(char* host, int port); void CloseConnection(); }; @@ -121,7 +122,7 @@ class connection : public classbase connection(); bool CreateListener(char* host, int p); - bool BeginLink(char* targethost, int port, char* password, char* servername); + bool BeginLink(char* targethost, int port, char* password, char* servername, int myport); bool MeshCookie(char* targethost, int port, long cookie, char* servername); void TerminateLink(char* targethost); bool SendPacket(char *message, const char* host); diff --git a/src/connection.cpp b/src/connection.cpp index 9344b1621..20695e873 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -42,6 +42,8 @@ bool connection::CreateListener(char* host, int p) int on = 0; struct linger linger = { 0 }; + this->port = p; + fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd <= 0) { @@ -120,6 +122,12 @@ bool ircd_connector::SetHostAddress(char* host, int port) return true; } +void ircd_connector::SetServerPort(int p) +{ + this->port = p; +} + + bool ircd_connector::MakeOutboundConnection(char* host, int port) { hostent* hoste = gethostbyname(host); @@ -161,7 +169,7 @@ bool ircd_connector::MakeOutboundConnection(char* host, int port) } -bool connection::BeginLink(char* targethost, int port, char* password, char* servername) +bool connection::BeginLink(char* targethost, int port, char* password, char* servername, int myport) { char connect[MAXBUF]; @@ -174,7 +182,7 @@ bool connection::BeginLink(char* targethost, int port, char* password, char* ser // targethost has been turned into an ip... // we dont want this as the server name. connector.SetServerName(servername); - sprintf(connect,"S %s %s :%s",getservername().c_str(),password,getserverdesc().c_str()); + sprintf(connect,"S %s %s %d :%s",getservername().c_str(),password,myport,getserverdesc().c_str()); connector.SetState(STATE_NOAUTH_OUTBOUND); connector.SetHostAndPort(targethost, port); this->connectors.push_back(connector); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 1f64154ce..353d6084c 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -5361,7 +5361,7 @@ void handle_connect(char **parameters, int pcnt, userrec *user) if (me[defaultRoute]) { - me[defaultRoute]->BeginLink(Link_IPAddr,LinkPort,Link_Pass,Link_ServerName); + me[defaultRoute]->BeginLink(Link_IPAddr,LinkPort,Link_Pass,Link_ServerName,me[defaultRoute]->port); return; } else @@ -6817,17 +6817,19 @@ void handle_link_packet(char* udp_msg, char* udp_host, serverrec *serv) } else if (token == 'S') { - // S test.chatspike.net password :ChatSpike InspIRCd test server + // S test.chatspike.net password portn :ChatSpike InspIRCd test server char* servername = strtok(params," "); char* password = strtok(NULL," "); + char* myport = strtok(NULL," "); char* serverdesc = finalparam+2; - WriteOpers("CONNECT from %s (%s)",servername,udp_host); + WriteOpers("CONNECT from %s (%s) (their port: %d)",servername,udp_host,atoi(myport)); for (int j = 0; j < serv->connectors.size(); j++) { if (!strcasecmp(serv->connectors[j].GetServerName().c_str(),udp_host)) { serv->connectors[j].SetServerName(servername); + serv->connectors[j].SetServerPort(atoi(myport)); } } @@ -7205,7 +7207,8 @@ int InspIRCd(void) strncpy(resolved,remotehost,MAXBUF); } // add to this connections ircd_connector vector - me[x]->AddIncoming(incomingSockfd,resolved,ntohs(client.sin_port)); + // *FIX* - we need the LOCAL port not the remote port in &client! + me[x]->AddIncoming(incomingSockfd,resolved,me[x]->port); } } } |