|
@@ -10,6 +10,7 @@
|
|
|
**/
|
|
|
|
|
|
#define CONFIG_PRIVATE
|
|
|
+#define CONTROL_PRIVATE
|
|
|
|
|
|
#include "or.h"
|
|
|
#include "circuitbuild.h"
|
|
@@ -693,6 +694,10 @@ get_options(void)
|
|
|
int
|
|
|
set_options(or_options_t *new_val, char **msg)
|
|
|
{
|
|
|
+ int i;
|
|
|
+ char *result;
|
|
|
+ smartlist_t *elements;
|
|
|
+ config_line_t *line;
|
|
|
or_options_t *old_options = global_options;
|
|
|
global_options = new_val;
|
|
|
/* Note that we pass the *old* options below, for comparison. It
|
|
@@ -707,7 +712,35 @@ set_options(or_options_t *new_val, char **msg)
|
|
|
"Acting on config options left us in a broken state. Dying.");
|
|
|
exit(1);
|
|
|
}
|
|
|
-
|
|
|
+ /* Issues a CONF_CHANGED event to notify controller of the change. If Tor is
|
|
|
+ * just starting up then the old_options will be undefined. */
|
|
|
+ if (old_options) {
|
|
|
+ elements = smartlist_create();
|
|
|
+ for (i=0; options_format.vars[i].name; ++i) {
|
|
|
+ if (!option_is_same(&options_format, new_val, old_options,
|
|
|
+ options_format.vars[i].name)) {
|
|
|
+ line = get_assigned_option(&options_format, new_val,
|
|
|
+ options_format.vars[i].name, 0);
|
|
|
+
|
|
|
+ if (line) {
|
|
|
+ for (; line; line = line->next) {
|
|
|
+ char *tmp;
|
|
|
+ tor_asprintf(&tmp, "650-%s=%s", line->key, line->value);
|
|
|
+ smartlist_add(elements, tmp);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ char *tmp;
|
|
|
+ tor_asprintf(&tmp, "650-%s", options_format.vars[i].name);
|
|
|
+ smartlist_add(elements, tmp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result = smartlist_join_strings(elements, "\r\n", 0, NULL);
|
|
|
+ control_event_conf_changed(result);
|
|
|
+ tor_free(result);
|
|
|
+ SMARTLIST_FOREACH(elements, char *, cp, tor_free(cp));
|
|
|
+ smartlist_free(elements);
|
|
|
+ }
|
|
|
config_free(&options_format, old_options);
|
|
|
|
|
|
return 0;
|