build-approved-routers 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/ruby
  2. # build-approved-routers - create a name-binding list for use at a Tor
  3. # directory authority
  4. #
  5. # Copyright (c) 2007 Peter Palfrader
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in
  15. # all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. # SOFTWARE.
  24. require "yaml"
  25. require 'db'
  26. require 'db-config'
  27. verbose = ARGV.first == "-v"
  28. db = Db.new($CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
  29. db.transaction_begin
  30. named = db.query2("
  31. SELECT fingerprint, router_id, nickname_id, nick, first_seen, last_seen
  32. FROM router NATURAL JOIN router_claims_nickname NATURAL JOIN nickname
  33. WHERE named")
  34. while (n=named.next) do
  35. puts "# (r##{n['router_id']},n##{n['nickname_id']}); first_seen: #{n['first_seen']}, last_seen: #{n['last_seen']}"
  36. fpr = n['fingerprint'].split(/(....)/).delete_if{|x| x=="" }.join(' ')
  37. puts "#{n['nick']} #{fpr}"
  38. end
  39. db.transaction_commit