Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (58 sloc) 2.6 KB
# Author: Robert Annessi <robert.annessi@nt.tuwien.ac.at>
# License: GPLv2 (2013-2015)
diff -urN tor-0.2.3.25/src/or/circuitbuild.c tor-0.2.3.25-dumpguards/src/or/circuitbuild.c
--- tor-0.2.3.25/src/or/circuitbuild.c 2012-11-19 22:24:38.000000000 +0100
+++ tor-0.2.3.25-dumpguards/src/or/circuitbuild.c 2013-10-21 15:07:53.080658547 +0200
@@ -4381,6 +4381,25 @@
return changed ? 1 : 0;
}
+/** Remove all currently listed entry guards. So new ones will be chosen. */
+void
+remove_all_entry_guards(void)
+{
+ char dbuf[HEX_DIGEST_LEN+1];
+
+ while (smartlist_len(entry_guards)) {
+ entry_guard_t *entry = smartlist_get(entry_guards, 0);
+ base16_encode(dbuf, sizeof(dbuf), entry->identity, DIGEST_LEN);
+ log_info(LD_CIRC, "Entry guard '%s' (%s) has been dropped.",
+ entry->nickname, dbuf);
+ control_event_guard(entry->nickname, entry->identity, "DROPPED");
+ entry_guard_free(entry);
+ smartlist_del(entry_guards, 0);
+ log_entry_guards(LOG_INFO);
+ entry_guards_changed();
+ }
+}
+
/** A new directory or router-status has arrived; update the down/listed
* status of the entry guards.
*
diff -urN tor-0.2.3.25/src/or/circuitbuild.h tor-0.2.3.25-dumpguards/src/or/circuitbuild.h
--- tor-0.2.3.25/src/or/circuitbuild.h 2012-11-19 22:24:38.000000000 +0100
+++ tor-0.2.3.25-dumpguards/src/or/circuitbuild.h 2013-10-21 14:46:27.570148797 +0200
@@ -68,6 +68,8 @@
const node_t *build_state_get_exit_node(cpath_build_state_t *state);
const char *build_state_get_exit_nickname(cpath_build_state_t *state);
+void remove_all_entry_guards(void);
+
void entry_guards_compute_status(const or_options_t *options, time_t now);
int entry_guard_register_connect_status(const char *digest, int succeeded,
int mark_relay_status, time_t now);
diff -urN tor-0.2.3.25/src/or/control.c tor-0.2.3.25-dumpguards/src/or/control.c
--- tor-0.2.3.25/src/or/control.c 2012-11-19 22:24:38.000000000 +0100
+++ tor-0.2.3.25-dumpguards/src/or/control.c 2013-10-21 17:46:41.630664869 +0200
@@ -3436,6 +3436,13 @@
} else if (!strcasecmp(conn->incoming_cmd, "AUTHCHALLENGE")) {
if (handle_control_authchallenge(conn, cmd_data_len, args))
return -1;
+ } else if (!strcasecmp(conn->incoming_cmd, "DUMPGUARDS")) {
+ if (conn->incoming_cmd_cur_len > strlen("DUMPGUARDS")+2)
+ connection_printf_to_buf(conn, "512 Too many arguments to DUMPGUARDS\r\n");
+ else {
+ remove_all_entry_guards();
+ send_control_done(conn);
+ }
} else {
connection_printf_to_buf(conn, "510 Unrecognized command \"%s\"\r\n",
conn->incoming_cmd);