2017-01-14 32 views
1

我完全迷失在這裏。我試圖根據文檔https://whoisrb.org/設置whois gem。不幸的是,當我嘗試在我的機器上本地執行whois時,我總是遇到錯誤。whois-rb gem產生錯誤:「Whois :: ServerNotFound」

錯誤消息:

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寶石以及..在我的模型對應的代碼:

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

非常感謝提前!

回答

1

根據錯誤,問題是要傳遞的

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地址)。

0

我不確定你在哪裏出錯我只是嘗試使用gem whoisrb創建一個示例蘋果,我所要做的就是將whois寶石添加到Gemfile中。現在

#Gemfile 
gem 'whois', '~> 3.0' 

您可以在

$ client = Whois::Client.new 
$ response = client.lookup("google.com") 

打開控制檯,輸入我創建了一個例子Git項目,將告訴你如何把它一起在控制器中。我可以和它應該給一個模型的方法

https://github.com/mzaragoza/sample-whoisrb