whois/whois.py
changeset 112 8acab8765146
parent 108 4fb2273c5821
child 122 95feee1af1da
equal deleted inserted replaced
111:ccad96890edd 112:8acab8765146
    53     QNICHOST_TAIL = ".whois-servers.net"
    53     QNICHOST_TAIL = ".whois-servers.net"
    54     SNICHOST = "whois.6bone.net"
    54     SNICHOST = "whois.6bone.net"
    55     BNICHOST = "whois.registro.br"
    55     BNICHOST = "whois.registro.br"
    56     NORIDHOST = "whois.norid.no"
    56     NORIDHOST = "whois.norid.no"
    57     IANAHOST = "whois.iana.org"
    57     IANAHOST = "whois.iana.org"
       
    58     PANDIHOST = "whois.pandi.or.id"
    58     DENICHOST = "de.whois-servers.net"
    59     DENICHOST = "de.whois-servers.net"
    59     DEFAULT_PORT = "nicname"
    60     DEFAULT_PORT = "nicname"
    60 
    61 
    61     WHOIS_RECURSE = 0x01
    62     WHOIS_RECURSE = 0x01
    62     WHOIS_QUICK = 0x02
    63     WHOIS_QUICK = 0x02
    63 
    64 
    64     ip_whois = [LNICHOST, RNICHOST, PNICHOST, BNICHOST]
    65     ip_whois = [LNICHOST, RNICHOST, PNICHOST, BNICHOST,PANDIHOST]
    65 
    66 
    66     def __init__(self):
    67     def __init__(self):
    67         self.use_qnichost = False
    68         self.use_qnichost = False
    68 
    69 
    69     def findwhois_server(self, buf, hostname, query):
    70     def findwhois_server(self, buf, hostname, query):
   137             domain = domain.encode('idna').decode('utf-8')
   138             domain = domain.encode('idna').decode('utf-8')
   138         except TypeError:
   139         except TypeError:
   139             domain = domain.decode('utf-8').encode('idna').decode('utf-8')
   140             domain = domain.decode('utf-8').encode('idna').decode('utf-8')
   140         if domain.endswith("-NORID"):
   141         if domain.endswith("-NORID"):
   141             return NICClient.NORIDHOST
   142             return NICClient.NORIDHOST
       
   143         if domain.endswith("id"):
       
   144             return NICClient.PANDIHOST
       
   145 
   142         domain = domain.split('.')
   146         domain = domain.split('.')
   143         if len(domain) < 2:
   147         if len(domain) < 2:
   144             return None
   148             return None
   145         tld = domain[-1]
   149         tld = domain[-1]
   146         if tld[0].isdigit():
   150         if tld[0].isdigit():
   236                       const="ru", dest="country",
   240                       const="ru", dest="country",
   237                       help="Lookup Russian NIC")
   241                       help="Lookup Russian NIC")
   238     parser.add_option("-6", "--6bone", action="store_const",
   242     parser.add_option("-6", "--6bone", action="store_const",
   239                       const=NICClient.SNICHOST, dest="whoishost",
   243                       const=NICClient.SNICHOST, dest="whoishost",
   240                       help="Lookup using host " + NICClient.SNICHOST)
   244                       help="Lookup using host " + NICClient.SNICHOST)
       
   245     parser.add_option("-n", "--ina", action="store_const",
       
   246                           const=NICClient.PANDIHOST, dest="whoishost",
       
   247                           help="Lookup using host " + NICClient.PANDIHOST)
   241     parser.add_option("-?", "--help", action="help")
   248     parser.add_option("-?", "--help", action="help")
   242 
   249 
   243     return parser.parse_args(argv)
   250     return parser.parse_args(argv)
   244 
   251 
   245 
   252