Skip to contentSkip to conversation

Make code and documentation for --remote-random-hostname consistent.

PATCH In review Gert Doering 4 participants 6 messages Nov 17, 2013 – Feb 12, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make code and documentation for --remote-random-hostname consistent.

Documentation examples, description and code were disagreeing on what this option actually does. Now they will all agree that it will *prepend* a random-byte string to the hostname name before resolving to work around DNS caching (needs a "*" wildcard record in the zone).

Fix trac #143

---
 doc/openvpn.8      |  2 +-
 src/openvpn/misc.c | 27 +++++++++------------------
 2 files changed, 10 insertions(+), 19 deletions(-)
doc/openvpn.8 +1 -1
index b53d383..3e2e1a4 100644
@@ -271,7 +271,7 @@ failover capability.
 .\"*********************************************************
 .TP
 .B \-\-remote-random-hostname
-Add a random string (6 characters) to first DNS label of hostname to prevent
+Prepend a random string (6 bytes, 12 hex characters) to hostname to prevent
 DNS caching.  For example, "foo.bar.gov" would be modified to
 "<random-chars>.foo.bar.gov".
 .\"*********************************************************
src/openvpn/misc.c +9 -18
index 4688444..7483184 100644
@@ -926,32 +926,23 @@ create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc
 }
 
 /*
- * Add a random string to first DNS label of hostname to prevent DNS caching.
+ * Prepend a random string to hostname to prevent DNS caching.
  * For example, foo.bar.gov would be modified to <random-chars>.foo.bar.gov.
- * Of course, this requires explicit support in the DNS server.
+ * Of course, this requires explicit support in the DNS server (wildcard).
  */
 const char *
 hostname_randomize(const char *hostname, struct gc_arena *gc)
 {
 # define n_rnd_bytes 6
 
-  char *hst = string_alloc(hostname, gc);
-  char *dot = strchr(hst, '.');
+  uint8_t rnd_bytes[n_rnd_bytes];
+  const char *rnd_str;
+  struct buffer hname = alloc_buf_gc (strlen(hostname)+sizeof(rnd_bytes)*2+4, gc);
 
-  if (dot)
-    {
-      uint8_t rnd_bytes[n_rnd_bytes];
-      const char *rnd_str;
-      struct buffer hname = alloc_buf_gc (strlen(hostname)+sizeof(rnd_bytes)*2+4, gc);
-
-      *dot++ = '\0';
-      prng_bytes (rnd_bytes, sizeof (rnd_bytes));
-      rnd_str = format_hex_ex (rnd_bytes, sizeof (rnd_bytes), 40, 0, NULL, gc);
-      buf_printf(&hname, "%s-0x%s.%s", hst, rnd_str, dot);
-      return BSTR(&hname);
-    }
-  else
-    return hostname;
+  prng_bytes (rnd_bytes, sizeof (rnd_bytes));
+  rnd_str = format_hex_ex (rnd_bytes, sizeof (rnd_bytes), 40, 0, NULL, gc);
+  buf_printf(&hname, "%s.%s", rnd_str, hostname);
+  return BSTR(&hname);
 # undef n_rnd_bytes
 }
 
Signature · 1 line
1.8.1.5
#1 lore raw

Hi,

this is actually not only asking for an ACK, but also for users that rely on the *old* behaviour ("foo.bar.gov" -> "foo-0x12345.bar.gov") and would be surprised.

gert

Quoted 75 lines · Gert Doering

Documentation examples, description and code were disagreeing on what this option actually does. Now they will all agree that it will *prepend* a random-byte string to the hostname name before resolving to work around DNS caching (needs a "*" wildcard record in the zone).

Fix trac #143

---
 doc/openvpn.8      |  2 +-
 src/openvpn/misc.c | 27 +++++++++------------------
 2 files changed, 10 insertions(+), 19 deletions(-)
doc/openvpn.8 +1 -1
index b53d383..3e2e1a4 100644
@@ -271,7 +271,7 @@ failover capability.
 .\"*********************************************************
 .TP
 .B \-\-remote-random-hostname
-Add a random string (6 characters) to first DNS label of hostname to prevent
+Prepend a random string (6 bytes, 12 hex characters) to hostname to prevent
 DNS caching.  For example, "foo.bar.gov" would be modified to
 "<random-chars>.foo.bar.gov".
 .\"*********************************************************
