summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorrl1987 <rl1987@sdf.lonestar.org>2018-02-11 15:22:41 +0100
committerNick Mathewson <nickm@torproject.org>2018-03-28 07:39:03 -0400
commit0e453929d21b030832b0c48fceac0c5688657e15 (patch)
treeb6f89ea48b25a0b4c3e3a057f38122e32815e8f3 /src/common
parentddee28a3c9b9dd256cd6560a4766f17a6c6fc13d (diff)
downloadtor-0e453929d21b030832b0c48fceac0c5688657e15.tar.gz
tor-0e453929d21b030832b0c48fceac0c5688657e15.zip
Allow IPv6 address strings to be used as hostnames in SOCKS5 requests
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c11
-rw-r--r--src/common/util.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 90204befc0..1818b4f19e 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1071,6 +1071,17 @@ string_is_valid_ipv6_address(const char *string)
return (tor_inet_pton(AF_INET6,string,&addr) == 1);
}
+/** Return true iff <b>string</b> is a valid destination address,
+ * i.e. either a DNS hostname or IPv4/IPv6 address string.
+ */
+int
+string_is_valid_dest(const char *string)
+{
+ return string_is_valid_ipv4_address(string) ||
+ string_is_valid_ipv6_address(string) ||
+ string_is_valid_hostname(string);
+}
+
/** Return true iff <b>string</b> matches a pattern of DNS names
* that we allow Tor clients to connect to.
*
diff --git a/src/common/util.h b/src/common/util.h
index 2ee0ea28cd..d6bda80363 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -233,6 +233,7 @@ const char *find_str_at_start_of_line(const char *haystack,
const char *needle);
int string_is_C_identifier(const char *string);
int string_is_key_value(int severity, const char *string);
+int string_is_valid_dest(const char *string);
int string_is_valid_hostname(const char *string);
int string_is_valid_ipv4_address(const char *string);
int string_is_valid_ipv6_address(const char *string);