/
name.rb
61 lines (60 loc) · 3.91 KB
/
name.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class Name
def initialize
@aliases = {
:akami => { :name => 'Akamai Technologies, Inc.', :dba => ['akam.net', 'akamai technologies'] },
:amazon => { :name => 'Amazon.com, Inc.', :dba => ['amazon.com', 'amazon.com, inc.'] },
:comodo => { :name => 'Comodo Group', :dba => ['comodo ca limited','the usertrust network'] },
:csc => { :name => 'Corporation Service Company', :dba => ['csc corporate domains, inc.'] },
:digicert => { :name => 'DigiCert, Inc.', :dba => ['digicert inc'] },
:dyn_inc => { :name => 'Dynamic Network Services, Inc.', :dba => ['mailhop.org', 'mydyndns.org','dynect.net'] },
:easydns => { :name => 'easyDNS Technologies, Inc.', :dba => ['easydns technologies, inc.', 'easydns.com', 'easydns.net', 'easydns.org'] },
:enom => { :name => 'eNom, Inc.', :dba => ['emailsrvr.com', 'enom, inc.', 'enom, incorporated', 'messagingengine.com', 'name-services.com', 'registrar-servers.com'] },
:equifax => { :name => 'Equifax, Inc.', :dba => ['equifax secure inc.','equifax'] },
:gandi => { :name => 'Gandi SAS', :dba => ['gandi sas', 'gandi.net', 'dns.gandi.net'] },
:godaddy => { :name => 'Go Daddy', :dba => ['domaincontrol.com', 'godaddy.com', 'godaddy.com, inc.', 'secureserver.net', 'wild west domains, inc.'] },
:google => { :name => 'Google, Inc.', :dba => ['aspmx.l.google.com', 'google.com', 'googlemail.com', 'l.google.com','google'] },
:markmonitor => { :name => 'MarkMonitor, Inc.', :dba => ['markmonitor inc.'] },
:microsoft => { :name => 'Microsoft Corporation', :dba => ['msft.net'] },
:netsol => { :name => 'Network Solutions, LLC', :dba => ['network solutions, llc.','network solutions llc'] },
:oneandone => { :name => '1 & 1 Internet, Inc.', :dba => ['1 & 1 internet ag','1and1.com'] },
:pair => { :name => 'pair Networks, Inc.', :dba => ['pair networks', 'pair.com'] },
:postini => { :name => 'Google, Inc. (Postini)', :dba => ['psmtp.com'] },
:rackspace => { :name => 'Rackspace, Inc.', :dba => ['rackspace.com','rackspace.com, ltd.'] },
:serverbeach => { :name => 'ServerBeach', :dba => ['serverbeach'] },
:slicehost => { :name => 'Slicehost LLC', :dba => ['slicehost llc', 'slicehost.net'] },
:softlayer => { :name => 'SoftLayer Technologies, Inc.', :dba => ['softlayer corporate c', 'softlayer technologies inc.', 'softlayer technologies', 'softlayer.com'] },
:thawte => { :name => 'thawte, Inc.', :dba => ['thawte consulting cc','thawte consulting (pty) ltd.'] },
:theplanet => { :name => 'The Planet Internet Services, Inc.', :dba => ['theplanet.com internet services','theplanet.com internet services, inc.'] },
:tucows => { :name => 'Tucows, Inc.', :dba => ['tucows inc.'] },
:ultradns => { :name => 'Neustar, Inc. (UltraDNS)', :dba => ['ultradns.info', 'ultradns.net', 'ultradns.org','ultradns.co.uk'] },
:verisign => { :name => 'VeriSign', :dba => ['verisign trust network', 'verisign, inc.'] },
:yahoo => { :name => 'Yahoo! Inc.', :dba => ['yahoo.com','inktomi corporation'] },
}
@lookup = {}
@aliases.keys.each {|shortname|
@aliases[shortname][:dba].each {|dba|
@lookup[dba] = shortname
}
}
end
def shorten(input)
return input unless input.is_a? String
return input unless input.match('.')
host = input.split('.')
return "#{host[-2]}.#{host[-1]}" if host[-1].match(/(com|net|org)/)
host.shift if host.size > 2
host.join('.')
end
def simplify(input,match=nil)
return input unless input.is_a? String
return :self if (match and simplify(input) == simplify(match))
return @lookup[input.downcase] if @lookup[input.downcase]
return :self if (match and simplify(input).gsub(/\W/,'').downcase.include? match.split(/\./)[-2])
input
end
def full(shortname)
return shortname unless shortname.is_a? Symbol
return shortname unless @aliases[shortname].is_a? Hash
@aliases[shortname][:name]
end
end