]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
ignore remote-random-hostname if a numeric host is provided
authorAntonio Quartulli <a@unstable.cc>
Mon, 30 Jan 2017 15:26:58 +0000 (23:26 +0800)
committerGert Doering <gert@greenie.muc.de>
Sun, 19 Mar 2017 18:20:47 +0000 (19:20 +0100)
Although it does not make sense to specify remote-random-hostname
when a numeric hostname is provided (being it the remote, the http
proxy or the socks server), this is still a valid configuration.

For this reason, this combination should still work as expected,
which means ignoring the randomization and directly using the
numeric IP.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20170130152658.15786-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13993.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/socket.c

index c1c0eaa0e03419583b57ddec3450abc50b0d24c1..7d3dd60cb4588b02d199c5e3a47d9de11b00bf2b 100644 (file)
@@ -338,20 +338,6 @@ openvpn_getaddrinfo(unsigned int flags,
     ASSERT(hostname || servname);
     ASSERT(!(flags & GETADDR_HOST_ORDER));
 
-    if (hostname && (flags & GETADDR_RANDOMIZE))
-    {
-        hostname = hostname_randomize(hostname, &gc);
-    }
-
-    if (hostname)
-    {
-        print_hostname = hostname;
-    }
-    else
-    {
-        print_hostname = "undefined";
-    }
-
     if (servname)
     {
         print_servname = servname;
@@ -402,6 +388,20 @@ openvpn_getaddrinfo(unsigned int flags,
         const char *fmt;
         int level = 0;
 
+        if (hostname && (flags & GETADDR_RANDOMIZE))
+        {
+            hostname = hostname_randomize(hostname, &gc);
+        }
+
+        if (hostname)
+        {
+            print_hostname = hostname;
+        }
+        else
+        {
+            print_hostname = "undefined";
+        }
+
         fmt = "RESOLVE: Cannot resolve host address: %s:%s (%s)";
         if ((flags & GETADDR_MENTION_RESOLVE_RETRY)
             && !resolve_retry_seconds)
@@ -512,6 +512,10 @@ openvpn_getaddrinfo(unsigned int flags,
     else
     {
         /* IP address parse succeeded */
+        if (flags & GETADDR_RANDOMIZE)
+        {
+            msg(M_WARN, "WARNING: ignoring --remote-random-hostname because the hostname is an IP address");
+        }
     }
 
 done: