Commit efa8e288 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

my_routerinfo, router_is_me, and learn_my_address are obsolete

ACIs are decided now by strcmp'ing nicknames, rather than comparing addr:port


svn:r529
parent 91cf86d8
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -789,7 +789,6 @@ int circuit_send_next_onion_skin(circuit_t *circ) {
int circuit_extend(cell_t *cell, circuit_t *circ) {
  connection_t *n_conn;
  aci_t aci_type;
  struct sockaddr_in me; /* my router identity */
  cell_t newcell;

  if(circ->n_conn) {
@@ -800,9 +799,6 @@ int circuit_extend(cell_t *cell, circuit_t *circ) {
  circ->n_addr = ntohl(*(uint32_t*)(cell->payload+RELAY_HEADER_SIZE));
  circ->n_port = ntohs(*(uint16_t*)(cell->payload+RELAY_HEADER_SIZE+4));

  if(learn_my_address(&me) < 0)
    return -1;

  n_conn = connection_twin_get_by_addr_port(circ->n_addr,circ->n_port);
  if(!n_conn || n_conn->type != CONN_TYPE_OR) {
    /* i've disabled making connections through OPs, but it's definitely
@@ -824,8 +820,7 @@ int circuit_extend(cell_t *cell, circuit_t *circ) {
  circ->n_conn = n_conn;
  log_fn(LOG_DEBUG,"n_conn is %s:%u",n_conn->address,n_conn->port);

  aci_type = decide_aci_type(ntohl(me.sin_addr.s_addr), ntohs(me.sin_port),
                             circ->n_addr, circ->n_port);
  aci_type = decide_aci_type(options.Nickname, n_conn->nickname);

  log_fn(LOG_DEBUG,"aci_type = %u.",aci_type);
  circ->n_aci = get_unique_aci_by_addr_port(circ->n_addr, circ->n_port, aci_type);
+1 −1
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ int getconfig(int argc, char **argv, or_options_t *options) {
  options->LogLevel = "debug";
  options->loglevel = LOG_DEBUG;
  options->DataDirectory = NULL;
  options->CoinWeight = 0.8;
  options->CoinWeight = 0.1;
  options->MaxConn = 900;
  options->DirFetchPostPeriod = 600;
  options->KeepalivePeriod = 300;
+2 −3
Original line number Diff line number Diff line
@@ -94,9 +94,8 @@ connection_t *connection_or_connect(routerinfo_t *router) {

  assert(router);

  if(router_is_me(router->addr, router->or_port)) {
    /* this is me! don't connect to me. XXX use nickname/key */
    log(LOG_DEBUG,"connection_or_connect(): This is me. Skipping.");
  if(options.Nickname && !strcmp(router->nickname,options.Nickname)) {
    log_fn(LOG_WARNING,"You asked me to connect to myself! Failing.");
    return NULL;
  }

+0 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
/********* START PROTOTYPES **********/

static void dumpstats(void); /* dump stats to stdout */
static int init_descriptor(void);

/********* START VARIABLES **********/

+10 −10
Original line number Diff line number Diff line
@@ -8,17 +8,17 @@ extern or_options_t options; /* command-line and config-file options */

static int count_acceptable_routers(routerinfo_t **rarray, int rarray_len);

int decide_aci_type(uint32_t local_addr, uint16_t local_port,
                    uint32_t remote_addr, uint16_t remote_port) {
int decide_aci_type(char *local_nick, char *remote_nick) {
  int result;
 
  if(local_addr > remote_addr)
    return ACI_TYPE_HIGHER;
  if(local_addr < remote_addr)
  assert(remote_nick);
  if(!local_nick)
    return ACI_TYPE_LOWER;
  if(local_port > remote_port)
    return ACI_TYPE_HIGHER;
   /* else */
  result = strcmp(local_nick, remote_nick);
  assert(result);
  if(result < 0)
    return ACI_TYPE_LOWER;
  return ACI_TYPE_HIGHER;
}

struct onion_queue_t {
Loading