[or-cvs] add a RESETCONF controller command, and make setconf with a...

arma at seul.org arma at seul.org
Thu Sep 8 03:18:53 UTC 2005


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

Modified Files:
	control.c 
Log Message:
add a RESETCONF controller command, and make setconf with a null
option actually mean to set it to ""


Index: control.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- control.c	24 Aug 2005 02:20:31 -0000	1.125
+++ control.c	8 Sep 2005 03:18:51 -0000	1.126
@@ -143,6 +143,8 @@
   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 @@
   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 @@
     }
   }
 
-  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 @@
   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 @@
   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;



More information about the tor-commits mailing list