aboutsummaryrefslogtreecommitdiff
path: root/src/or/command.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2002-07-02 09:36:58 +0000
committerRoger Dingledine <arma@torproject.org>2002-07-02 09:36:58 +0000
commitd982925593dbb724e4c8ebeb4f945c2184f11831 (patch)
treec3f22938ad261f3c45ed2744ae0950388c1c04e8 /src/or/command.c
parentb34fad4d38ac9c45eb2112fa9dde26e499ccdcc5 (diff)
downloadtor-d982925593dbb724e4c8ebeb4f945c2184f11831.tar.gz
tor-d982925593dbb724e4c8ebeb4f945c2184f11831.zip
Integrated onion proxy into or/
The 'or' process can now be told (by the global_role variable) what roles this server should play -- connect to all ORs, listen for ORs, listen for OPs, listen for APs, or any combination. * everything in /src/op/ is now obsolete. * connection_ap.c now handles all interactions with application proxies * "port" is now or_port, op_port, ap_port. But routers are still always referenced (say, in conn_get_by_addr_port()) by addr / or_port. We should make routers.c actually read these new ports (currently I've kludged it so op_port = or_port+10, ap_port=or_port+20) * circuits currently know if they're at the beginning of the path because circ->cpath is set. They use this instead for crypts (both ways), if it's set. * I still obey the "send a 0 back to the AP when you're ready" protocol, but I think we should phase it out. I can simply not read from the AP socket until I'm ready. I need to do a lot of cleanup work here, but the code appears to work, so now's a good time for a checkin. svn:r22
Diffstat (limited to 'src/or/command.c')
-rw-r--r--src/or/command.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/or/command.c b/src/or/command.c
index fddf5cfea4..6218096773 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -43,7 +43,7 @@ void command_process_create_cell(cell_t *cell, connection_t *conn) {
memcpy((void *)&circ->onionlen,(void *)cell->payload, 4);
circ->onionlen = ntohl(circ->onionlen);
log(LOG_DEBUG,"command_process_create_cell(): Onion length is %u.",circ->onionlen);
- if(circ->onionlen > 50000) { /* too big */
+ if(circ->onionlen > 50000 || circ->onionlen < 1) { /* too big or too small */
log(LOG_DEBUG,"That's ludicrous. Closing.");
circuit_close(circ);
return;
@@ -172,6 +172,10 @@ void command_process_data_cell(cell_t *cell, connection_t *conn) {
log(LOG_DEBUG,"command_process_data_cell(): circuit in open_wait. Dropping data cell.");
return;
}
+ if(circ->state == CIRCUIT_STATE_OR_WAIT) {
+ log(LOG_DEBUG,"command_process_data_cell(): circuit in or_wait. Dropping data cell.");
+ return;
+ }
/* at this point both circ->n_conn and circ->p_conn are guaranteed to be set */
@@ -184,10 +188,18 @@ void command_process_data_cell(cell_t *cell, connection_t *conn) {
}
} else { /* it's an ingoing cell */
cell->aci = circ->p_aci; /* switch it */
- if(circuit_deliver_data_cell(cell, circ, circ->p_conn, 'e') < 0) {
- log(LOG_DEBUG,"command_process_data_cell(): circuit_deliver_data_cell (backward) failed. Closing.");
- circuit_close(circ);
- return;
+ if(circ->p_conn->type == CONN_TYPE_AP) { /* we want to decrypt, not encrypt */
+ if(circuit_deliver_data_cell(cell, circ, circ->p_conn, 'd') < 0) {
+ log(LOG_DEBUG,"command_process_data_cell(): circuit_deliver_data_cell (backward to AP) failed. Closing.");
+ circuit_close(circ);
+ return;
+ }
+ } else {
+ if(circuit_deliver_data_cell(cell, circ, circ->p_conn, 'e') < 0) {
+ log(LOG_DEBUG,"command_process_data_cell(): circuit_deliver_data_cell (backward) failed. Closing.");
+ circuit_close(circ);
+ return;
+ }
}
}
}