[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] new config option DirAllowPrivateAddresses for authdirserve...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] new config option DirAllowPrivateAddresses for authdirserve...
- From: arma@xxxxxxxx (Roger Dingledine)
- Date: Thu, 6 Jan 2005 16:03:30 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Thu, 06 Jan 2005 16:03:52 -0500
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or
Modified Files:
config.c directory.c dirserv.c or.h
Log Message:
new config option DirAllowPrivateAddresses for authdirservers.
now by default they refuse router descriptors that have non-IP
or private-IP addresses.
Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.295
retrieving revision 1.296
diff -u -d -r1.295 -r1.296
--- config.c 5 Jan 2005 06:05:37 -0000 1.295
+++ config.c 6 Jan 2005 21:03:27 -0000 1.296
@@ -103,6 +103,7 @@
VAR("CookieAuthentication",BOOL, CookieAuthentication, "0"),
VAR("DebugLogFile", STRING, DebugLogFile, NULL),
VAR("DataDirectory", STRING, DataDirectory, NULL),
+ VAR("DirAllowPrivateAddresses",BOOL, DirAllowPrivateAddresses, NULL),
VAR("DirPort", UINT, DirPort, "0"),
VAR("DirBindAddress", LINELIST, DirBindAddress, NULL),
/* XXX we'd like dirfetchperiod to be higher for people with dirport not
Index: directory.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -d -r1.188 -r1.189
--- directory.c 6 Jan 2005 20:11:52 -0000 1.188
+++ directory.c 6 Jan 2005 21:03:27 -0000 1.189
@@ -653,7 +653,7 @@
log_fn(LOG_WARN,"http status 400 (bad request) response from dirserver '%s'. Malformed server descriptor?", conn->address);
break;
case 403:
- log_fn(LOG_WARN,"http status 403 (unapproved server) response from dirserver '%s'. Is your clock skewed? Have you mailed us your key fingerprint? Are you using the right key? See http://tor.eff.org/doc/tor-doc.html#server.", conn->address);
+ log_fn(LOG_WARN,"http status 403 (unapproved server) response from dirserver '%s'. Is your clock skewed? Have you mailed us your key fingerprint? Are you using the right key? Are you using a private IP address? See http://tor.eff.org/doc/tor-doc.html#server.", conn->address);
break;
default:
log_fn(LOG_WARN,"http status %d response unrecognized (server '%s').", status_code, conn->address);
Index: dirserv.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- dirserv.c 6 Jan 2005 20:11:52 -0000 1.134
+++ dirserv.c 6 Jan 2005 21:03:27 -0000 1.135
@@ -284,6 +284,27 @@
smartlist_clear(descriptor_list);
}
+/** Return -1 if <b>ri</b> has a private or otherwise bad address,
+ * unless we're configured to not care. Return 0 if all ok. */
+static int
+dirserv_router_has_valid_address(routerinfo_t *ri)
+{
+ struct in_addr iaddr;
+ if (get_options()->DirAllowPrivateAddresses)
+ return 0; /* whatever it is, we're fine with it */
+ if (!tor_inet_aton(ri->address, &iaddr)) {
+ log_fn(LOG_INFO,"Router '%s' published non-IP address '%s'. Refusing.",
+ ri->nickname, ri->address);
+ return -1;
+ }
+ if (is_internal_IP(ntohl(iaddr.s_addr))) {
+ log_fn(LOG_INFO,"Router '%s' published internal IP address '%s'. Refusing.",
+ ri->nickname, ri->address);
+ return -1; /* it's a private IP, we should reject it */
+ }
+ return 0;
+}
+
/** Parse the server descriptor at *desc and maybe insert it into the
* list of server descriptors, and (if the descriptor is well-formed)
* advance *desc immediately past the descriptor's end.
@@ -340,7 +361,7 @@
}
if (r==0) {
char fp[FINGERPRINT_LEN+1];
- log_fn(LOG_INFO, "Unknown nickname '%s' (%s:%d). Adding.",
+ log_fn(LOG_INFO, "Unknown nickname '%s' (%s:%d). Will try to add.",
ri->nickname, ri->address, ri->or_port);
if (crypto_pk_get_fingerprint(ri->identity_pkey, fp, 1) < 0) {
log_fn(LOG_WARN, "Error computing fingerprint for '%s'", ri->nickname);
@@ -363,6 +384,12 @@
*desc = end;
return 0;
}
+ if (dirserv_router_has_valid_address(ri) < 0) {
+ log_fn(LOG_NOTICE, "Router with nickname '%s' has invalid address '%s'. Not adding.", ri->nickname, ri->address);
+ routerinfo_free(ri);
+ *desc = end;
+ return 0;
+ }
/* Do we already have an entry for this router? */
for (i = 0; i < smartlist_len(descriptor_list); ++i) {
Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.519
retrieving revision 1.520
diff -u -d -r1.519 -r1.520
--- or.h 6 Jan 2005 20:11:52 -0000 1.519
+++ or.h 6 Jan 2005 21:03:27 -0000 1.520
@@ -910,9 +910,11 @@
struct config_line_t *DirBindAddress;
/** Local address to bind outbound sockets */
char *OutboundBindAddress;
+ /** Directory server only: which versions of
+ * Tor should we tell users to run? */
struct config_line_t *RecommendedVersions;
- /**< Directory server only: which versions of
- * Tor should we tell users to run? */
+ /** Whether dirservers refuse router descriptors with private IPs. */
+ int DirAllowPrivateAddresses;
char *User; /**< Name of user to run Tor as. */
char *Group; /**< Name of group to run Tor as. */
double PathlenCoinWeight; /**< Parameter used to configure average path