aboutsummaryrefslogtreecommitdiff
path: root/gnunet/gnsrecord.py
diff options
context:
space:
mode:
Diffstat (limited to 'gnunet/gnsrecord.py')
-rw-r--r--gnunet/gnsrecord.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/gnunet/gnsrecord.py b/gnunet/gnsrecord.py
new file mode 100644
index 0000000..4d00139
--- /dev/null
+++ b/gnunet/gnsrecord.py
@@ -0,0 +1,36 @@
1import datetime
2
3dns_types = {
4 "A": 1,
5 "NS": 2,
6 "CNAME": 5,
7 "SOA": 6,
8 "PTR": 12,
9 "MX": 15,
10 "TXT": 16,
11 "AAAA": 28,
12 "TLSA": 52}
13
14gns_types = {
15 "PKEY": 65536,
16 "NICK": 65537,
17 "LEHO": 65538,
18 "VPN": 65539,
19 "GNS2DNS": 65540}
20
21types = dict(list(dns_types.items()) + list(gns_types.items()))
22
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