[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Addressmap tweak: Make "addressmap x x" remove any mapping ...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] Addressmap tweak: Make "addressmap x x" remove any mapping ...
- From: nickm@xxxxxxxx (Nick Mathewson)
- Date: Wed, 23 Feb 2005 01:40:50 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Wed, 23 Feb 2005 01:41:19 -0500
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv24043
Modified Files:
connection_edge.c
Log Message:
Addressmap tweak: Make "addressmap x x" remove any mapping from the address x.
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.281
retrieving revision 1.282
diff -u -d -r1.281 -r1.282
--- connection_edge.c 22 Feb 2005 08:18:35 -0000 1.281
+++ connection_edge.c 23 Feb 2005 06:40:48 -0000 1.282
@@ -430,8 +430,11 @@
/** 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 @@
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 @@
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);