whois-rb gem produces error: "Whois::ServerNotFound"
whois-rb gem produces error: "Whois::ServerNotFound"
我完全迷失在这里。我试图根据 https://whoisrb.org/ 上的文档设置 whois gem。不幸的是,当我尝试在我的机器上本地执行 whois 时,我总是遇到错误。
错误信息:
Unable to find a WHOIS server for `;; answer received from 192.168.178.1 (75 bytes) ;; ;; security level : unchecked ;; ->>header<<- opcode: query, status: noerror, id: 51102 ;; flags: qr rd ra cd; query: 1, answer: 1, authority: 0, additional: 1 opt pseudo-record : payloadsize 512, xrcode 0, version 0, flags 32768 ;; question section (1 record) ;; google-public-dns-b.google.com. in a ;; answer section (1 record) google-public-dns-b.google.com. 84453 in a 8.8.4.4 '
不要混淆,我也在使用 dnsruby gem.. 我模型中的相应代码:
def set_isp
res = Resolver.new
a_record = res.query(self.domain_name)
whois = Whois::Client.new
rec = whois.lookup(a_record)
self.isp = rec.name
end
提前致谢!
我不确定你哪里出错了我只是尝试使用 gem whoisrb 创建一个示例苹果我所要做的就是将 whois gem 添加到 Gemfile。
#Gemfile
gem 'whois', '~> 3.0'
现在您可以打开控制台并输入
$ client = Whois::Client.new
$ response = client.lookup("google.com")
我创建了一个示例 git 项目,它将向您展示它是如何在控制器中组合在一起的。我可以而且应该将其用于模型方法
根据错误,问题是您正在传递
的结果
a_record = res.query(self.domain_name)
直达
whois.lookup
但是a_record
的内容不是域名。相反,它是一个完整的 DNS 响应:
;; answer received from 192.168.178.1 (75 bytes)
;;
;; security level : unchecked
;; ->>header<<- opcode: query, status: noerror, id: 51102
...
请确保输入的是有效的域名(或IP地址)。
我完全迷失在这里。我试图根据 https://whoisrb.org/ 上的文档设置 whois gem。不幸的是,当我尝试在我的机器上本地执行 whois 时,我总是遇到错误。
错误信息:
Unable to find a WHOIS server for `;; answer received from 192.168.178.1 (75 bytes) ;; ;; security level : unchecked ;; ->>header<<- opcode: query, status: noerror, id: 51102 ;; flags: qr rd ra cd; query: 1, answer: 1, authority: 0, additional: 1 opt pseudo-record : payloadsize 512, xrcode 0, version 0, flags 32768 ;; question section (1 record) ;; google-public-dns-b.google.com. in a ;; answer section (1 record) google-public-dns-b.google.com. 84453 in a 8.8.4.4 '
不要混淆,我也在使用 dnsruby gem.. 我模型中的相应代码:
def set_isp
res = Resolver.new
a_record = res.query(self.domain_name)
whois = Whois::Client.new
rec = whois.lookup(a_record)
self.isp = rec.name
end
提前致谢!
我不确定你哪里出错了我只是尝试使用 gem whoisrb 创建一个示例苹果我所要做的就是将 whois gem 添加到 Gemfile。
#Gemfile
gem 'whois', '~> 3.0'
现在您可以打开控制台并输入
$ client = Whois::Client.new
$ response = client.lookup("google.com")
我创建了一个示例 git 项目,它将向您展示它是如何在控制器中组合在一起的。我可以而且应该将其用于模型方法
根据错误,问题是您正在传递
的结果a_record = res.query(self.domain_name)
直达
whois.lookup
但是a_record
的内容不是域名。相反,它是一个完整的 DNS 响应:
;; answer received from 192.168.178.1 (75 bytes)
;;
;; security level : unchecked
;; ->>header<<- opcode: query, status: noerror, id: 51102
...
请确保输入的是有效的域名(或IP地址)。