[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] better interface for connection_ap_handshake_socks_reply()



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	config.c connection.c connection_edge.c main.c 
Log Message:
better interface for connection_ap_handshake_socks_reply()
make --list-fingerprint print the fingerprint again


Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -d -r1.198 -r1.199
--- config.c	3 Nov 2004 19:49:03 -0000	1.198
+++ config.c	3 Nov 2004 23:13:28 -0000	1.199
@@ -430,6 +430,7 @@
     default:
       tor_free(result->key);
       tor_free(result);
+      log_fn(LOG_WARN,"Bug: unknown type %d for known key %s", var->type, key);
       return NULL;
     }
 
@@ -1032,7 +1033,7 @@
   }
 
   if (options->AccountingStart < 0 || options->AccountingStart > 31) {
-    log(LOG_WARN,"Monthy accounting must start on a day of the month, and no months have %d days.",
+    log(LOG_WARN,"Monthly accounting must start on a day of the month, and no months have %d days.",
         options->AccountingStart);
     result = -1;
   } else if (options->AccountingStart > 28) {

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.279
retrieving revision 1.280
diff -u -d -r1.279 -r1.280
--- connection.c	3 Nov 2004 18:33:06 -0000	1.279
+++ connection.c	3 Nov 2004 23:13:28 -0000	1.280
@@ -212,7 +212,7 @@
     case CONN_TYPE_AP:
       if (conn->socks_request->has_finished == 0) {
         log_fn(LOG_INFO,"Cleaning up AP -- sending socks reject.");
-        connection_ap_handshake_socks_reply(conn, NULL, 0, 0);
+        connection_ap_handshake_socks_reply(conn, NULL, 0, -1);
         conn->socks_request->has_finished = 1;
         conn->hold_open_until_flushed = 1;
       } else {

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -d -r1.223 -r1.224
--- connection_edge.c	3 Nov 2004 18:33:07 -0000	1.223
+++ connection_edge.c	3 Nov 2004 23:13:28 -0000	1.224
@@ -365,7 +365,7 @@
       connection_ap_handshake_socks_reply(conn, socks->reply, socks->replylen, 0);
     } else if(sockshere == -1) { /* send normal reject */
       log_fn(LOG_WARN,"Fetching socks handshake failed. Closing.");
-      connection_ap_handshake_socks_reply(conn, NULL, 0, 0);
+      connection_ap_handshake_socks_reply(conn, NULL, 0, -1);
     } else {
       log_fn(LOG_DEBUG,"socks handshake not all here yet.");
     }
@@ -675,35 +675,39 @@
     }
   }
   connection_ap_handshake_socks_reply(conn, buf, replylen,
-                                      answer_type == RESOLVED_TYPE_IPV4 ||
-                                      answer_type == RESOLVED_TYPE_IPV6);
+                                      (answer_type == RESOLVED_TYPE_IPV4 ||
+                                      answer_type == RESOLVED_TYPE_IPV6) ? 1 : -1);
 }
 
 /** Send a socks reply to stream <b>conn</b>, using the appropriate
  * socks version, etc.
  *
+ * Status can be 1 (succeeded), -1 (failed), or 0 (not sure yet).
+ *
  * If <b>reply</b> is defined, then write <b>replylen</b> bytes of it
- * to conn and return.
+ * to conn and return, else reply based on <b>status</b>.
  *
- * Otherwise, send back a reply based on whether <b>success</b> is 1 or 0.
+ * If <b>reply</b> is undefined, <b>status</b> can't be 0.
  */
 void connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
-                                         size_t replylen, int success) {
+                                         size_t replylen, int status) {
   char buf[256];
 
-  control_event_stream_status(conn,
-                       success ? STREAM_EVENT_SUCCEEDED : STREAM_EVENT_FAILED);
+  if(status) /* it's either 1 or -1 */
+    control_event_stream_status(conn,
+                       status==1 ? STREAM_EVENT_SUCCEEDED : STREAM_EVENT_FAILED);
 
   if(replylen) { /* we already have a reply in mind */
     connection_write_to_buf(reply, replylen, conn);
     return;
   }
   tor_assert(conn->socks_request);
+  tor_assert(status == 1 || status == -1);
   if(conn->socks_request->socks_version == 4) {
     memset(buf,0,SOCKS4_NETWORK_LEN);
 #define SOCKS4_GRANTED          90
 #define SOCKS4_REJECT           91
-    buf[1] = (success ? SOCKS4_GRANTED : SOCKS4_REJECT);
+    buf[1] = (status==1 ? SOCKS4_GRANTED : SOCKS4_REJECT);
     /* leave version, destport, destip zero */
     connection_write_to_buf(buf, SOCKS4_NETWORK_LEN, conn);
   }
@@ -711,7 +715,7 @@
     buf[0] = 5; /* version 5 */
 #define SOCKS5_SUCCESS          0
 #define SOCKS5_GENERIC_ERROR    1
-    buf[1] = success ? SOCKS5_SUCCESS : SOCKS5_GENERIC_ERROR;
+    buf[1] = status==1 ? SOCKS5_SUCCESS : SOCKS5_GENERIC_ERROR;
     buf[2] = 0;
     buf[3] = 1; /* ipv4 addr */
     memset(buf+4,0,6); /* Set external addr/port to 0.

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.352
retrieving revision 1.353
diff -u -d -r1.352 -r1.353
--- main.c	3 Nov 2004 19:49:03 -0000	1.352
+++ main.c	3 Nov 2004 23:13:28 -0000	1.353
@@ -1371,6 +1371,8 @@
     log_fn(LOG_ERR, "Error computing fingerprint");
     return;
   }
+  /*XXX is options.Nickname for-sure defined yet here? */
+  printf("%s %s\n", options.Nickname, buf);
 }
 
 /** DOCDOC **/