src/openvpn/misc.c +9 -18
index 4688444..7483184 100644
@@ -926,32 +926,23 @@ create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc
 }
 
 /*
- * Add a random string to first DNS label of hostname to prevent DNS caching.
+ * Prepend a random string to hostname to prevent DNS caching.
  * For example, foo.bar.gov would be modified to <random-chars>.foo.bar.gov.
- * Of course, this requires explicit support in the DNS server.
+ * Of course, this requires explicit support in the DNS server (wildcard).
  */
 const char *
 hostname_randomize(const char *hostname, struct gc_arena *gc)
 {
 # define n_rnd_bytes 6
 
-  char *hst = string_alloc(hostname, gc);
-  char *dot = strchr(hst, '.');
+  uint8_t rnd_bytes[n_rnd_bytes];
+  const char *rnd_str;
+  struct buffer hname = alloc_buf_gc (strlen(hostname)+sizeof(rnd_bytes)*2+4, gc);
 
-  if (dot)
-    {
-      uint8_t rnd_bytes[n_rnd_bytes];
-      const char *rnd_str;
-      struct buffer hname = alloc_buf_gc (strlen(hostname)+sizeof(rnd_bytes)*2+4, gc);
-
-      *dot++ = '\0';
-      prng_bytes (rnd_bytes, sizeof (rnd_bytes));
-      rnd_str = format_hex_ex (rnd_bytes, sizeof (rnd_bytes), 40, 0, NULL, gc);
-      buf_printf(&hname, "%s-0x%s.%s", hst, rnd_str, dot);
-      return BSTR(&hname);
-    }
-  else
-    return hostname;
+  prng_bytes (rnd_bytes, sizeof (rnd_bytes));
+  rnd_str = format_hex_ex (rnd_bytes, sizeof (rnd_bytes), 40, 0, NULL, gc);
+  buf_printf(&hname, "%s.%s", rnd_str, hostname);
+  return BSTR(&hname);
 # undef n_rnd_bytes
 }
 
Signature · 1 line
1.8.1.5
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#2 lore raw
In reply to Gert Doering

Am 17.11.13 15:30, schrieb Gert Doering:

Quoted 8 lines

Documentation examples, description and code were disagreeing on what this option actually does. Now they will all agree that it will *prepend* a random-byte string to the hostname name before resolving to work around DNS caching (needs a "*" wildcard record in the zone).

Fix trac #143

ACK

#3 lore raw
In reply to Gert Doering

Patch has been applied to the master and release/2.3 branches.

commit 7de8f3f322c1a1c13022a0243267624930dac5c9 (master) commit 945cfa53cde35340da830f35fb0ae18f15b92862 (release/2.3)

Author: Gert Doering
Date:   Sun Nov 17 15:30:20 2013 +0100
     Make code and documentation for --remote-random-hostname consistent.

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/7999

--
kind regards,

Gert Doering

#4 lore raw

[Openvpn-devel] openvpn 2.3 and windows nsi

In reply to Gert Doering

Hi,

in the sources of openvpn_2.2.2.zip there were under /win the nsi scripts, in the sources of openvpn 2.3.2 it's missing. Do I have to crosscompile it under linux to get this folder?

We like to make some changes to the nsi installer scripts, to roll out own configfiles etc.

Thanks for help, Eike

Am 17.11.2013 15:30, schrieb Gert Doering:

Quoted 72 lines

Documentation examples, description and code were disagreeing on what this option actually does. Now they will all agree that it will *prepend* a random-byte string to the hostname name before resolving to work around DNS caching (needs a "*" wildcard record in the zone).

Fix trac #143

---
  doc/openvpn.8      |  2 +-
  src/openvpn/misc.c | 27 +++++++++------------------
  2 files changed, 10 insertions(+), 19 deletions(-)
doc/openvpn.8 +1 -1
index b53d383..3e2e1a4 100644
@@ -271,7 +271,7 @@ failover capability.
  .\"*********************************************************
  .TP
  .B \-\-remote-random-hostname
-Add a random string (6 characters) to first DNS label of hostname to prevent
+Prepend a random string (6 bytes, 12 hex characters) to hostname to prevent
  DNS caching.  For example, "foo.bar.gov" would be modified to
  "<random-chars>.foo.bar.gov".
  .\"*********************************************************
src/openvpn/misc.c +9 -18
index 4688444..7483184 100644
@@ -926,32 +926,23 @@ create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc
  }
 
  /*
- * Add a random string to first DNS label of hostname to prevent DNS caching.
+ * Prepend a random string to hostname to prevent DNS caching.
   * For example, foo.bar.gov would be modified to <random-chars>.foo.bar.gov.
- * Of course, this requires explicit support in the DNS server.
+ * Of course, this requires explicit support in the DNS server (wildcard).
   */
  const char *
  hostname_randomize(const char *hostname, struct gc_arena *gc)
  {
  # define n_rnd_bytes 6
 
-  char *hst = string_alloc(hostname, gc);
-  char *dot = strchr(hst, '.');
+  uint8_t rnd_bytes[n_rnd_bytes];
+  const char *rnd_str;
+  struct buffer hname = alloc_buf_gc (strlen(hostname)+sizeof(rnd_bytes)*2+4, gc);
 
-  if (dot)
-    {
-      uint8_t rnd_bytes[n_rnd_bytes];
-      const char *rnd_str;
-      struct buffer hname = alloc_buf_gc (strlen(hostname)+sizeof(rnd_bytes)*2+4, gc);
-
-      *dot++ = '\0';
-      prng_bytes (rnd_bytes, sizeof (rnd_bytes));
-      rnd_str = format_hex_ex (rnd_bytes, sizeof (rnd_bytes), 40, 0, NULL, gc);
-      buf_printf(&hname, "%s-0x%s.%s", hst, rnd_str, dot);
-      return BSTR(&hname);
-    }
-  else
-    return hostname;
+  prng_bytes (rnd_bytes, sizeof (rnd_bytes));
+  rnd_str = format_hex_ex (rnd_bytes, sizeof (rnd_bytes), 40, 0, NULL, gc);
+  buf_printf(&hname, "%s.%s", rnd_str, hostname);
+  return BSTR(&hname);
  # undef n_rnd_bytes
  }
 
