[or-cvs] Make a new AssumeReachable config option that will publish ...
arma at seul.org
arma at seul.org
Fri Aug 26 07:41:22 UTC 2005
Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or
Modified Files:
config.c connection.c connection_or.c or.h router.c
routerlist.c
Log Message:
Make a new AssumeReachable config option that will publish anyway.
Also, let authdirservers start without setting their Address field.
Something is still not working though. Will fix in morning.
Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.396
retrieving revision 1.397
diff -u -d -r1.396 -r1.397
--- config.c 25 Aug 2005 20:33:16 -0000 1.396
+++ config.c 26 Aug 2005 07:41:19 -0000 1.397
@@ -100,6 +100,7 @@
VAR("AccountingStart", STRING, AccountingStart, NULL),
VAR("Address", STRING, Address, NULL),
VAR("AllowUnverifiedNodes",CSV, AllowUnverifiedNodes, "middle,rendezvous"),
+ VAR("AssumeReachable", BOOL, AssumeReachable, "0"),
VAR("AuthoritativeDirectory",BOOL, AuthoritativeDir, "0"),
VAR("BandwidthBurst", MEMUNIT, BandwidthBurst, "5 MB"),
VAR("BandwidthRate", MEMUNIT, BandwidthRate, "2 MB"),
@@ -1141,7 +1142,7 @@
/**
* Based on <b>options-\>Address</b>, guess our public IP address and put it
- * in *<b>addr_out</b>. If <b>hostname_out</b> is provided, set
+ * (in host order) into *<b>addr_out</b>. If <b>hostname_out</b> is provided, set
* *<b>hostname_out</b> to a new string holding the hostname we used to get
* the address. Return 0 if all is well, or -1 if we can't find a suitable
* public IP address.
Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.393
retrieving revision 1.394
diff -u -d -r1.393 -r1.394
--- connection.c 7 Aug 2005 19:27:38 -0000 1.393
+++ connection.c 26 Aug 2005 07:41:19 -0000 1.394
@@ -669,10 +669,9 @@
newconn->s = news;
/* remember the remote address */
- newconn->address = tor_malloc(INET_NTOA_BUF_LEN);
- tor_inet_ntoa(&remote.sin_addr, newconn->address, INET_NTOA_BUF_LEN);
newconn->addr = ntohl(remote.sin_addr.s_addr);
newconn->port = ntohs(remote.sin_port);
+ newconn->address = tor_dup_addr(newconn->addr);
if (connection_add(newconn) < 0) { /* no space, forget it */
connection_free(newconn);
Index: connection_or.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection_or.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -d -r1.185 -r1.186
--- connection_or.c 24 Aug 2005 02:31:01 -0000 1.185
+++ connection_or.c 26 Aug 2005 07:41:19 -0000 1.186
@@ -240,7 +240,6 @@
uint32_t addr, uint16_t port,
const char *id_digest)
{
- struct in_addr in;
const char *n;
or_options_t *options = get_options();
routerinfo_t *r = router_get_by_digest(id_digest);
@@ -265,10 +264,7 @@
conn->identity_digest, DIGEST_LEN);
}
tor_free(conn->address);
- in.s_addr = htonl(addr);
-
- conn->address = tor_malloc(INET_NTOA_BUF_LEN);
- tor_inet_ntoa(&in,conn->address,INET_NTOA_BUF_LEN);
+ conn->address = tor_dup_addr(addr);
}
/** "update an OR connection nickname on the fly"
Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.652
retrieving revision 1.653
diff -u -d -r1.652 -r1.653
--- or.h 25 Aug 2005 20:33:17 -0000 1.652
+++ or.h 26 Aug 2005 07:41:19 -0000 1.653
@@ -1092,6 +1092,7 @@
int SocksPort; /**< Port to listen on for SOCKS connections. */
int ControlPort; /**< Port to listen on for control connections. */
int DirPort; /**< Port to listen on for directory connections. */
+ int AssumeReachable; /**< Whether to publish our descriptor regardless. */
int AuthoritativeDir; /**< Boolean: is this an authoritative directory? */
int ClientOnly; /**< Boolean: should we never evolve into a server role? */
int NoPublish; /**< Boolean: should we never publish a descriptor? */
Index: router.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -d -r1.192 -r1.193
--- router.c 25 Aug 2005 20:33:17 -0000 1.192
+++ router.c 26 Aug 2005 07:41:19 -0000 1.193
@@ -401,14 +401,20 @@
int
check_whether_orport_reachable(void)
{
- return clique_mode(get_options()) || can_reach_or_port;
+ or_options_t *options = get_options();
+ return clique_mode(options) ||
+ options->AssumeReachable ||
+ can_reach_or_port;
}
/** Return 1 if we don't have a dirport configured, or if it's reachable. */
int
check_whether_dirport_reachable(void)
{
- return !get_options()->DirPort || can_reach_dir_port;
+ or_options_t *options = get_options();
+ return !options->DirPort ||
+ options->AssumeReachable ||
+ can_reach_dir_port;
}
/**DOCDOC*/
@@ -720,10 +726,8 @@
routerinfo_t *ri;
uint32_t addr;
char platform[256];
- struct in_addr in;
int hibernating = we_are_hibernating();
or_options_t *options = get_options();
- char addrbuf[INET_NTOA_BUF_LEN];
if (desc_clean_since && !force)
return 0;
@@ -734,9 +738,7 @@
}
ri = tor_malloc_zero(sizeof(routerinfo_t));
- in.s_addr = htonl(addr);
- tor_inet_ntoa(&in, addrbuf, sizeof(addrbuf));
- ri->address = tor_strdup(addrbuf);
+ ri->address = tor_dup_addr(addr);
ri->nickname = tor_strdup(options->Nickname);
ri->addr = addr;
ri->or_port = options->ORPort;
Index: routerlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -d -r1.250 -r1.251
--- routerlist.c 16 Aug 2005 02:52:27 -0000 1.250
+++ routerlist.c 26 Aug 2005 07:41:19 -0000 1.251
@@ -1461,15 +1461,25 @@
if (!trusted_dir_servers)
trusted_dir_servers = smartlist_create();
- if (tor_lookup_hostname(address, &a)) {
+ if (!address) { /* need to guess */
+ if (resolve_my_address(get_options(), &a, NULL) < 0) {
+ log_fn(LOG_WARN, "Couldn't find a suitable address. Returning.");
+ return;
+ }
+ } else if (tor_lookup_hostname(address, &a)) {
log_fn(LOG_WARN, "Unable to lookup address for directory server at %s",
address);
return;
+ a = ntohl(a);
}
ent = tor_malloc(sizeof(trusted_dir_server_t));
- ent->address = tor_strdup(address);
- ent->addr = ntohl(a);
+ if (address) {
+ ent->address = tor_strdup(address);
+ } else {
+ ent->address = tor_dup_addr(a);
+ }
+ ent->addr = a;
ent->dir_port = port;
ent->is_running = 1;
memcpy(ent->digest, digest, DIGEST_LEN);
More information about the tor-commits
mailing list