summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-09-26 19:27:30 +0200
committerJulian Andres Klode <jak@debian.org>2017-10-26 13:17:38 +0200
commitfb73af35d69d998a75eefc946a8452e56c4ff99c (patch)
treea0a3eeab6846f90acef1dbfb44e88e45bc02b2b4 /methods
parente9dca65c2ecd81678899e4e1fd47872488620fc1 (diff)
proper error reporting for v3 onion services
APT connects just fine to any .onion address given, only if the connect fails somehow it will perform checks on the sanity of which in this case is checking the length as they are well defined and as the strings are arbitrary a user typing them easily mistypes which apt should can be slightly more helpful in figuring out by saying the onion hasn't the required length. (cherry picked from commit f3e34838d95132e5f318e85525326decbfb19e36)
Diffstat (limited to 'methods')
-rw-r--r--methods/connect.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/methods/connect.cc b/methods/connect.cc
index 949cd3f99..6a7b71c0b 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -523,13 +523,13 @@ bool UnwrapSocks(std::string Host, int Port, URI Proxy, std::unique_ptr<MethodFd
else if (errcode == 0x01)
{
auto const prevdot = Host.rfind('.', lastdot - 1);
- if (lastdot == 16 && prevdot == std::string::npos)
+ if (prevdot == std::string::npos && (lastdot == 16 || lastdot == 56))
; // valid .onion address
- else if (prevdot != std::string::npos && (lastdot - prevdot) == 17)
+ else if (prevdot != std::string::npos && ((lastdot - prevdot) == 17 || (lastdot - prevdot) == 57))
; // valid .onion address with subdomain(s)
else
{
- errstr = "Invalid hostname: onion service name must be 16 characters long";
+ errstr = "Invalid hostname: onion service name must be either 16 or 56 characters long";
Owner->SetFailReason("SOCKS");
}
}