whois/whois.py
changeset 136 30259bf0523f
parent 134 3ff7f09ea24a
child 160 c385321ec3e4
child 162 93f6f3021941
equal deleted inserted replaced
135:808c8bc803f5 136:30259bf0523f
   113                 query_bytes = "-T dn,ace -C UTF-8 " + query
   113                 query_bytes = "-T dn,ace -C UTF-8 " + query
   114             elif hostname.endswith(NICClient.QNICHOST_TAIL) and many_results:
   114             elif hostname.endswith(NICClient.QNICHOST_TAIL) and many_results:
   115                 query_bytes = '=' + query
   115                 query_bytes = '=' + query
   116             else:
   116             else:
   117                 query_bytes = query
   117                 query_bytes = query
   118             s.send((query_bytes) + b"\r\n")
   118             s.send(bytes(query_bytes,'utf-8') + b"\r\n")
   119             # recv returns bytes
   119             # recv returns bytes
   120             while True:
   120             while True:
   121                 d = s.recv(4096)
   121                 d = s.recv(4096)
   122                 response += d
   122                 response += d
   123                 if not d:
   123                 if not d:
   139     def choose_server(self, domain):
   139     def choose_server(self, domain):
   140         """Choose initial lookup NIC host"""
   140         """Choose initial lookup NIC host"""
   141         try:
   141         try:
   142             domain = domain.encode('idna').decode('utf-8')
   142             domain = domain.encode('idna').decode('utf-8')
   143         except TypeError:
   143         except TypeError:
       
   144             domain = domain.decode('utf-8').encode('idna').decode('utf-8')
       
   145         except AttributeError:
   144             domain = domain.decode('utf-8').encode('idna').decode('utf-8')
   146             domain = domain.decode('utf-8').encode('idna').decode('utf-8')
   145         if domain.endswith("-NORID"):
   147         if domain.endswith("-NORID"):
   146             return NICClient.NORIDHOST
   148             return NICClient.NORIDHOST
   147         if domain.endswith("id"):
   149         if domain.endswith("id"):
   148             return NICClient.PANDIHOST
   150             return NICClient.PANDIHOST