#5 lore raw

Re: [Openvpn-devel] openvpn 2.3 and windows nsi

Hi,

The OpenVPN Windows buildsystem has changed greatly since 2.2.2. Look here for current build documentation:

<https://community.openvpn.net/openvpn/wiki/BuildingUsingGenericBuildsystem>

The wiki page above links to instructions and scripts for bootstrapping a new cross-compile box.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
Quoted 96 lines

Hi,

in the sources of openvpn_2.2.2.zip there were under /win the nsi scripts, in the sources of openvpn 2.3.2 it's missing.
Do I have to crosscompile it under linux to get this folder?

We like to make some changes to the nsi installer scripts, to roll out own configfiles etc.

Thanks for help, Eike

Am 17.11.2013 15:30, schrieb Gert Doering:

Quoted 62 lines

Documentation examples, description and code were disagreeing on what this option actually does. Now they will all agree that it will *prepend* a random-byte string to the hostname name before resolving to work around DNS caching (needs a "*" wildcard record in the zone).

Fix trac #143

---
  doc/openvpn.8      |  2 +-
  src/openvpn/misc.c | 27 +++++++++------------------
  2 files changed, 10 insertions(+), 19 deletions(-)
doc/openvpn.8 +1 -1
index b53d383..3e2e1a4 100644
@@ -271,7 +271,7 @@ failover capability.
  .\"*********************************************************
  .TP
  .B \-\-remote-random-hostname
-Add a random string (6 characters) to first DNS label of hostname to prevent
+Prepend a random string (6 bytes, 12 hex characters) to hostname to prevent
  DNS caching.  For example, "foo.bar.gov" would be modified to
  "<random-chars>.foo.bar.gov".
  .\"*********************************************************
src/openvpn/misc.c +5 -15
index 4688444..7483184 100644
@@ -926,32 +926,23 @@ create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc
  }
 
  /*
- * Add a random string to first DNS label of hostname to prevent DNS caching.
+ * Prepend a random string to hostname to prevent DNS caching.
   * For example, foo.bar.gov would be modified to <random-chars>.foo.bar.gov.
- * Of course, this requires explicit support in the DNS server.
+ * Of course, this requires explicit support in the DNS server (wildcard).
   */
  const char *
  hostname_randomize(const char *hostname, struct gc_arena *gc)
  {
  # define n_rnd_bytes 6
 
-  char *hst = string_alloc(hostname, gc);
-  char *dot = strchr(hst, '.');
+  uint8_t rnd_bytes[n_rnd_bytes];
+  const char *rnd_str;
+  struct buffer hname = alloc_buf_gc (strlen(hostname)+sizeof(rnd_bytes)*2+4, gc);
 
-  if (dot)
-    {
-      uint8_t rnd_bytes[n_rnd_bytes];
-      const char *rnd_str;
-      struct buffer hname = alloc_buf_gc (strlen(hostname)+sizeof(rnd_bytes)*2+4, gc);
-
-      *dot++ = '\0';
-      prng_bytes (rnd_bytes, sizeof (rnd_bytes));
-      rnd_str = format_hex_ex (rnd_bytes, sizeof (rnd_bytes), 40, 0, NULL, gc);
-      buf_printf(&hname, "%s-0x%s.%s", hst, rnd_str, dot);
-      return BSTR(&hname);

src/openvpn/misc.c create_temp_file (const char *directory, const char *prefix, struct gc_arena *gc · line 948

Quoted 10 lines
src/openvpn/misc.c +4 -3
-    }
-  else
-    return hostname;
+  prng_bytes (rnd_bytes, sizeof (rnd_bytes));
+  rnd_str = format_hex_ex (rnd_bytes, sizeof (rnd_bytes), 40, 0, NULL, gc);
+  buf_printf(&hname, "%s.%s", rnd_str, hostname);
+  return BSTR(&hname);
  # undef n_rnd_bytes
  }
 

------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel