We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 01e059f + a3c6fed commit 4ad7d46Copy full SHA for 4ad7d46
tools/dnsquery.rb
@@ -0,0 +1,33 @@
1
+#!/usr/bin/env ruby
2
+require 'domainatrix'
3
+
4
+def get_ip_of_host(host)
5
+ require 'socket'
6
+ ip = Socket.getaddrinfo(host, nil)
7
+ return nil if !ip || !ip[0] || !ip[0][2]
8
+ ip[0][2]
9
+rescue => e
10
+ nil
11
+end
12
13
+def get_root_of_host(host)
14
+ begin
15
+ url = Domainatrix.parse(host)
16
+ if url.domain && url.public_suffix
17
+ return url.domain+'.'+url.public_suffix
18
+ end
19
+ rescue => e
20
+ return nil
21
22
23
24
+STDOUT.sync = true
25
+while host = gets
26
+ host = host.strip
27
+ break unless host && host.size>1
28
+ ip = get_ip_of_host(host)
29
+ next unless ip
30
+ rootdomain = get_root_of_host(host)
31
+ #break unless rootdomain
32
+ puts host+"\t"+rootdomain+"\t"+ip
33
0 commit comments