[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] initial patches on patches
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
buffers.c circuit.c connection_edge.c cpuworker.c main.c
onion.c or.h routers.c
Log Message:
initial patches on patches
Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/buffers.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- buffers.c 11 Nov 2003 02:41:31 -0000 1.52
+++ buffers.c 16 Nov 2003 17:00:02 -0000 1.53
@@ -430,7 +430,7 @@
req->reply[0] = 5; /* socks5 reply */
req->reply[1] = 0xFF; /* reject all methods */
return -1;
- }
+ }
buf_remove_from_front(buf,2+nummethods);/* remove packet from buf */
req->replylen = 2; /* 2 bytes of response */
@@ -461,7 +461,7 @@
strlen(tmpbuf)+1,MAX_SOCKS_ADDR_LEN);
return -1;
}
- strcpy(req->addr,tmpbuf);
+ strcpy(req->address,tmpbuf);
req->port = ntohs(*(uint16_t*)(buf->mem+8));
buf_remove_from_front(buf, 10);
return 1;
@@ -475,8 +475,8 @@
len+1,MAX_SOCKS_ADDR_LEN);
return -1;
}
- memcpy(req->addr,buf->mem+5,len);
- req->addr[len] = 0;
+ memcpy(req->address,buf->mem+5,len);
+ req->address[len] = 0;
req->port = ntohs(*(uint16_t*)(buf->mem+5+len));
buf_remove_from_front(buf, 5+len+2);
return 1;
@@ -533,7 +533,7 @@
}
}
log_fn(LOG_DEBUG,"Everything is here. Success.");
- strcpy(req->addr, socks4_prot == socks4 ? tmpbuf : startaddr);
+ strcpy(req->address, socks4_prot == socks4 ? tmpbuf : startaddr);
buf_remove_from_front(buf, next-buf->mem+1); /* next points to the final \0 on inbuf */
return 1;
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- circuit.c 14 Nov 2003 20:45:47 -0000 1.92
+++ circuit.c 16 Nov 2003 17:00:02 -0000 1.93
@@ -86,6 +86,8 @@
crypto_free_cipher_env(circ->n_crypto);
if (circ->p_crypto)
crypto_free_cipher_env(circ->p_crypto);
+ if(circ->build_state)
+ tor_free(circ->build_state->chosen_exit);
tor_free(circ->build_state);
circuit_free_cpath(circ->cpath);
free(circ);
@@ -659,7 +661,7 @@
circ = circuit_new(0, NULL); /* sets circ->p_circ_id and circ->p_conn */
circ->state = CIRCUIT_STATE_OR_WAIT;
circ->build_state = onion_new_cpath_build_state();
-
+
if (! circ->build_state) {
log_fn(LOG_INFO,"Generating cpath length failed.");
circuit_close(circ);
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- connection_edge.c 16 Nov 2003 05:33:45 -0000 1.55
+++ connection_edge.c 16 Nov 2003 17:00:02 -0000 1.56
@@ -101,7 +101,7 @@
payload[0] = reason;
if(reason == END_STREAM_REASON_EXITPOLICY) {
*(uint32_t *)(payload+1) = htonl(conn->addr);
- payload_len += 6;
+ payload_len += 4;
}
circ = circuit_get_by_conn(conn);
@@ -250,12 +250,10 @@
*(cell->payload+RELAY_HEADER_SIZE) == END_STREAM_REASON_EXITPOLICY) {
/* No need to close the connection. We'll hold it open while
* we try a new exit node.
- * cell->payload+RELAY_HEADER_SIZE+1 holds the addr and then
- * port of the destination. Which is good, because we've
- * forgotten it.
+ * cell->payload+RELAY_HEADER_SIZE+1 holds the destination addr.
*/
addr = ntohl(*cell->payload+RELAY_HEADER_SIZE+1);
- client_dns_set_entry(conn->socks_request->addr, addr);
+ client_dns_set_entry(conn->socks_request->address, addr);
conn->state = AP_CONN_STATE_CIRCUIT_WAIT;
/* XXX Build another circuit as required */
return 0;
@@ -324,7 +322,7 @@
log_fn(LOG_INFO,"Connected! Notifying application.");
if (cell->length-RELAY_HEADER_SIZE == 4) {
addr = htonl(*(uint32_t*)(cell->payload + RELAY_HEADER_SIZE));
- client_dns_set_entry(conn->socks_request->addr, addr);
+ client_dns_set_entry(conn->socks_request->address, addr);
}
if(connection_ap_handshake_socks_reply(conn, NULL, 0, 1) < 0) {
log_fn(LOG_INFO,"Writing to socks-speaking application failed. Closing.");
@@ -620,19 +618,18 @@
assert(ap_conn->type == CONN_TYPE_AP);
assert(ap_conn->state == AP_CONN_STATE_CIRCUIT_WAIT);
assert(ap_conn->socks_request);
- assert(ap_conn->socks_request->addr);
crypto_pseudo_rand(STREAM_ID_SIZE, ap_conn->stream_id);
/* FIXME check for collisions */
- in.s_addr = client_dns_lookup_entry(ap_conn->socks_request->addr);
+ in.s_addr = client_dns_lookup_entry(ap_conn->socks_request->address);
string_addr = in.s_addr ? inet_ntoa(in) : NULL;
memcpy(payload, ap_conn->stream_id, STREAM_ID_SIZE);
payload_len = STREAM_ID_SIZE + 1 +
snprintf(payload+STREAM_ID_SIZE,CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE-STREAM_ID_SIZE,
"%s:%d",
- string_addr ? string_addr : ap_conn->socks_request->addr,
+ string_addr ? string_addr : ap_conn->socks_request->address,
ap_conn->socks_request->port);
log_fn(LOG_DEBUG,"Sending relay cell to begin stream %d.",*(int *)ap_conn->stream_id);
@@ -786,8 +783,8 @@
int connection_ap_can_use_exit(connection_t *conn, routerinfo_t *exit)
{
uint32_t addr;
-
- addr = client_dns_lookup_entry(conn->socks_request->addr);
+
+ addr = client_dns_lookup_entry(conn->socks_request->address);
return router_supports_exit_address(addr, conn->port, exit);
}
@@ -896,7 +893,7 @@
}
}
-static void client_dns_clean()
+static void client_dns_clean(void)
{
struct client_dns_entry **expired_entries;
int n_expired_entries = 0;
@@ -905,8 +902,8 @@
int i;
expired_entries = tor_malloc(client_dns_size *
- sizeof(struct client_dns_entry *));
-
+ sizeof(struct client_dns_entry *));
+
now = time(NULL);
SPLAY_FOREACH(ent, client_dns_tree, &client_dns_root) {
if (ent->expires < now) {
Index: cpuworker.c
===================================================================
RCS file: /home/or/cvsroot/src/or/cpuworker.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cpuworker.c 11 Nov 2003 03:01:48 -0000 1.14
+++ cpuworker.c 16 Nov 2003 17:00:02 -0000 1.15
@@ -5,7 +5,7 @@
#include "or.h"
extern or_options_t options; /* command-line and config-file options */
-#define MAX_CPUWORKERS 17
+#define MAX_CPUWORKERS 16
#define MIN_CPUWORKERS 1
#define TAG_LEN 8
@@ -60,10 +60,14 @@
if(conn->inbuf_reached_eof) {
log_fn(LOG_WARN,"Read eof. Worker dying.");
if(conn->state != CPUWORKER_STATE_IDLE) {
- /* XXX the circ associated with this cpuworker will wait forever. Oops. */
+ /* the circ associated with this cpuworker will have to wait until
+ * it gets culled in run_connection_housekeeping(), since we have
+ * no way to find out which circ it was. */
+ log_fn(LOG_WARN,"...and leaving a circuit waiting. Oh well.");
num_cpuworkers_busy--;
}
num_cpuworkers--;
+ spawn_enough_cpuworkers(); /* try to regrow. hope we don't end up spinning. */
return -1;
}
@@ -215,7 +219,6 @@
}
}
-
static void process_pending_task(connection_t *cpuworker) {
circuit_t *circ;
@@ -233,8 +236,8 @@
/* if cpuworker is defined, assert that he's idle, and use him. else,
* look for an idle cpuworker and use him. if none idle, queue task onto
* the pending onion list and return.
- * If question_type is CPUWORKER_TASK_ONION then task is a circ, else
- * (something else)
+ * If question_type is CPUWORKER_TASK_ONION then task is a circ.
+ * No other question_types are allowed.
*/
int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type,
void *task) {
@@ -271,7 +274,7 @@
connection_write_to_buf(tag, sizeof(tag), cpuworker);
connection_write_to_buf(circ->onionskin, DH_ONIONSKIN_LEN, cpuworker);
}
- return 0;
+ return 0;
}
/*
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- main.c 13 Nov 2003 06:49:25 -0000 1.144
+++ main.c 16 Nov 2003 17:00:02 -0000 1.145
@@ -802,6 +802,9 @@
if(options.OnionRouter) { /* only spawn dns handlers if we're a router */
dns_init(); /* initialize the dns resolve tree, and spawn workers */
}
+ if(options.SocksPort) {
+ client_dns_init(); /* init the client dns cache */
+ }
#ifndef MS_WINDOWS /* do signal stuff only on unix */
signal (SIGINT, catch); /* catch kills so we can exit cleanly */
Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- onion.c 16 Nov 2003 05:33:45 -0000 1.84
+++ onion.c 16 Nov 2003 17:00:02 -0000 1.85
@@ -6,16 +6,11 @@
extern or_options_t options; /* command-line and config-file options */
-struct cpath_build_state_t {
- int desired_path_len;
- char *chosen_exit; /* nicknames */
-};
-
static int count_acceptable_routers(routerinfo_t **rarray, int rarray_len);
int decide_circ_id_type(char *local_nick, char *remote_nick) {
int result;
-
+
assert(remote_nick);
if(!local_nick)
return CIRC_ID_TYPE_LOWER;
@@ -306,8 +301,7 @@
}
}
}
- tor_free(n_supported);
- tor_free(n_maybe_supported);
+ tor_free(n_supported); tor_free(n_maybe_supported);
i = crypto_pseudo_rand_int(dir->n_routers);
log_fn(LOG_DEBUG, "Chose exit server '%s'", dir->routers[i]->nickname);
return dir->routers[i];
@@ -324,7 +318,6 @@
return NULL;
info = tor_malloc(sizeof(cpath_build_state_t));
info->desired_path_len = r;
- /* XXX This is leaked */
info->chosen_exit = tor_strdup(choose_good_exit_server(dir)->nickname);
return info;
}
@@ -413,6 +406,7 @@
} else if (cur_len == state->desired_path_len - 1) { /* Picking last node */
log_fn(LOG_DEBUG, "Contemplating last hop: choice already made.");
choice = router_get_by_nickname(state->chosen_exit);
+ /* XXX check if null */
} else {
log_fn(LOG_DEBUG, "Contemplating intermediate hop: random choice.");
choice = rarray[crypto_pseudo_rand_int(rarray_len)];
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -d -r1.186 -r1.187
--- or.h 16 Nov 2003 05:33:45 -0000 1.186
+++ or.h 16 Nov 2003 17:00:02 -0000 1.187
@@ -392,7 +392,10 @@
typedef struct crypt_path_t crypt_path_t;
-typedef struct cpath_build_state_t cpath_build_state_t;
+typedef struct {
+ int desired_path_len;
+ char *chosen_exit; /* nickname of planned exit node */
+} cpath_build_state_t;
/* struct for a path (circuit) through the network */
struct circuit_t {
@@ -470,7 +473,7 @@
char socks_version;
int replylen;
char reply[MAX_SOCKS_REPLY_LEN];
- char addr[MAX_SOCKS_ADDR_LEN];
+ char address[MAX_SOCKS_ADDR_LEN];
uint16_t port;
};
@@ -626,6 +629,8 @@
extern uint64_t stats_n_data_bytes_packaged;
extern uint64_t stats_n_data_cells_received;
extern uint64_t stats_n_data_bytes_received;
+
+void client_dns_init(void);
/********************************* connection_or.c ***************************/
Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- routers.c 16 Nov 2003 05:33:45 -0000 1.90
+++ routers.c 16 Nov 2003 17:00:02 -0000 1.91
@@ -63,7 +63,7 @@
return router;
}
- log_fn(LOG_WARN,"No dirservers are up. Giving them all another chance.");
+ log_fn(LOG_INFO,"No dirservers are reachable. Trying them all again.");
/* no running dir servers found? go through and mark them all as up,
* and we'll cycle through the list again. */
for(i=0;i<directory->n_routers;i++) {