dnsrobot 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +62 -0
  4. data/lib/dnsrobot.rb +191 -0
  5. metadata +51 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 72ebf9c3d281d3fb88a6656aeeaeed5652deeb6e7d929f1e1cb6837413e3d8eb
4
+ data.tar.gz: 7098979fa75119443a1ab655b32051d72defac59d63eaddaa2770b9d8bcefa4f
5
+ SHA512:
6
+ metadata.gz: 4fd11a1e081a23abc91c96be54a492428a610e3e8c5317f3f32b50acee3adf4f455abc44ec771c66175ee5087ce61cb09e43cd77ec4d9fed3e441f45b7da2723
7
+ data.tar.gz: c9ce6d5fee6e00facb84e2f945729655b47f358af9a8f3dabee358d1fee37d28a8ac4a169a76b903cb089e2477b8afd01140bcb8a9ee65c6c250baac6b6997ba
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DNS Robot (dnsrobot.net)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # dnsrobot
2
+
3
+ Ruby client for the [DNS Robot](https://dnsrobot.net) API — 53 free online DNS and network tools.
4
+
5
+ No API key required. Zero external dependencies.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install dnsrobot
11
+ ```
12
+
13
+ Or add to your Gemfile:
14
+
15
+ ```ruby
16
+ gem "dnsrobot"
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```ruby
22
+ require "dnsrobot"
23
+
24
+ dr = DNSRobot.new
25
+
26
+ # DNS lookup
27
+ result = dr.dns_lookup("example.com")
28
+ puts result["resolvedIPs"]
29
+
30
+ # WHOIS lookup
31
+ whois = dr.whois_lookup("example.com")
32
+ puts whois["registrar"]["name"]
33
+
34
+ # SSL certificate check
35
+ ssl = dr.ssl_check("github.com")
36
+ puts "Days left: #{ssl["leafCertificate"]["daysToExpire"]}"
37
+
38
+ # Email authentication
39
+ spf = dr.spf_check("gmail.com")
40
+ puts "SPF Grade: #{spf["grade"]}"
41
+ ```
42
+
43
+ ## Available Methods
44
+
45
+ | Method | Description | Tool Page |
46
+ |--------|-------------|-----------|
47
+ | `dns_lookup(domain)` | DNS record lookup | [DNS Lookup](https://dnsrobot.net/dns-lookup) |
48
+ | `whois_lookup(domain)` | WHOIS registration data | [WHOIS Lookup](https://dnsrobot.net/whois-lookup) |
49
+ | `ssl_check(domain)` | SSL/TLS certificate check | [SSL Checker](https://dnsrobot.net/ssl-checker) |
50
+ | `spf_check(domain)` | SPF record validation | [SPF Checker](https://dnsrobot.net/spf-checker) |
51
+ | `dkim_check(domain)` | DKIM record check | [DKIM Checker](https://dnsrobot.net/dkim-checker) |
52
+ | `dmarc_check(domain)` | DMARC record validation | [DMARC Checker](https://dnsrobot.net/dmarc-checker) |
53
+ | `mx_lookup(domain)` | MX record lookup | [MX Lookup](https://dnsrobot.net/mx-lookup) |
54
+ | `ns_lookup(domain)` | Nameserver lookup | [NS Lookup](https://dnsrobot.net/ns-lookup) |
55
+ | `ip_lookup(ip)` | IP geolocation | [IP Lookup](https://dnsrobot.net/ip-lookup) |
56
+ | `http_headers(url)` | HTTP header analysis | [HTTP Headers](https://dnsrobot.net/http-headers) |
57
+ | `port_check(host, port)` | TCP port check | [Port Checker](https://dnsrobot.net/port-checker) |
58
+
59
+ ## Links
60
+
61
+ - **Homepage**: [dnsrobot.net](https://dnsrobot.net)
62
+ - **All 53 Tools**: [dnsrobot.net/all-tools](https://dnsrobot.net/all-tools)
data/lib/dnsrobot.rb ADDED
@@ -0,0 +1,191 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "uri"
6
+
7
+ # Ruby client for the DNS Robot API (https://dnsrobot.net).
8
+ #
9
+ # Provides access to 11 DNS and network tools including DNS lookups,
10
+ # WHOIS queries, SSL certificate checks, and email authentication
11
+ # validation (SPF, DKIM, DMARC).
12
+ #
13
+ # No API key required. Zero external dependencies.
14
+ #
15
+ # @example
16
+ # dr = DNSRobot.new
17
+ # result = dr.dns_lookup("example.com")
18
+ # puts result["resolvedIPs"]
19
+ #
20
+ # @see https://dnsrobot.net DNS Robot - 53 free online DNS and network tools
21
+ class DNSRobot
22
+ VERSION = "0.1.0"
23
+
24
+ # @param base_url [String] API base URL
25
+ # @param timeout [Integer] HTTP timeout in seconds
26
+ # @param user_agent [String] User-Agent header
27
+ def initialize(base_url: "https://dnsrobot.net/api", timeout: 30, user_agent: nil)
28
+ @base_url = base_url.chomp("/")
29
+ @timeout = timeout
30
+ @user_agent = user_agent || "dnsrobot-ruby/#{VERSION}"
31
+ end
32
+
33
+ # Perform a DNS lookup.
34
+ # @param domain [String] Domain name (required)
35
+ # @param record_type [String] Record type (default: "A")
36
+ # @param dns_server [String] DNS server (default: "8.8.8.8")
37
+ # @return [Hash] Parsed JSON response
38
+ # @see https://dnsrobot.net/dns-lookup
39
+ def dns_lookup(domain, record_type: "A", dns_server: "8.8.8.8")
40
+ raise ArgumentError, "domain is required" if domain.nil? || domain.empty?
41
+
42
+ post("dns-query", {
43
+ domain: domain,
44
+ recordType: record_type,
45
+ dnsServer: dns_server
46
+ })
47
+ end
48
+
49
+ # Retrieve WHOIS registration data.
50
+ # @param domain [String] Domain name (required)
51
+ # @return [Hash] Parsed JSON response
52
+ # @see https://dnsrobot.net/whois-lookup
53
+ def whois_lookup(domain)
54
+ raise ArgumentError, "domain is required" if domain.nil? || domain.empty?
55
+
56
+ post("whois", { domain: domain })
57
+ end
58
+
59
+ # Check SSL/TLS certificate.
60
+ # @param domain [String] Domain name (required)
61
+ # @return [Hash] Parsed JSON response
62
+ # @see https://dnsrobot.net/ssl-checker
63
+ def ssl_check(domain)
64
+ raise ArgumentError, "domain is required" if domain.nil? || domain.empty?
65
+
66
+ post("ssl-certificate", { domain: domain })
67
+ end
68
+
69
+ # Validate SPF record.
70
+ # @param domain [String] Domain name (required)
71
+ # @return [Hash] Parsed JSON response
72
+ # @see https://dnsrobot.net/spf-checker
73
+ def spf_check(domain)
74
+ raise ArgumentError, "domain is required" if domain.nil? || domain.empty?
75
+
76
+ post("spf-checker", { domain: domain })
77
+ end
78
+
79
+ # Check DKIM record.
80
+ # @param domain [String] Domain name (required)
81
+ # @param selector [String, nil] DKIM selector (optional)
82
+ # @return [Hash] Parsed JSON response
83
+ # @see https://dnsrobot.net/dkim-checker
84
+ def dkim_check(domain, selector: nil)
85
+ raise ArgumentError, "domain is required" if domain.nil? || domain.empty?
86
+
87
+ payload = { domain: domain }
88
+ payload[:selector] = selector if selector
89
+ post("dkim-checker", payload)
90
+ end
91
+
92
+ # Validate DMARC record.
93
+ # @param domain [String] Domain name (required)
94
+ # @return [Hash] Parsed JSON response
95
+ # @see https://dnsrobot.net/dmarc-checker
96
+ def dmarc_check(domain)
97
+ raise ArgumentError, "domain is required" if domain.nil? || domain.empty?
98
+
99
+ post("dmarc-checker", { domain: domain })
100
+ end
101
+
102
+ # Retrieve MX records.
103
+ # @param domain [String] Domain name (required)
104
+ # @return [Hash] Parsed JSON response
105
+ # @see https://dnsrobot.net/mx-lookup
106
+ def mx_lookup(domain)
107
+ raise ArgumentError, "domain is required" if domain.nil? || domain.empty?
108
+
109
+ post("mx-lookup", { domain: domain })
110
+ end
111
+
112
+ # Retrieve nameserver records.
113
+ # @param domain [String] Domain name (required)
114
+ # @return [Hash] Parsed JSON response
115
+ # @see https://dnsrobot.net/ns-lookup
116
+ def ns_lookup(domain)
117
+ raise ArgumentError, "domain is required" if domain.nil? || domain.empty?
118
+
119
+ post("ns-lookup", { domain: domain })
120
+ end
121
+
122
+ # Look up IP geolocation data.
123
+ # @param ip [String] IP address (required)
124
+ # @return [Hash] Parsed JSON response
125
+ # @see https://dnsrobot.net/ip-lookup
126
+ def ip_lookup(ip)
127
+ raise ArgumentError, "ip is required" if ip.nil? || ip.empty?
128
+
129
+ post("ip-info", { ip: ip })
130
+ end
131
+
132
+ # Fetch and analyze HTTP response headers.
133
+ # @param url [String] URL to check (required, https:// added if missing)
134
+ # @return [Hash] Parsed JSON response
135
+ # @see https://dnsrobot.net/http-headers
136
+ def http_headers(url)
137
+ raise ArgumentError, "url is required" if url.nil? || url.empty?
138
+
139
+ url = "https://#{url}" unless url.start_with?("http://", "https://")
140
+ post("http-headers", { url: url })
141
+ end
142
+
143
+ # Check if a TCP port is open.
144
+ # @param host [String] Hostname or IP (required)
145
+ # @param port [Integer] Port number 1-65535 (required)
146
+ # @return [Hash] Parsed JSON response
147
+ # @see https://dnsrobot.net/port-checker
148
+ def port_check(host, port)
149
+ raise ArgumentError, "host is required" if host.nil? || host.empty?
150
+ raise ArgumentError, "port is required" if port.nil? || port.to_i <= 0
151
+
152
+ get("port-check", { host: host, port: port.to_s })
153
+ end
154
+
155
+ private
156
+
157
+ def post(endpoint, payload)
158
+ uri = URI("#{@base_url}/#{endpoint}")
159
+ http = Net::HTTP.new(uri.host, uri.port)
160
+ http.use_ssl = uri.scheme == "https"
161
+ http.open_timeout = @timeout
162
+ http.read_timeout = @timeout
163
+
164
+ req = Net::HTTP::Post.new(uri)
165
+ req["Content-Type"] = "application/json"
166
+ req["User-Agent"] = @user_agent
167
+ req.body = JSON.generate(payload)
168
+
169
+ res = http.request(req)
170
+ raise "DNS Robot API error: HTTP #{res.code} from #{endpoint}: #{res.body}" unless res.is_a?(Net::HTTPSuccess)
171
+
172
+ JSON.parse(res.body)
173
+ end
174
+
175
+ def get(endpoint, params)
176
+ uri = URI("#{@base_url}/#{endpoint}")
177
+ uri.query = URI.encode_www_form(params)
178
+ http = Net::HTTP.new(uri.host, uri.port)
179
+ http.use_ssl = uri.scheme == "https"
180
+ http.open_timeout = @timeout
181
+ http.read_timeout = @timeout
182
+
183
+ req = Net::HTTP::Get.new(uri)
184
+ req["User-Agent"] = @user_agent
185
+
186
+ res = http.request(req)
187
+ raise "DNS Robot API error: HTTP #{res.code} from #{endpoint}: #{res.body}" unless res.is_a?(Net::HTTPSuccess)
188
+
189
+ JSON.parse(res.body)
190
+ end
191
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dnsrobot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - DNS Robot
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for the DNS Robot API — DNS lookups, WHOIS, SSL checks, SPF/DKIM/DMARC
14
+ validation, and more. No API key required. Zero external dependencies.
15
+ email:
16
+ - rubygems@dnsrobot.net
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - lib/dnsrobot.rb
24
+ homepage: https://dnsrobot.net
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://dnsrobot.net
29
+ source_code_uri: https://github.com/dnsrobot/dns-robot-cli
30
+ bug_tracker_uri: https://github.com/dnsrobot/dns-robot-cli/issues
31
+ documentation_uri: https://dnsrobot.net/all-tools
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.5.0
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubygems_version: 3.0.3.1
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Ruby client for the DNS Robot API
51
+ test_files: []