summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2005-09-08 03:18:51 +0000
committerRoger Dingledine <arma@torproject.org>2005-09-08 03:18:51 +0000
commit08348ae66e2f37dafbe5eb0ed3acb501739f19c5 (patch)
treef89301b695b5a573ef343c5b21ccaf441ee404a3 /src
parent0a8a8ba54656a380e7e7f7400b23b588c08da02c (diff)
downloadtor-08348ae66e2f37dafbe5eb0ed3acb501739f19c5.tar.gz
tor-08348ae66e2f37dafbe5eb0ed3acb501739f19c5.zip
add a RESETCONF controller command, and make setconf with a null
option actually mean to set it to "" svn:r4916
Diffstat (limited to 'src')
-rw-r--r--src/or/control.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 040c23a5b1..e4e4eaab40 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -143,6 +143,8 @@ static void send_control1_event(uint16_t event, const char *format, ...)
CHECK_PRINTF(2,3);
static int handle_control_setconf(connection_t *conn, uint32_t len,
char *body);
+static int handle_control_resetconf(connection_t *conn, uint32_t len,
+ char *body);
static int handle_control_getconf(connection_t *conn, uint32_t len,
const char *body);
static int handle_control_setevents(connection_t *conn, uint32_t len,
@@ -602,10 +604,11 @@ get_stream(const char *id)
return conn;
}
-/** Called when we receive a SETCONF message: parse the body and try
- * to update our configuration. Reply with a DONE or ERROR message. */
+/** Helper for setconf and resetconf. Acts like setconf, except
+ * it passes <b>reset</b> on to options_trial_assign().
+ */
static int
-handle_control_setconf(connection_t *conn, uint32_t len, char *body)
+control_setconf_helper(connection_t *conn, uint32_t len, char *body, int reset)
{
int r;
config_line_t *lines=NULL;
@@ -663,7 +666,7 @@ handle_control_setconf(connection_t *conn, uint32_t len, char *body)
}
}
- if ((r=options_trial_assign(lines, 1)) < 0) {
+ if ((r=options_trial_assign(lines, reset)) < 0) {
log_fn(LOG_WARN,"Controller gave us config lines that didn't validate.");
if (r==-1) {
if (v0)
@@ -685,6 +688,24 @@ handle_control_setconf(connection_t *conn, uint32_t len, char *body)
return 0;
}
+/** Called when we receive a SETCONF message: parse the body and try
+ * to update our configuration. Reply with a DONE or ERROR message. */
+static int
+handle_control_setconf(connection_t *conn, uint32_t len, char *body)
+{
+ return control_setconf_helper(conn, len, body, 0);
+}
+
+/** Called when we receive a RESETCONF message: parse the body and try
+ * to update our configuration. Reply with a DONE or ERROR message. */
+static int
+handle_control_resetconf(connection_t *conn, uint32_t len, char *body)
+{
+ int v0 = STATE_IS_V0(conn->state);
+ tor_assert(!v0);
+ return control_setconf_helper(conn, len, body, 1);
+}
+
/** Called when we receive a GETCONF message. Parse the request, and
* reply with a CONFVALUE or an ERROR message */
static int
@@ -1979,6 +2000,9 @@ connection_control_process_inbuf_v1(connection_t *conn)
if (!strcasecmp(conn->incoming_cmd, "SETCONF")) {
if (handle_control_setconf(conn, data_len, args))
return -1;
+ } else if (!strcasecmp(conn->incoming_cmd, "RESETCONF")) {
+ if (handle_control_resetconf(conn, data_len, args))
+ return -1;
} else if (!strcasecmp(conn->incoming_cmd, "GETCONF")) {
if (handle_control_getconf(conn, data_len, args))
return -1;