commit c2f3a08680a45772c37cf1069138690dbd124767
parent 900f93c431db4ef2455e159d9c98261083407196
Author: rexxnor <rexxnor+gnunet@brief.li>
Date: Tue, 9 Oct 2018 12:47:15 +0200
fixed special cases with GNS2DNS
Diffstat:
1 file changed, 47 insertions(+), 3 deletions(-)
diff --git a/gnsmigrator/gnsmigrator.py b/gnsmigrator/gnsmigrator.py
@@ -16,6 +16,12 @@ Options:
"""
# imports
+from ctypes import c_size_t
+from ctypes import c_uint32
+from ctypes import c_uint64
+from ctypes import c_void_p
+from enum import Enum
+from dataclasses import dataclass
import multiprocessing
import queue
import sys
@@ -32,6 +38,26 @@ GNUNET_NAMESTORE_COMMAND = 'gnunet-namestore'
GNUNET_GNS_COMMAND = 'gnunet-gns'
GNUNET_ARM_COMMAND = 'gnunet-arm'
+class GNUnetGNSRecordFlags(Enum):
+ """
+ Flags that can be set for a record.
+ """
+ GNUNET_GNSRECORD_RF_NONE = 0
+ GNUNET_GNSRECORD_RF_PRIVATE = 2
+ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION = 8
+ GNUNET_GNSRECORD_RF_SHADOW_RECORD = 16
+
+@dataclass
+class GNUnetGNSRecordData():
+ """
+ Representation of a GNS Record in python
+ """
+ data: c_void_p
+ expiration_time: c_uint64
+ data_size: c_size_t
+ record_type: c_uint32
+ flags: GNUnetGNSRecordFlags
+
class BaseMigrator():
"""
Base class for migration
@@ -186,10 +212,21 @@ class BaseMigrator():
if dnsname_str != '@':
# Special case for the GNS2DNS case
if rtype_str == 'NS':
+ if str(value)[-1] == ".":
+ dnsresolver = str(value)[:-1]
+ else:
+ dnsresolver = "%s.%s" % (value, domain)
+ dnsresolver = str(value)[:-1]
+
+ if dnsname_str[-1] == ".":
+ dnsname_str = dnsname_str[:-1]
+
+ if domain[-1] == ".":
+ domain = domain[:-1]
# if no resolver is specified, choose the FQDN nameserver from zone
- if not dnsresolver:
- dnsresolver = value[:-1]
+ #if not dnsresolver:
+ # dnsresolver = value[:-1]
pkey_lookup = subprocess.Popen([GNUNET_ZONE_CREATION_COMMAND, '-d'],
stdout=subprocess.PIPE)
@@ -331,7 +368,14 @@ class TLDMigrator(BaseMigrator):
break
# execute thing to run on item
dnsname, ttl, authns = record
- authns = str(authns)[:-1]
+ if str(authns)[:-1] == ".":
+ authns = str(authns)[:-1]
+ else:
+ authns = "%s.%s" % (authns, zonename)
+
+ # building gns record struct
+ #GNUnetGNSRecordData()
+
subprocess.run([GNUNET_NAMESTORE_COMMAND,
'-z', zonename,
'-a', '-n', str(dnsname),