aboutsummaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-03-02 19:26:46 +0000
committerNick Mathewson <nickm@torproject.org>2005-03-02 19:26:46 +0000
commit65230fd39f0c333ce8616f5a578f4941ea9f0b94 (patch)
treee6d33d51eac0f07d35e7fbebcc021f350c724646 /src/or/control.c
parent06a574b0c95b332b01aa8beb30bfb8237c1f7747 (diff)
downloadtor-65230fd39f0c333ce8616f5a578f4941ea9f0b94.tar.gz
tor-65230fd39f0c333ce8616f5a578f4941ea9f0b94.zip
Implement "Dont-Care" from addresses to MapAddress control message. For safety, refuse to launch connections to unmapped addresses in the dont-care range.
svn:r3725
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 4ce437283b..ff54f38959 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -471,6 +471,18 @@ handle_control_mapaddress(connection_t *conn, uint16_t len, const char *body)
log_fn(LOG_WARN,"Skipping invalid argument '%s' in MapAddress msg",from);
} else if (!is_plausible_address(to)) {
log_fn(LOG_WARN,"Skipping invalid argument '%s' in AddressMap msg",to);
+ } else if (!strcmp(from, ".") || !strcmp(from, "0.0.0.0")) {
+ char *addr = client_dns_get_unmapped_address(
+ strcmp(from,".") ? RESOLVED_TYPE_HOSTNAME : RESOLVED_TYPE_IPV4);
+ if (!addr) {
+ log_fn(LOG_WARN,
+ "Unable to allocate address for '%s' in AdressMap msg", line);
+ } else {
+ char *ans = tor_malloc(strlen(addr)+strlen(to)+2);
+ tor_snprintf(ans, "%s %s", addr, to);
+ addressmap_register(addr, tor_strdup(to), 0);
+ smartlist_add(reply, ans);
+ }
} else {
addressmap_register(from, tor_strdup(to), 0);
smartlist_add(reply, tor_strdup(line));