Commit 95e5384a authored by Nick Mathewson's avatar Nick Mathewson 🌉
Browse files

Change many files to new log_fn format


svn:r333
parent 6965a469
......@@ -23,7 +23,7 @@ NICK . Handle half-open connections
- Figure out what causes connections to close, standardize
when we mark a connection vs when we tear it down
o Look at what ssl does to keep from mutating data streams
NICK . On the fly compression of each stream
X On the fly compression of each stream
o Clean up the event loop (optimize and sanitize)
ARMA o Remove that awful concept of 'roles'
ARMA . Exit policies
......@@ -45,6 +45,10 @@ SPEC!! D Non-clique topologies
o Distribute queries onto the farm, get answers
o Preemptively grow a new worker before he's needed
- Prune workers when too many are idle
- DNS cache
- Clear DNS cache over time
- Honor DNS TTL info
- Have strategy when all workers are busy
o Keep track of which connections are in dns_wait
o Need to cache positives/negatives on the tor side
o Keep track of which queries have been asked
......@@ -54,9 +58,9 @@ SPEC!! D Non-clique topologies
- Consider taking the master out of the loop?
. Directory servers
D Automated reputation management
NICK . Include key in source; sign directories
. Include key in source; sign directories
o Signed directory backend
- Document
o Document
ARMA - Integrate
- Add versions to code
NICK . Have directories list recommended-versions
......
......@@ -159,17 +159,17 @@ crypto_create_init_cipher(int cipher_type, char *key, char *iv, int encrypt_mode
crypto_cipher_env_t *crypto = NULL;
if (! (crypto = crypto_new_cipher_env(cipher_type))) {
log(LOG_ERR, "Unable to allocate crypto object");
log_fn(LOG_ERR, "Unable to allocate crypto object");
return NULL;
}
if (crypto_cipher_set_key(crypto, key)) {
log(LOG_ERR, "Unable to set key: %s", crypto_perror());
log_fn(LOG_ERR, "Unable to set key: %s", crypto_perror());
goto error;
}
if (crypto_cipher_set_iv(crypto, iv)) {
log(LOG_ERR, "Unable to set iv: %s", crypto_perror());
log_fn(LOG_ERR, "Unable to set iv: %s", crypto_perror());
goto error;
}
......@@ -179,7 +179,7 @@ crypto_create_init_cipher(int cipher_type, char *key, char *iv, int encrypt_mode
r = crypto_cipher_decrypt_init_cipher(crypto);
if (r) {
log(LOG_ERR, "Unabble to initialize cipher: %s", crypto_perror());
log_fn(LOG_ERR, "Unabble to initialize cipher: %s", crypto_perror());
goto error;
}
return crypto;
......@@ -310,7 +310,7 @@ int crypto_pk_read_private_key_from_filename(crypto_pk_env_t *env, unsigned char
fclose(f_pr);
if (retval == -1)
{
log(LOG_ERR,"Error reading private key : %s",crypto_perror());
log_fn(LOG_ERR,"Error reading private key : %s",crypto_perror());
return -1;
}
......@@ -318,12 +318,12 @@ int crypto_pk_read_private_key_from_filename(crypto_pk_env_t *env, unsigned char
retval = crypto_pk_check_key(env);
if (retval == 0)
{
log(LOG_ERR,"Private key read but is invalid : %s.", crypto_perror());
log_fn(LOG_ERR,"Private key read but is invalid : %s.", crypto_perror());
return -1;
}
else if (retval == -1)
{
log(LOG_ERR,"Private key read but validity checking failed : %s",crypto_perror());
log_fn(LOG_ERR,"Private key read but validity checking failed : %s",crypto_perror());
return -1;
}
else if (retval == 1)
......@@ -799,19 +799,19 @@ int crypto_seed_rng()
for (i = 0; filenames[i]; ++i) {
f = fopen(filenames[i], "rb");
if (!f) continue;
log(LOG_INFO, "Seeding RNG from %s", filenames[i]);
log_fn(LOG_INFO, "Seeding RNG from %s", filenames[i]);
buf[20]='\xff';
n = fread(buf, 1, 20, f);
fclose(f);
if (n != 20) {
log(LOG_INFO, "Error reading from entropy source");
log_fn(LOG_INFO, "Error reading from entropy source");
return -1;
}
RAND_seed(buf, 20);
return 0;
}
log(LOG_INFO, "Cannot seed RNG -- no entropy source found.");
log_fn(LOG_INFO, "Cannot seed RNG -- no entropy source found.");
return -1;
}
......
......@@ -13,7 +13,7 @@ void *tor_malloc(size_t size) {
result = malloc(size);
if(!result) {
log(LOG_ERR,"tor_malloc(): Out of memory. Dying.");
log_fn(LOG_ERR, "Out of memory. Dying.");
exit(1);
}
......@@ -24,7 +24,7 @@ void
my_gettimeofday(struct timeval *timeval)
{
if (gettimeofday(timeval, NULL)) {
log(LOG_ERR, "my_gettimeofday: gettimeofday failed.");
log_fn(LOG_ERR, "gettimeofday failed.");
/* If gettimeofday dies, we have either given a bad timezone (we didn't),
or segfaulted.*/
exit(1);
......@@ -40,7 +40,7 @@ tv_udiff(struct timeval *start, struct timeval *end)
long secdiff = end->tv_sec - start->tv_sec;
if (secdiff+1 > LONG_MAX/1000000) {
log(LOG_NOTICE, "tv_udiff(): comparing times too far apart.");
log_fn(LOG_NOTICE, "comparing times too far apart.");
return LONG_MAX;
}
......@@ -54,7 +54,7 @@ tv_udiff(struct timeval *start, struct timeval *end)
*/
udiff = secdiff*1000000L + (end_usec - start->tv_usec);
if(udiff < 0) {
log(LOG_NOTICE, "tv_udiff(): start is after end. Returning 0.");
log_fn(LOG_NOTICE, "start is after end. Returning 0.");
return 0;
}
return udiff;
......
......@@ -60,7 +60,7 @@ int read_to_buf(int s, int at_most, char **buf, int *buflen, int *buf_datalen, i
*/
}
// log(LOG_DEBUG,"read_to_buf(): reading at most %d bytes.",at_most);
// log_fn(LOG_DEBUG,"reading at most %d bytes.",at_most);
read_result = read(s, *buf+*buf_datalen, at_most);
if (read_result < 0) {
if(errno!=EAGAIN) { /* it's a real error */
......@@ -68,12 +68,12 @@ int read_to_buf(int s, int at_most, char **buf, int *buflen, int *buf_datalen, i
}
return 0;
} else if (read_result == 0) {
log(LOG_DEBUG,"read_to_buf(): Encountered eof");
log_fn(LOG_DEBUG,"Encountered eof");
*reached_eof = 1;
return 0;
} else { /* we read some bytes */
*buf_datalen += read_result;
// log(LOG_DEBUG,"read_to_buf(): Read %d bytes. %d on inbuf.",read_result, *buf_datalen);
// log_fn(LOG_DEBUG,"Read %d bytes. %d on inbuf.",read_result, *buf_datalen);
return read_result;
}
}
......@@ -98,13 +98,13 @@ int flush_buf(int s, char **buf, int *buflen, int *buf_flushlen, int *buf_datale
if(errno!=EAGAIN) { /* it's a real error */
return -1;
}
log(LOG_DEBUG,"flush_buf(): write() would block, returning.");
log_fn(LOG_DEBUG,"write() would block, returning.");
return 0;
} else {
*buf_datalen -= write_result;
*buf_flushlen -= write_result;
memmove(*buf, *buf+write_result, *buf_datalen);
// log(LOG_DEBUG,"flush_buf(): flushed %d bytes, %d ready to flush, %d remain.",
// log_fn(LOG_DEBUG,"flushed %d bytes, %d ready to flush, %d remain.",
// write_result,*buf_flushlen,*buf_datalen);
return *buf_flushlen;
}
......@@ -122,13 +122,13 @@ int write_to_buf(char *string, int string_len,
/* this is the point where you would grow the buffer, if you want to */
if (string_len + *buf_datalen > *buflen) { /* we're out of luck */
log(LOG_DEBUG, "write_to_buf(): buflen too small. Time to implement growing dynamic bufs.");
log_fn(LOG_DEBUG, "buflen too small. Time to implement growing dynamic bufs.");
return -1;
}
memcpy(*buf+*buf_datalen, string, string_len);
*buf_datalen += string_len;
// log(LOG_DEBUG,"write_to_buf(): added %d bytes to buf (now %d total).",string_len, *buf_datalen);
// log_fn(LOG_DEBUG,"added %d bytes to buf (now %d total).",string_len, *buf_datalen);
return *buf_datalen;
}
......
This diff is collapsed.
......@@ -22,7 +22,7 @@ void command_time_process_cell(cell_t *cell, connection_t *conn,
time_passed = tv_udiff(&start, &end) ;
if (time_passed > 5000) { /* more than 5ms */
log(LOG_INFO,"command_time_process_cell(): That call just took %d ms.",time_passed/1000);
log_fn(LOG_INFO,"That call just took %ld ms.",time_passed/1000);
}
*time += time_passed;
}
......@@ -83,14 +83,14 @@ void command_process_create_cell(cell_t *cell, connection_t *conn) {
circ = circuit_get_by_aci_conn(cell->aci, conn);
if(circ) {
log(LOG_DEBUG,"command_process_create_cell(): received CREATE cell for known circ. Dropping.");
log_fn(LOG_DEBUG,"received CREATE cell for known circ. Dropping.");
return;
}
circ = circuit_new(cell->aci, conn);
circ->state = CIRCUIT_STATE_ONIONSKIN_PENDING;
if(cell->length != DH_ONIONSKIN_LEN) {
log(LOG_DEBUG,"command_process_create_cell(): Bad cell length %d. Dropping.", cell->length);
log_fn(LOG_DEBUG,"Bad cell length %d. Dropping.", cell->length);
circuit_close(circ);
return;
}
......@@ -99,10 +99,10 @@ void command_process_create_cell(cell_t *cell, connection_t *conn) {
/* add it to the pending onions queue, and then return */
if(onion_pending_add(circ) < 0) {
log(LOG_DEBUG,"command_process_create_cell(): Failed to queue onionskin. Closing.");
log_fn(LOG_DEBUG,"Failed to queue onionskin. Closing.");
circuit_close(circ);
}
log(LOG_DEBUG,"command_process_create_cell(): success: queued onionskin.");
log_fn(LOG_DEBUG,"success: queued onionskin.");
return;
}
......@@ -113,26 +113,26 @@ void command_process_created_cell(cell_t *cell, connection_t *conn) {
circ = circuit_get_by_aci_conn(cell->aci, conn);
if(!circ) {
log(LOG_DEBUG,"command_process_created_cell(): received CREATED cell for unknown circ. Dropping.");
log_fn(LOG_DEBUG,"received CREATED cell for unknown circ. Dropping.");
return;
}
if(circ->n_aci != cell->aci) {
log(LOG_DEBUG,"command_process_created_cell(): got created cell from OPward? Dropping.");
log_fn(LOG_DEBUG,"got created cell from OPward? Dropping.");
return;
}
assert(cell->length == DH_KEY_LEN);
if(circ->cpath) { /* we're the OP. Handshake this. */
log(LOG_DEBUG,"command_process_created_cell(): at OP. Finishing handshake.");
log_fn(LOG_DEBUG,"at OP. Finishing handshake.");
if(circuit_finish_handshake(circ, cell->payload) < 0) {
log(LOG_INFO,"command_process_created_cell(): circuit_finish_handshake failed.");
log_fn(LOG_INFO,"circuit_finish_handshake failed.");
circuit_close(circ);
return;
}
log(LOG_DEBUG,"command_process_created_cell(): Moving to next skin.");
log_fn(LOG_DEBUG,"Moving to next skin.");
if(circuit_send_next_onion_skin(circ) < 0) {
log(LOG_INFO,"command_process_created_cell(): circuit_send_next_onion_skin failed.");
log_fn(LOG_INFO,"circuit_send_next_onion_skin failed.");
circuit_close(circ);
return;
}
......@@ -146,9 +146,9 @@ void command_process_created_cell(cell_t *cell, connection_t *conn) {
newcell.length = RELAY_HEADER_SIZE + cell->length;
memcpy(newcell.payload+RELAY_HEADER_SIZE, cell->payload, DH_KEY_LEN);
log(LOG_DEBUG,"command_process_created_cell(): Sending extended relay cell.");
log_fn(LOG_DEBUG,"Sending extended relay cell.");
if(circuit_deliver_relay_cell(&newcell, circ, CELL_DIRECTION_IN, NULL) < 0) {
log(LOG_DEBUG,"command_process_created_cell(): failed to deliver extended cell. Closing.");
log_fn(LOG_DEBUG,"failed to deliver extended cell. Closing.");
circuit_close(circ);
return;
}
......@@ -162,26 +162,26 @@ void command_process_relay_cell(cell_t *cell, connection_t *conn) {
circ = circuit_get_by_aci_conn(cell->aci, conn);
if(!circ) {
log(LOG_DEBUG,"command_process_relay_cell(): unknown circuit %d. Dropping.", cell->aci);
log_fn(LOG_DEBUG,"unknown circuit %d. Dropping.", cell->aci);
return;
}
if(circ->state == CIRCUIT_STATE_ONIONSKIN_PENDING) {
log(LOG_DEBUG,"command_process_relay_cell(): circuit in create_wait. Dropping.");
log_fn(LOG_DEBUG,"circuit in create_wait. Dropping.");
return;
}
if(cell->aci == circ->p_aci) { /* it's an outgoing cell */
cell->aci = circ->n_aci; /* switch it */
if(circuit_deliver_relay_cell(cell, circ, CELL_DIRECTION_OUT, conn->cpath_layer) < 0) {
log(LOG_INFO,"command_process_relay_cell(): circuit_deliver_relay_cell (forward) failed. Closing.");
log_fn(LOG_INFO,"circuit_deliver_relay_cell (forward) failed. Closing.");
circuit_close(circ);
return;
}
} else { /* it's an ingoing cell */
cell->aci = circ->p_aci; /* switch it */
if(circuit_deliver_relay_cell(cell, circ, CELL_DIRECTION_IN, NULL) < 0) {
log(LOG_DEBUG,"command_process_relay_cell(): circuit_deliver_relay_cell (backward) failed. Closing.");
log_fn(LOG_DEBUG,"circuit_deliver_relay_cell (backward) failed. Closing.");
circuit_close(circ);
return;
}
......@@ -194,11 +194,11 @@ void command_process_destroy_cell(cell_t *cell, connection_t *conn) {
circ = circuit_get_by_aci_conn(cell->aci, conn);
if(!circ) {
log(LOG_DEBUG,"command_process_destroy_cell(): unknown circuit %d. Dropping.", cell->aci);
log_fn(LOG_DEBUG,"unknown circuit %d. Dropping.", cell->aci);
return;
}
log(LOG_DEBUG,"command_process_destroy_cell(): Received for aci %d.",cell->aci);
log_fn(LOG_DEBUG,"Received for aci %d.",cell->aci);
if(circ->state == CIRCUIT_STATE_ONIONSKIN_PENDING) {
onion_pending_remove(circ);
}
......@@ -209,7 +209,7 @@ void command_process_destroy_cell(cell_t *cell, connection_t *conn) {
circuit_close(circ);
} else { /* the destroy came from ahead */
circ->n_conn = NULL;
log(LOG_DEBUG, "command_process_destroy_cell(): Delivering 'truncated' back.");
log_fn(LOG_DEBUG, "Delivering 'truncated' back.");
connection_edge_send_command(NULL, circ, RELAY_COMMAND_TRUNCATED);
}
}
......
......@@ -140,7 +140,7 @@ int config_compare(struct config_line *c, char *key, int type, void *arg) {
return 0;
/* it's a match. cast and assign. */
log(LOG_DEBUG,"config_compare(): Recognized keyword '%s' as %s, using value '%s'.",c->key,key,c->value);
log_fn(LOG_DEBUG,"Recognized keyword '%s' as %s, using value '%s'.",c->key,key,c->value);
switch(type) {
case CONFIG_TYPE_INT:
......@@ -200,7 +200,7 @@ void config_assign(or_options_t *options, struct config_line *list) {
) {
/* then we're ok. it matched something. */
} else {
log(LOG_WARNING,"config_assign(): Ignoring unknown keyword '%s'.",list->key);
log_fn(LOG_WARNING,"Ignoring unknown keyword '%s'.",list->key);
}
list = list->next;
......
......@@ -123,7 +123,7 @@ void connection_free(connection_t *conn) {
crypto_free_pk_env(conn->pkey);
if(conn->s > 0) {
log(LOG_INFO,"connection_free(): closing fd %d.",conn->s);
log_fn(LOG_INFO,"closing fd %d.",conn->s);
close(conn->s);
}
if(conn->type == CONN_TYPE_OR) {
......@@ -140,7 +140,7 @@ int connection_create_listener(struct sockaddr_in *bindaddr, int type) {
s = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
if (s < 0)
{
log(LOG_ERR,"connection_create_listener(): Socket creation failed.");
log_fn(LOG_ERR,"Socket creation failed.");
return -1;
}
......@@ -161,18 +161,18 @@ int connection_create_listener(struct sockaddr_in *bindaddr, int type) {
conn = connection_new(type);
if(!conn) {
log(LOG_DEBUG,"connection_create_listener(): connection_new failed. Giving up.");
log_fn(LOG_DEBUG,"connection_new failed. Giving up.");
return -1;
}
conn->s = s;
if(connection_add(conn) < 0) { /* no space, forget it */
log(LOG_DEBUG,"connection_create_listener(): connection_add failed. Giving up.");
log_fn(LOG_DEBUG,"connection_add failed. Giving up.");
connection_free(conn);
return -1;
}
log(LOG_DEBUG,"connection_create_listener(): Listening on port %u.",ntohs(bindaddr->sin_port));
log_fn(LOG_DEBUG,"Listening on port %u.",ntohs(bindaddr->sin_port));
conn->state = LISTENER_STATE_READY;
connection_start_reading(conn);
......@@ -192,7 +192,7 @@ int connection_handle_listener_read(connection_t *conn, int new_type, int new_st
if(errno==EAGAIN)
return 0; /* he hung up before we could accept(). that's fine. */
/* else there was a real error. */
log(LOG_ERR,"connection_handle_listener_read(): accept() failed. Closing.");
log_fn(LOG_ERR,"accept() failed. Closing.");
return -1;
}
log(LOG_INFO,"Connection accepted on socket %d (child of fd %d).",news, conn->s);
......@@ -475,7 +475,7 @@ int connection_send_destroy(aci_t aci, connection_t *conn) {
assert(conn);
if(!connection_speaks_cells(conn)) {
log(LOG_INFO,"connection_send_destroy(): Aci %d: At an edge. Marking connection for close.", aci);
log_fn(LOG_INFO,"Aci %d: At an edge. Marking connection for close.", aci);
conn->marked_for_close = 1;
return 0;
}
......@@ -483,7 +483,7 @@ int connection_send_destroy(aci_t aci, connection_t *conn) {
memset(&cell, 0, sizeof(cell_t));
cell.aci = aci;
cell.command = CELL_DESTROY;
log(LOG_INFO,"connection_send_destroy(): Sending destroy (aci %d).",aci);
log_fn(LOG_INFO,"Sending destroy (aci %d).",aci);
return connection_write_cell_to_buf(&cell, conn);
}
......@@ -548,7 +548,7 @@ int connection_process_inbuf(connection_t *conn) {
case CONN_TYPE_DNSWORKER:
return connection_dns_process_inbuf(conn);
default:
log(LOG_DEBUG,"connection_process_inbuf() got unexpected conn->type.");
log_fn(LOG_DEBUG,"got unexpected conn->type.");
return -1;
}
}
......@@ -584,11 +584,11 @@ repeat_connection_package_raw_inbuf:
circ = circuit_get_by_conn(conn);
if(!circ) {
log(LOG_DEBUG,"connection_package_raw_inbuf(): conn has no circuits!");
log_fn(LOG_DEBUG,"conn has no circuits!");
return -1;
}
log(LOG_DEBUG,"connection_package_raw_inbuf(): (%d) Packaging %d bytes (%d waiting).",conn->s,cell.length, conn->inbuf_datalen);
log_fn(LOG_DEBUG,"(%d) Packaging %d bytes (%d waiting).",conn->s,cell.length, conn->inbuf_datalen);
cell.command = CELL_RELAY;
......@@ -599,7 +599,7 @@ repeat_connection_package_raw_inbuf:
if(conn->type == CONN_TYPE_EXIT) {
cell.aci = circ->p_aci;
if(circuit_deliver_relay_cell(&cell, circ, CELL_DIRECTION_IN, NULL) < 0) {
log(LOG_DEBUG,"connection_package_raw_inbuf(): circuit_deliver_relay_cell (backward) failed. Closing.");
log_fn(LOG_DEBUG,"circuit_deliver_relay_cell (backward) failed. Closing.");
circuit_close(circ);
return 0;
}
......@@ -609,7 +609,7 @@ repeat_connection_package_raw_inbuf:
assert(conn->type == CONN_TYPE_AP);
cell.aci = circ->n_aci;
if(circuit_deliver_relay_cell(&cell, circ, CELL_DIRECTION_OUT, conn->cpath_layer) < 0) {
log(LOG_DEBUG,"connection_package_raw_inbuf(): circuit_deliver_relay_cell (forward) failed. Closing.");
log_fn(LOG_DEBUG,"circuit_deliver_relay_cell (forward) failed. Closing.");
circuit_close(circ);
return 0;
}
......@@ -624,11 +624,10 @@ repeat_connection_package_raw_inbuf:
assert(conn->package_window > 0);
if(--conn->package_window <= 0) { /* is it 0 after decrement? */
connection_stop_reading(conn);
log(LOG_DEBUG,"connection_package_raw_inbuf(): conn->package_window reached 0.");
log_fn(LOG_DEBUG,"conn->package_window reached 0.");
return 0; /* don't process the inbuf any more */
}
log(LOG_DEBUG,"connection_package_raw_inbuf(): conn->package_window is %d",conn->package_window);
log_fn(LOG_DEBUG,"conn->package_window is %d",conn->package_window);
/* handle more if there's more, or return 0 if there isn't */
goto repeat_connection_package_raw_inbuf;
......@@ -644,7 +643,7 @@ int connection_consider_sending_sendme(connection_t *conn, int edge_type) {
circ = circuit_get_by_conn(conn);
if(!circ) {
/* this can legitimately happen if the destroy has already arrived and torn down the circuit */
log(LOG_DEBUG,"connection_consider_sending_sendme(): No circuit associated with conn. Skipping.");
log_fn(LOG_DEBUG,"No circuit associated with conn. Skipping.");
return 0;
}
......@@ -660,10 +659,10 @@ int connection_consider_sending_sendme(connection_t *conn, int edge_type) {
cell.aci = circ->n_aci;
while(conn->deliver_window < STREAMWINDOW_START - STREAMWINDOW_INCREMENT) {
log(LOG_DEBUG,"connection_consider_sending_sendme(): Outbuf %d, Queueing stream sendme.", conn->outbuf_flushlen);
log_fn(LOG_DEBUG,"Outbuf %d, Queueing stream sendme.", conn->outbuf_flushlen);
conn->deliver_window += STREAMWINDOW_INCREMENT;
if(circuit_deliver_relay_cell(&cell, circ, CELL_DIRECTION(edge_type), conn->cpath_layer) < 0) {
log(LOG_DEBUG,"connection_consider_sending_sendme(): circuit_deliver_relay_cell failed. Closing.");
log_fn(LOG_DEBUG,"circuit_deliver_relay_cell failed. Closing.");
circuit_close(circ);
return 0;
}
......@@ -676,7 +675,7 @@ int connection_finished_flushing(connection_t *conn) {
assert(conn);
// log(LOG_DEBUG,"connection_finished_flushing() entered. Socket %u.", conn->s);
// log_fn(LOG_DEBUG,"entered. Socket %u.", conn->s);
switch(conn->type) {
case CONN_TYPE_OR:
......@@ -689,7 +688,7 @@ int connection_finished_flushing(connection_t *conn) {
case CONN_TYPE_DNSWORKER:
return connection_dns_finished_flushing(conn);
default:
log(LOG_DEBUG,"connection_finished_flushing() got unexpected conn->type.");
log_fn(LOG_DEBUG,"got unexpected conn->type.");
return -1;
}
}
......@@ -719,10 +718,10 @@ int connection_process_cell_from_inbuf(connection_t *conn) {
#endif
/* decrypt */
if(crypto_cipher_decrypt(conn->b_crypto,crypted,CELL_NETWORK_SIZE,outbuf)) {
log(LOG_ERR,"connection_process_cell_from_inbuf(): Decryption failed, dropping.");
log_fn(LOG_ERR,"Decryption failed, dropping.");
return connection_process_inbuf(conn); /* process the remainder of the buffer */
}
// log(LOG_DEBUG,"connection_process_cell_from_inbuf(): Cell decrypted (%d bytes).",outlen);
// log_fn(LOG_DEBUG,"Cell decrypted (%d bytes).",outlen);
#if 0
printf("Cell header plaintext: ");
for(x=0;x<8;x++) {
......@@ -734,7 +733,7 @@ int connection_process_cell_from_inbuf(connection_t *conn) {
/* retrieve cell info from outbuf (create the host-order struct from the network-order string) */
cell_unpack(&cell, outbuf);
// log(LOG_DEBUG,"connection_process_cell_from_inbuf(): Decrypted cell is of type %u (ACI %u).",cellp->command,cellp->aci);
// log_fn(LOG_DEBUG,"Decrypted cell is of type %u (ACI %u).",cellp->command,cellp->aci);
command_process_cell(&cell, conn);
return connection_process_inbuf(conn); /* process the remainder of the buffer */
......
......@@ -12,7 +12,7 @@ int ap_handshake_process_socks(connection_t *conn) {
assert(conn);
log(LOG_DEBUG,"ap_handshake_process_socks() entered.");
log_fn(LOG_DEBUG,"entered.");
if(!conn->socks_version) { /* try to pull it in */
......@@ -22,38 +22,38 @@ int ap_handshake_process_socks(connection_t *conn) {
if(connection_fetch_from_buf((char *)&socks4_info,sizeof(socks4_t),conn) < 0)
return -1;
log(LOG_DEBUG,"ap_handshake_process_socks(): Successfully read socks info.");
log_fn(LOG_DEBUG,"Successfully read socks info.");
if(socks4_info.version != 4) {
log(LOG_NOTICE,"ap_handshake_process_socks(): Unrecognized version %d.",socks4_info.version);
log_fn(LOG_NOTICE,"Unrecognized version %d.",socks4_info.version);
ap_handshake_socks_reply(conn, SOCKS4_REQUEST_REJECT);
return -1;
}
conn->socks_version = socks4_info.version;
if(socks4_info.command != 1) { /* not a connect? we don't support it. */
log(LOG_NOTICE,"ap_handshake_process_socks(): command %d not '1'.",socks4_info.command);
log_fn(LOG_NOTICE,"command %d not '1'.",socks4_info.command);
ap_handshake_socks_reply(conn, SOCKS4_REQUEST_REJECT);
return -1;
}
conn->dest_port = ntohs(*(uint16_t*)&socks4_info.destport);
if(!conn->dest_port) {
log(LOG_NOTICE,"ap_handshake_process_socks(): Port is zero.");
log_fn(LOG_NOTICE,"Port is zero.");
ap_handshake_socks_reply(conn, SOCKS4_REQUEST_REJECT);
return -1;
}
log(LOG_NOTICE,"ap_handshake_process_socks(): Dest port is %d.",conn->dest_port);
log_fn(LOG_NOTICE,"Dest port is %d.",conn->dest_port);
if(socks4_info.destip[0] ||
socks4_info.destip[1] ||
socks4_info.destip[2] ||
!socks4_info.destip[3]) { /* not 0.0.0.x */
log(LOG_NOTICE,"ap_handshake_process_socks(): destip not in form 0.0.0.x.");
log_fn(LOG_NOTICE,"destip not in form 0.0.0.x.");
sprintf(tmpbuf, "%d.%d.%d.%d", socks4_info.destip[0],
socks4_info.destip[1], socks4_info.destip[2], socks4_info.destip[3]);
conn->dest_addr = strdup(tmpbuf);
log(LOG_DEBUG,"ap_handshake_process_socks(): Successfully read destip (%s)", conn->dest_addr);
log_fn(LOG_DEBUG,"Successfully read destip (%s)", conn->dest_addr);
}
}
......@@ -63,14 +63,14 @@ int ap_handshake_process_socks(connection_t *conn) {
if(amt < 0) /* not there yet */
return 0;
if(amt > 500) {
log(LOG_NOTICE,"ap_handshake_process_socks(): username too long.");
log_fn(LOG_NOTICE,"username too long.");
ap_handshake_socks_reply(conn, SOCKS4_REQUEST_REJECT);
return -1;
}
if(connection_fetch_from_buf(tmpbuf,amt,conn) < 0)
return -1;
conn->read_username = 1;
log(LOG_DEBUG,"ap_handshake_process_socks(): Successfully read username.");
log_fn(LOG_DEBUG,"Successfully read username.");
}
if(!conn->dest_addr) { /* no dest_addr found yet */
......@@ -78,7 +78,7 @@ int ap_handshake_process_socks(connection_t *conn) {
if(amt < 0) /* not there yet */
return 0;
if(amt > 500) {
log(LOG_NOTICE,"ap_handshake_process_socks(): dest_addr too long.");
log_fn(LOG_NOTICE,"dest_addr too long.");
ap_handshake_socks_reply(conn, SOCKS4_REQUEST_REJECT);
return -1;
}
......@@ -86,7 +86,7 @@ int ap_handshake_process_socks(connection_t *conn) {
return -1;
conn->dest_addr = strdup(tmpbuf);
log(LOG_NOTICE,"ap_handshake_process_socks(): successfully read dest addr '%s'",
log_fn(LOG_NOTICE,"successfully read dest addr '%s'",
conn->dest_addr);
}
......@@ -94,14 +94,14 @@ int ap_handshake_process_socks(connection_t *conn) {
circ = circuit_get_newest_ap();
if(!circ) {
log(LOG_INFO,"ap_handshake_process_socks(): No circuit ready. Closing.");
log_fn(LOG_INFO,"No circuit ready. Closing.");
return -1;
}
circ->dirty = 1;