2017-03-22 04:06:24 +01:00
|
|
|
import whoisdb.models
|
2017-03-21 02:36:07 +01:00
|
|
|
import domains.models
|
2017-03-20 00:16:33 +01:00
|
|
|
|
2017-03-22 04:06:24 +01:00
|
|
|
|
2017-03-20 00:16:33 +01:00
|
|
|
def _addFields(fields, obj, fieldNames):
|
|
|
|
for fieldName in fieldNames:
|
2017-03-21 02:36:07 +01:00
|
|
|
fields.append((fieldName.capitalize().replace("_", " "), getattr(obj, fieldName)))
|
2017-03-20 00:16:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
def getWhoisObjectFields(obj, owner):
|
|
|
|
fields = []
|
|
|
|
|
2017-03-22 04:06:24 +01:00
|
|
|
if getattr(obj, "handle", None):
|
2017-03-20 00:16:33 +01:00
|
|
|
_addFields(fields, obj, ["handle"])
|
|
|
|
|
|
|
|
c = type(obj)
|
|
|
|
if c == whoisdb.models.Maintainer:
|
2017-03-27 02:22:51 +02:00
|
|
|
_addFields(fields, obj, ["description", "admin_c"])
|
2017-03-20 00:16:33 +01:00
|
|
|
if owner:
|
|
|
|
_addFields(fields, obj, ["auth"])
|
|
|
|
elif c == whoisdb.models.Contact:
|
|
|
|
_addFields(fields, obj, ["name", "mnt_by"])
|
|
|
|
elif c == whoisdb.models.ASBlock:
|
|
|
|
_addFields(fields, obj, ["name"])
|
|
|
|
fields.append(("AS Range", "%s - %s" % (obj.asBegin, obj.asEnd)))
|
2017-03-21 19:34:02 +01:00
|
|
|
_addFields(fields, obj, ["description", "parent_block", "mnt_by", "mnt_lower", "admin_c"])
|
2017-03-20 00:16:33 +01:00
|
|
|
elif c == whoisdb.models.ASNumber:
|
2017-03-21 19:34:02 +01:00
|
|
|
_addFields(fields, obj, ["name", "number", "description", "volatile", "mnt_by", "mnt_lower", "admin_c"])
|
2017-03-20 00:16:33 +01:00
|
|
|
elif c == whoisdb.models.InetNum:
|
|
|
|
_addFields(fields, obj, ["name"])
|
|
|
|
fields.append(("Address CIDR", obj.prefix()))
|
2017-03-21 02:36:07 +01:00
|
|
|
_addFields(fields, obj, ["description", "parent_range", "mnt_by", "mnt_lower", "admin_c"])
|
|
|
|
elif c == domains.models.Domain:
|
|
|
|
_addFields(fields, obj, ["name", "nameservers", "mnt_by", "admin_c"])
|
|
|
|
elif c == domains.models.Nameserver:
|
|
|
|
_addFields(fields, obj, ["name", "glueIPv4", "glueIPv6", "mnt_by", "admin_c"])
|
|
|
|
elif c == domains.models.ReverseZone:
|
2017-03-22 04:06:24 +01:00
|
|
|
#_addFields(fields, obj, ["name"])
|
2017-03-21 02:36:07 +01:00
|
|
|
fields.append(("Address CIDR", obj.prefix()))
|
|
|
|
_addFields(fields, obj, ["parentNet", "nameservers"])
|
2017-03-20 00:16:33 +01:00
|
|
|
|
|
|
|
return fields
|
|
|
|
|
2017-03-22 04:06:24 +01:00
|
|
|
|
2017-03-21 19:34:02 +01:00
|
|
|
def guessWhoisObject(self, handle):
|
|
|
|
# is it a normal handle?
|
|
|
|
pass
|