diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2011-03-09 11:34:04 +0100 |
---|---|---|
committer | Sebastian Hahn <sebastian@torproject.org> | 2011-03-11 18:44:35 +0100 |
commit | f7a3cdc8f27c2306cf06d742af63846c82ebdc56 (patch) | |
tree | 7b276a43f4ea8ce0baf8e111523125333fd71e6f /src/or/rephist.c | |
parent | 48c4d532814ae4fdbf07635e57911bdf0e962b75 (diff) | |
download | tor-f7a3cdc8f27c2306cf06d742af63846c82ebdc56.tar.gz tor-f7a3cdc8f27c2306cf06d742af63846c82ebdc56.zip |
Use observed instead of declared uptime for HSDir
It is important to verify the uptime claim of a relay instead of just
trusting it, otherwise it becomes too easy to blackhole a specific
hidden service. rephist already has data available that we can use here.
Bugfix on 0.2.0.10-alpha.
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index 53214d61ef..69001de839 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -528,6 +528,20 @@ get_weighted_fractional_uptime(or_history_t *hist, time_t when) return ((double) up) / total; } +/** Return how long the router whose identity digest is <b>id</b> has + * been reachable. Return 0 if the router is unknown or currently deemed + * unreachable. */ +long +rep_hist_get_uptime(const char *id, time_t when) +{ + or_history_t *hist = get_or_history(id); + if (!hist) + return 0; + if (!hist->start_of_run) + return 0; + return when - hist->start_of_run; +} + /** Return an estimated MTBF for the router whose identity digest is * <b>id</b>. Return 0 if the router is unknown. */ double |