Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 108 lines (94 sloc) 3.654 kB
afb4065 @weppos Super simple and super buggy initial version. It works, but sometimes…
authored
1 namespace :server do
2
07cd39b @weppos Refactoring class to use an object oriented server definition. The li…
authored
3 desc "server:convert_file_tlds"
4 task :convert_file_tlds do
404f837 @weppos Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
authored
5 list = parse_list_tld
6 File.open("lib/whois/definitions/tlds.txt", "w+") do |f|
7 f.write(list)
8 end
9 puts "Created file with #{list.size} servers."
10 end
11
12 desc "server:convert_file_ipv4"
13 task :convert_file_ipv4 do
14 list = parse_list_ipv4
15 File.open("lib/whois/definitions/ipv4.txt", "w+") do |f|
16 f.write(list)
17 end
18 puts "Created file with #{list.size} servers."
19 end
20
21 desc "server:convert_file_ipv6"
22 task :convert_file_ipv6 do
23 list = parse_list_ipv6
24 File.open("lib/whois/definitions/ipv6.txt", "w+") do |f|
25 f.write(list)
26 end
27 puts "Created file with #{list.size} servers."
28 end
29
30
31 def parse_list_tld
32 File.readlines("data/tld_serv_list").map do |line|
33 line.chomp!
34 line.gsub!(/^\s*(.*)\s*$/, '\1')
35 line.gsub!(/\s*#.*$/, '')
36 next if line =~ /^$/;
37 abort("format error #{line}") unless line =~ /^([\w\d\.-]+)\s+([\w\d\.:-]+|[A-Z]+\s+.*)$/
38
39 extension, instructions = $1, $2
40 server, options = case instructions
41 when "NONE" then [nil, { :adapter => Whois::Server::Adapters::None }]
42 when "ARPA" then [nil, { :adapter => Whois::Server::Adapters::Arpa }]
43 when /^WEB (.*)$/ then [nil, { :adapter => Whois::Server::Adapters::Web, :web => $1 }]
44 when "CRSNIC" then ["whois.crsnic.net", { :adapter => Whois::Server::Adapters::Verisign }]
45 when "PIR" then ["whois.publicinterestregistry.net", { :adapter => Whois::Server::Adapters::Pir }]
46 when "AFILIAS" then ["whois.afilias-grs.info", { :adapter => Whois::Server::Adapters::Afilias }]
47 when "NICCC" then ["whois.nic.cc", { :adapter => Whois::Server::Adapters::Verisign }]
48 else [instructions]
49 end
50
51 <<-RUBY
52 Whois::Server.define :tld, #{extension.inspect}, \
53 #{server.inspect}\
54 #{options.nil? ? "" : ", " + options.inspect}
55 RUBY
56 end
57 end
58
59 def parse_list_ipv4
60 File.readlines("data/ip_del_list").map do |line|
afb4065 @weppos Super simple and super buggy initial version. It works, but sometimes…
authored
61 line.chomp!
62 line.gsub!(/^\s*(.*)\s*$/, '\1')
63 line.gsub!(/\s*#.*$/, '')
404f837 @weppos Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
authored
64 next if line =~ /^$/;
65 abort("format error #{line}") unless line =~ /^([\d\.]+)\/(\d+)\s+([\w\.]+)$/
66
67 range, server = line.split(/[ \t]/)
68 server, options = case server
69 when /\./ then [server]
70 when "UNALLOCATED" then [nil, { :adapter => Whois::Server::Adapters::None }]
71 else ["whois.#{server}.net"]
72 end
73
74 <<-RUBY
75 Whois::Server.define :ipv6, #{range.inspect}, \
07cd39b @weppos Refactoring class to use an object oriented server definition. The li…
authored
76 #{server.inspect}\
77 #{options.nil? ? "" : ", " + options.inspect}
404f837 @weppos Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
authored
78 RUBY
79 end
80 end
81
82 def parse_list_ipv6
83 File.readlines("data/ip6_del_list").map do |line|
84 line.chomp!
85 line.gsub!(/^\s*(.*)\s*$/, '\1')
86 line.gsub!(/\s*#.*$/, '')
87 next if line =~ /^$/;
88 abort("format error #{line}") unless line =~ %r{^([\da-fA-F]{4}):([\da-fA-F]{1,4})::/(\d+)\s+([\w\.]+)$}
89
90 range = "#{$1}:#{$2}::/#{$3}"
91 server = $4
92 server, options = case server
93 when /\./ then [server]
94 when "UNALLOCATED" then [nil, { :adapter => Whois::Server::Adapters::None }]
95 when "6to4" then ["6to4", { :adapter => Whois::Server::Adapters::NotImplemented }]
96 when "teredo" then ["teredo", { :adapter => Whois::Server::Adapters::NotImplemented }]
97 else ["whois.#{server}.net"]
afb4065 @weppos Super simple and super buggy initial version. It works, but sometimes…
authored
98 end
404f837 @weppos Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
authored
99
100 <<-RUBY
101 Whois::Server.define :ipv6, #{range.inspect}, \
102 #{server.inspect}\
103 #{options.nil? ? "" : ", " + options.inspect}
104 RUBY
07cd39b @weppos Refactoring class to use an object oriented server definition. The li…
authored
105 end
afb4065 @weppos Super simple and super buggy initial version. It works, but sometimes…
authored
106 end
404f837 @weppos Merged branch 'ip.' Added support for IPv4 and IPv6 (closes #265).
authored
107
afb4065 @weppos Super simple and super buggy initial version. It works, but sometimes…
authored
108 end
Something went wrong with that request. Please try again.