diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-09-15 22:29:47 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-09-15 22:29:47 +0000 |
commit | 3db8c152878c665823711fb1b8bcb61927014e3e (patch) | |
tree | 768032f988b0cff69fca144887907953097caab5 /src/or/circuituse.c | |
parent | 2bde30efa6027ccc1ff53f784164a5e218fce93b (diff) | |
download | tor-3db8c152878c665823711fb1b8bcb61927014e3e.tar.gz tor-3db8c152878c665823711fb1b8bcb61927014e3e.zip |
Add a circuit_conforms_to_options() function for use in debugging paths [and inother stuff too]. Untested, and so far unused.
svn:r16914
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r-- | src/or/circuituse.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 672c858a7a..2b34f7e6ee 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -212,6 +212,34 @@ circuit_get_best(edge_connection_t *conn, int must_be_open, uint8_t purpose, return best ? TO_ORIGIN_CIRCUIT(best) : NULL; } +/** Check whether, according to the policies in <b>options</b>, the + * circuit <b>circ makes sense. */ +/* XXXX021 currently only checks Exclude{Exit}Nodes. */ +int +circuit_conforms_to_options(const origin_circuit_t *circ, + const or_options_t *options) +{ + const crypt_path_t *cpath, *cpath_next = NULL; + + for (cpath = circ->cpath; cpath && cpath_next != circ->cpath; + cpath = cpath_next) { + cpath_next = cpath->next; + + if (routerset_contains_extendinfo(options->ExcludeNodes, + cpath->extend_info)) + return 0; + + if (cpath->next == circ->cpath) { + /* This is apparently the exit node. */ + + if (routerset_contains_extendinfo(options->ExcludeExitNodes, + cpath->extend_info)) + return 0; + } + } + return 1; +} + /** Close all circuits that start at us, aren't open, and were born * at least CircuitBuildTimeout seconds ago. */ |