aboutsummaryrefslogtreecommitdiff
path: root/gnunet/gnsrecord.py
diff options
context:
space:
mode:
Diffstat (limited to 'gnunet/gnsrecord.py')
-rw-r--r--gnunet/gnsrecord.py57
1 files changed, 30 insertions, 27 deletions
diff --git a/gnunet/gnsrecord.py b/gnunet/gnsrecord.py
index 4d00139..1cb0d72 100644
--- a/gnunet/gnsrecord.py
+++ b/gnunet/gnsrecord.py
@@ -1,36 +1,39 @@
1import datetime 1import datetime
2 2
3
3dns_types = { 4dns_types = {
4 "A": 1, 5 "A": 1,
5 "NS": 2, 6 "NS": 2,
6 "CNAME": 5, 7 "CNAME": 5,
7 "SOA": 6, 8 "SOA": 6,
8 "PTR": 12, 9 "PTR": 12,
9 "MX": 15, 10 "MX": 15,
10 "TXT": 16, 11 "TXT": 16,
11 "AAAA": 28, 12 "AAAA": 28,
12 "TLSA": 52} 13 "TLSA": 52}
14
13 15
14gns_types = { 16gns_types = {
15 "PKEY": 65536, 17 "PKEY": 65536,
16 "NICK": 65537, 18 "NICK": 65537,
17 "LEHO": 65538, 19 "LEHO": 65538,
18 "VPN": 65539, 20 "VPN": 65539,
19 "GNS2DNS": 65540} 21 "GNS2DNS": 65540}
22
20 23
21types = dict(list(dns_types.items()) + list(gns_types.items())) 24types = dict(list(dns_types.items()) + list(gns_types.items()))
22 25
23class Data:
24 def __init__(self, record_type, data, expiration_time=None, private=None, pending=None, shadow=None):
25 self.record_type = str(record_type)
26 if record_type not in types:
27 raise ValueError("'record_type' must be one of %s" % types)
28 #self.data = bytearray(data)
29 self.data = str(data)
30 if expiration_time is not None and not isinstance(expiration_time, datetime.datetime) or isinstance(expiration_time, datetime.timedelta):
31 raise TypeError("'expiration_time' must be a datetime.datetime or a datetime.timedelta")
32 self.expiration_time = expiration_time
33 self.private = private
34 self.pending = pending
35 self.shadow = shadow
36 26
27class Data:
28 def __init__(self, record_type, data, expiration_time=None, private=None, pending=None, shadow=None):
29 self.record_type = str(record_type)
30 if record_type not in types:
31 raise ValueError("'record_type' must be one of %s" % types)
32 # self.data = bytearray(data)
33 self.data = str(data)
34 if expiration_time is not None and not isinstance(expiration_time, datetime.datetime) or isinstance(expiration_time, datetime.timedelta):
35 raise TypeError("'expiration_time' must be a datetime.datetime or a datetime.timedelta")
36 self.expiration_time = expiration_time
37 self.private = private
38 self.pending = pending
39 self.shadow = shadow