Browse code

ignore remote-random-hostname if a numeric host is provided

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>

Antonio Quartulli authored on 2017/01/31 00:26:58
Showing 1 changed files
... ...
@@ -338,20 +338,6 @@ openvpn_getaddrinfo(unsigned int flags,
338 338
     ASSERT(hostname || servname);
339 339
     ASSERT(!(flags & GETADDR_HOST_ORDER));
340 340
 
341
-    if (hostname && (flags & GETADDR_RANDOMIZE))
342
-    {
343
-        hostname = hostname_randomize(hostname, &gc);
344
-    }
345
-
346
-    if (hostname)
347
-    {
348
-        print_hostname = hostname;
349
-    }
350
-    else
351
-    {
352
-        print_hostname = "undefined";
353
-    }
354
-
355 341
     if (servname)
356 342
     {
357 343
         print_servname = servname;
... ...
@@ -402,6 +388,20 @@ openvpn_getaddrinfo(unsigned int flags,
402 402
         const char *fmt;
403 403
         int level = 0;
404 404
 
405
+        if (hostname && (flags & GETADDR_RANDOMIZE))
406
+        {
407
+            hostname = hostname_randomize(hostname, &gc);
408
+        }
409
+
410
+        if (hostname)
411
+        {
412
+            print_hostname = hostname;
413
+        }
414
+        else
415
+        {
416
+            print_hostname = "undefined";
417
+        }
418
+
405 419
         fmt = "RESOLVE: Cannot resolve host address: %s:%s (%s)";
406 420
         if ((flags & GETADDR_MENTION_RESOLVE_RETRY)
407 421
             && !resolve_retry_seconds)
... ...
@@ -512,6 +512,10 @@ openvpn_getaddrinfo(unsigned int flags,
512 512
     else
513 513
     {
514 514
         /* IP address parse succeeded */
515
+        if (flags & GETADDR_RANDOMIZE)
516
+        {
517
+            msg(M_WARN, "WARNING: ignoring --remote-random-hostname because the hostname is an IP address");
518
+        }
515 519
     }
516 520
 
517 521
 done: