summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-11-03 23:13:28 +0000
committerRoger Dingledine <arma@torproject.org>2004-11-03 23:13:28 +0000
commita4753283dd95a6399f65f8f439bad525702a08fc (patch)
treeec682e32a6971c65e49e36584d934682503aed14
parent5b312541d7d3fa20aca0c07aab5c4341fa779762 (diff)
downloadtor-a4753283dd95a6399f65f8f439bad525702a08fc.tar.gz
tor-a4753283dd95a6399f65f8f439bad525702a08fc.zip
better interface for connection_ap_handshake_socks_reply()
make --list-fingerprint print the fingerprint again svn:r2668
-rw-r--r--src/or/config.c3
-rw-r--r--src/or/connection.c2
-rw-r--r--src/or/connection_edge.c24
-rw-r--r--src/or/main.c2
4 files changed, 19 insertions, 12 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 7af93ff65a..6dadda1c48 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -430,6 +430,7 @@ config_get_assigned_option(or_options_t *options, const char *key)
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 @@ getconfig(int argc, char **argv, or_options_t *options)
}
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) {
diff --git a/src/or/connection.c b/src/or/connection.c
index 7d3b4c43bc..0576069634 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -212,7 +212,7 @@ void connection_about_to_close_connection(connection_t *conn)
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 {
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 51506b3628..5d799c20ee 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -365,7 +365,7 @@ static int connection_ap_handshake_process_socks(connection_t *conn) {
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 @@ void connection_ap_handshake_socks_resolved(connection_t *conn,
}
}
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 @@ void connection_ap_handshake_socks_reply(connection_t *conn, char *reply,
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.
diff --git a/src/or/main.c b/src/or/main.c
index 87e729beac..7e3470766a 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1371,6 +1371,8 @@ static void do_list_fingerprint(void)
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 **/