diff options
author | Peter Palfrader <peter@palfrader.org> | 2009-09-21 13:14:39 +0200 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2009-09-21 13:14:39 +0200 |
commit | a9c45754e0e587dda4e16f888a1662eddf90b1f5 (patch) | |
tree | cc5b7aa467419ae63f394e9e3929c38eac316915 /contrib/auto-naming/process-consensus | |
parent | b440a4d9369c4a6c4501b289f2e6ff089ba9a519 (diff) | |
parent | 54ba86d9d0cff2ceef75d564ece3d7d2ea26af26 (diff) | |
download | tor-a9c45754e0e587dda4e16f888a1662eddf90b1f5.tar tor-a9c45754e0e587dda4e16f888a1662eddf90b1f5.tar.gz |
Merge commit 'tor-0.2.2.2-alpha' into debian-merge
* commit 'tor-0.2.2.2-alpha': (94 commits)
downgrade a log severity, since this event has been known
Update to the "September 4 2009" ip-to-country file.
bump to 0.2.2.2-alpha
Revert "Teach connection_ap_can_use_exit about Exclude*Nodes"
fix grammar / add changelog for the torify commit
Fix compile on Snow Leopard
Fix build warnings on OSX 10.5.8
Change the condition on the nonlive timeout counting.
Add a couple of time helper functions.
Fix typos and comments, plus two bugs
Implement and document new network liveness algorithm.
Fix some precision-related asserts in unit tests.
replace contrib/auto-naming with a readme saying where it went
clarify our rules for assigning the Named flag
disable the end of circuitbuildtimeout units tests
draw in a lot of 0.2.1.20 changelog items into 0.2.2.2-alpha
Fix compile on freebsd
Let our config abbreviations rewrite more than once
a mish-mash of stuff in my sandbox
give proposal 151 a changelog and other touchups
...
Diffstat (limited to 'contrib/auto-naming/process-consensus')
-rwxr-xr-x | contrib/auto-naming/process-consensus | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/contrib/auto-naming/process-consensus b/contrib/auto-naming/process-consensus deleted file mode 100755 index dc9d207e4..000000000 --- a/contrib/auto-naming/process-consensus +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/ruby - -# process-consensus - read a current consensus document, inserting the -# information into a database then calling -# update-named-status.rb to update the name-binding -# flags -# -# Copyright (c) 2007 Peter Palfrader -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require "yaml" - -require 'db' -require 'db-config' -require 'update-named-status' - -$db = Db.new($CONFIG['database']['dbhost'], $CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password']) - -$router_cache = {} -$nickname_cache = {} - -def parse_consensus consensus - ts = nil - routers = [] - consensus.each do |line| - (key, value) = line.split(' ',2) - case key - when "valid-after", "published": ts = DateTime.parse(value) - when "r": - (nick, fpr, _) = value.split(' ', 3) - nick.downcase! - next if nick == 'unnamed' - routers << { - 'nick' => nick, - 'fingerprint' => (fpr+'=').unpack('m').first.unpack('H*').first - } - end - end - throw "Did not find a timestamp" unless ts - throw "Did not find any routers" unless routers.size > 0 - return ts, routers -end - -def insert_routers_into_db(router, table, field, value) - pk = table+'_id' - row = $db.query_row("SELECT #{pk} FROM #{table} WHERE #{field}=?", value) - if row - return row[pk] - else - r = { field => value } - $db.insert_row( table, r ) - return r[pk] - end -end - -def handle_one_consensus(c) - puts "parsing..." if $verbose - timestamp, routers = parse_consensus c - puts "storing..." if $verbose - - routers.each do |router| - fpr = router['fingerprint'] - nick = router['nick'] - $router_cache[fpr] = router_id = ($router_cache[fpr] or insert_routers_into_db(router, 'router', 'fingerprint', router['fingerprint'])) - $nickname_cache[nick] = nickname_id = ($nickname_cache[nick] or insert_routers_into_db(router, 'nickname', 'nick', router['nick'])) - - row = $db.update( - 'router_claims_nickname', - { 'last_seen' => timestamp.to_s }, - { 'router_id' => router_id, 'nickname_id' => nickname_id} ) - case row - when 0: - $db.insert('router_claims_nickname', - { - 'first_seen' => timestamp.to_s, - 'last_seen' => timestamp.to_s, - 'router_id' => router_id, 'nickname_id' => nickname_id} ) - when 1: - else - throw "Update of router_claims_nickname returned unexpected number of affected rows(#{row})" - end - end -end - -$db.transaction_begin -if ARGV.first == '-v' - $verbose = true - ARGV.shift -end - -if ARGV.size == 0 - handle_one_consensus STDIN.readlines - do_update $verbose -else - ARGV.each do |filename| - puts filename if $verbose - handle_one_consensus File.new(filename).readlines - puts "updating..." if $verbose - do_update $verbose - end -end -$db.transaction_commit |