aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-02-23 06:40:48 +0000
committerNick Mathewson <nickm@torproject.org>2005-02-23 06:40:48 +0000
commite0387d1322a5dc5ea46da1e3dc84a2befa29d922 (patch)
tree8135f7563484b389f45d38c3b28a14bc4e03ffa9 /src
parent2ff6cfccd68b069ef05bc43b8f3f2e290aff0437 (diff)
downloadtor-e0387d1322a5dc5ea46da1e3dc84a2befa29d922.tar.gz
tor-e0387d1322a5dc5ea46da1e3dc84a2befa29d922.zip
Addressmap tweak: Make "addressmap x x" remove any mapping from the address x.
svn:r3666
Diffstat (limited to 'src')
-rw-r--r--src/or/connection_edge.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 632a93e497..ec085bb406 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -430,8 +430,11 @@ int addressmap_already_mapped(const char *address) {
/** Register a request to map <b>address</b> to <b>new_address</b>,
* which will expire on <b>expires</b> (or 0 if never expires).
*
- * new_address should be a newly dup'ed string, which we'll use or
+ * <b>new_address</b> should be a newly dup'ed string, which we'll use or
* free as appropriate. We will leave address alone.
+ *
+ * If <b>new_address</b> is NULL, or equal to <b>address</b>, remove
+ * any mappings that exist from <b>address</b>.
*/
void addressmap_register(const char *address, char *new_address, time_t expires) {
addressmap_entry_t *ent;
@@ -442,6 +445,15 @@ void addressmap_register(const char *address, char *new_address, time_t expires)
tor_free(new_address);
return;
}
+ if (!new_address || !strcasecmp(address,new_address)) {
+ tor_free(new_address);
+ /* Remove the old mapping, if any. */
+ if (ent) {
+ addressmap_ent_free(ent);
+ strmap_remove(addressmap, address);
+ }
+ return;
+ }
if (ent) { /* we'll replace it */
tor_free(ent->new_address);
} else { /* make a new one and register it */
@@ -487,7 +499,7 @@ void client_dns_set_addressmap(const char *address, uint32_t val)
tor_assert(address); tor_assert(val);
if (tor_inet_aton(address, &in))
- return; /* don't set an addressmap back to ourselves! */
+ return; /* don't set an addresmap back to ourselves! ????NM*/
in.s_addr = htonl(val);
addr = tor_malloc(INET_NTOA_BUF_LEN);
tor_inet_ntoa(&in,addr,INET_NTOA_BUF_LEN);