[OpenVPN home] [Date Prev] [Date Index] [Date Next]
[OpenVPN mailing lists] [Thread Prev] [Thread Index] [Thread Next]
Google
 
Web openvpn.net

Re: [Openvpn-users] resolv-retry for unlimited time?



I wonder how can I use resolv-retry with an unlimited number of retries?
Is this possible at all?

The following two patches allow resolv-retry to work forever if you call openvpn with "resolv-retry=-1". Maybe the patch could be added to the next openvpn release?


babel@eisler:~/openvpn-1.5.0$ diff -u options.c.org options.c
--- options.c.org Tue Jan 6 09:10:25 2004
+++ options.c Fri Jan 2 21:13:43 2004
@@ -84,7 +84,8 @@
" file containing username/password on 2 lines.\n"
"--http-proxy-retry : Retry indefinitely on HTTP proxy errors.\n"
"--resolv-retry n: If hostname resolve fails for --remote, retry\n"
- " resolve for n seconds before failing (disabled by default).\n"
+ " resolve for n seconds before failing. If you set this"
+ " to -1 there is no timeout. (disabled by default).\n"
"--float : Allow remote to change its IP address/port, such as through\n"
" DHCP (this is the default if --remote is not used).\n"
"--ipchange cmd : Execute shell command cmd on remote ip address initial\n"
@@ -1082,7 +1083,7 @@
else if (streq (p[0], "resolv-retry") && p[1])
{
++i;
- options->resolve_retry_seconds = positive (atoi (p[1]));
+ options->resolve_retry_seconds = (atoi (p[1]));
}
else if (streq (p[0], "ipchange") && p[1])
{


babel@eisler:~/openvpn-1.5.0$ diff -u socket.c.org socket.c
--- socket.c.org        Tue Jan  6 09:10:15 2004
+++ socket.c    Fri Jan  2 21:16:08 2004
@@ -89,10 +89,22 @@
  if (!status)
    {
      const int fail_wait_interval = 5; /* seconds */
-      int resolve_retries = resolve_retry_seconds / fail_wait_interval;
+      int resolve_retries;
+      int forever;
      struct hostent *h;
      const char *fmt;

+      if(resolve_retry_seconds >= 0)
+       {
+         resolve_retries = resolve_retry_seconds / fail_wait_interval;
+         forever = 0;
+       }
+      else
+       {
+         resolve_retries = 1;
+         forever = 1;
+       }
+
      CLEAR (ia);

      fmt = "RESOLVE: Cannot resolve host address: %s: %s";
@@ -129,16 +141,19 @@

         /* resolve lookup failed, should we
            continue or fail? */
-         msg (((resolve_retries > 0
+         msg (((forever || resolve_retries > 0
                || !(flags & GETADDR_FATAL))
               ? D_RESOLVE_ERRORS : M_FATAL),
              fmt,
              hostname,
              h_errno_msg (h_errno));

-         if (--resolve_retries <= 0
-             && !(flags & GETADDR_FATAL))
-           goto done;
+         if(!forever)
+           {
+             if (--resolve_retries <= 0
+                 && !(flags & GETADDR_FATAL))
+               goto done;
+           }

         sleep (fail_wait_interval);
       }

---
Claas Hilbrecht
http://www.jucs-kramkiste.de


____________________________________________ Openvpn-users mailing list Openvpn-users@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/openvpn-users