remove retired hosters: carnet, freenet, helsinki, linaro, ugent, uni-karlsruhe,...
[mirror/dsa-puppet.git] / modules / debian_org / lib / facter / onion-services.rb
1 begin
2     require 'json'
3
4     Facter.add("onion_tor_service_hostname") do
5         services = {}
6
7         Dir['/var/lib/tor/onion/*/hostname'].each do |p|
8             dir = File.dirname(p)
9             service = File.basename(dir)
10             hostname = IO.read(p).chomp
11             services[service] = hostname
12         end
13         setcode do
14             services.to_json
15         end
16     end
17
18     Facter.add("onion_balance_service_hostname") do
19         services = {}
20
21         Dir['/etc/onionbalance/private_keys/*.key'].each do |p|
22             service = File.basename(p, '.key')
23             begin
24                 services[service] = IO.popen(['/usr/local/bin/tor-onion-name', p]).read.chomp
25             rescue Errno::ENOENT
26             end
27         end
28         setcode do
29             services.to_json
30         end
31     end
32
33
34 rescue Exception => e
35 end