summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-06-28 22:56:27 +0200
committerJulian Andres Klode <jak@debian.org>2017-06-29 11:48:04 +0200
commit9a9bbe00ffe021fe82ea35fbe65af91b039396fe (patch)
tree552e19f7fe4bbda9ff52af15392d85009a634eae
parent2422996f80f09e03f2f8fc7f1f00586666f02605 (diff)
use port from SRV record instead of initial port
An SRV record includes a portnumber to use with the host given, but apt was ignoring the portnumber and instead used either the port given by the user for the initial host or the default port for the service. In practice the service usually runs on another host on the default port, so it tends to work as intended and even if not and apt can't get a connection there it will gracefully fallback to contacting the initial host with the right port, so its a user invisible bug most of the time. (cherry picked from commit 9bdc09016f9570389451dd619d7e878bfeaa91df)
-rw-r--r--methods/connect.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/methods/connect.cc b/methods/connect.cc
index f6fb14769..5bb34a958 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -312,12 +312,15 @@ bool Connect(std::string Host,int Port,const char *Service,
size_t stackSize = 0;
// try to connect in the priority order of the srv records
std::string initialHost{std::move(Host)};
+ auto const initialPort = Port;
while(SrvRecords.empty() == false)
{
_error->PushToStack();
++stackSize;
// PopFromSrvRecs will also remove the server
- Host = PopFromSrvRecs(SrvRecords).target;
+ auto Srv = PopFromSrvRecs(SrvRecords);
+ Host = Srv.target;
+ Port = Srv.port;
auto const ret = ConnectToHostname(Host, Port, Service, DefPort, Fd, TimeOut, Owner);
if (ret)
{
@@ -327,6 +330,7 @@ bool Connect(std::string Host,int Port,const char *Service,
}
}
Host = std::move(initialHost);
+ Port = initialPort;
// we have no (good) SrvRecords for this host, connect right away
_error->PushToStack();