From 77053147771164dd53c78bef1d27fb2be180eb5d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 10 Jul 2007 17:13:24 +0000 Subject: r13637@catbus: nickm | 2007-07-06 14:24:27 -0400 fix copy-paste error in config message src/or/config.c . Apply initial (but pared-down) version of launch-resolve-via-controller patch from Robert Hogan. svn:r10780 --- src/or/control.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/or/control.c') diff --git a/src/or/control.c b/src/or/control.c index 0fc859ca17..7cbf372be2 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -133,6 +133,8 @@ static int handle_control_closestream(control_connection_t *conn, uint32_t len, static int handle_control_closecircuit(control_connection_t *conn, uint32_t len, const char *body); +static int handle_control_resolve(control_connection_t *conn, uint32_t len, + const char *body); static int handle_control_usefeature(control_connection_t *conn, uint32_t len, const char *body); @@ -894,6 +896,8 @@ handle_control_setevents(control_connection_t *conn, uint32_t len, event_code = EVENT_GUARD; } else if (!strcasecmp(ev, "STREAM_BW")) event_code = EVENT_STREAM_BANDWIDTH_USED; + else if (!strcasecmp(ev, "RESOLVED")) + event_code = EVENT_RESOLVED; else { connection_printf_to_buf(conn, "552 Unrecognized event \"%s\"\r\n", ev); @@ -2212,6 +2216,32 @@ handle_control_closecircuit(control_connection_t *conn, uint32_t len, return 0; } +static int +handle_control_resolve(control_connection_t *conn, uint32_t len, + const char *body) +{ + smartlist_t *args; + (void) len; /* body is nul-terminated; it's safe to ignore the length */ + + if (!(conn->event_mask & EVENT_ADDRMAP)) { + log_warn(LD_CONTROL, "Controller asked us to resolve an address, but " + "isn't listening for ADDRMAP events. It probably won't see " + "the answer."); + } + args = smartlist_create(); + smartlist_split_string(args, body, " ", + SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); + SMARTLIST_FOREACH(args, const char *, arg, { + evdns_server_control(arg); + }); + + SMARTLIST_FOREACH(args, char *, cp, tor_free(cp)); + smartlist_free(args); + + send_control_done(conn); + return 0; +} + /** Called when we get a USEFEATURE command: parse the feature list, and * set up the control_connection's options properly. */ static int @@ -2442,6 +2472,9 @@ connection_control_process_inbuf(control_connection_t *conn) } else if (!strcasecmp(conn->incoming_cmd, "USEFEATURE")) { if (handle_control_usefeature(conn, data_len, args)) return -1; + } else if (!strcasecmp(conn->incoming_cmd, "RESOLVE")) { + if (handle_control_resolve(conn, data_len, args)) + return -1; } else { connection_printf_to_buf(conn, "510 Unrecognized command \"%s\"\r\n", conn->incoming_cmd); -- cgit v1.2.3-54-g00ecf