summaryrefslogtreecommitdiffstats
path: root/src/openvpn/misc.c
diff options
context:
space:
mode:
authorGert Doering <gert@greenie.muc.de>2013-11-17 15:30:20 +0100
committerGert Doering <gert@greenie.muc.de>2014-01-09 11:30:56 +0100
commit945cfa53cde35340da830f35fb0ae18f15b92862 (patch)
treecf19139d83c14984d4afcdc3cc335f23afedf7f4 /src/openvpn/misc.c
parente93fb8ceebe9ca7748d8874893221a40330564e4 (diff)
downloadopenvpn-945cfa53cde35340da830f35fb0ae18f15b92862.tar.gz
openvpn-945cfa53cde35340da830f35fb0ae18f15b92862.tar.xz
openvpn-945cfa53cde35340da830f35fb0ae18f15b92862.zip
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 Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: Arne Schwabe <arne@rfc2549.org> Message-Id: <1384698620-27946-1-git-send-email-gert@greenie.muc.de> URL: http://article.gmane.org/gmane.network.openvpn.devel/7999 (cherry picked from commit 7de8f3f322c1a1c13022a0243267624930dac5c9)
Diffstat (limited to 'src/openvpn/misc.c')
-rw-r--r--src/openvpn/misc.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c
index fa327f8..56a01a6 100644
--- a/src/openvpn/misc.c
+++ b/src/openvpn/misc.c
@@ -934,32 +934,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
}