import socket
import select
from datetime import datetime, timedelta
+import functools
import dns, dns.message, dns.query
from dns.rdatatype import *
msg = msg.splitlines().pop(0)
print ('received control message: %s' % msg)
- msg = msg.split('|')
+ msg = msg.split(b'|')
if len(msg) == 0:
return
- actions = [x.strip() for x in msg[0].split(',')]
- n = reduce(lambda n,act: (n + (2 if act == 'dname' else 1)), [0] + actions)
+ actions = [x.strip() for x in msg[0].split(b',')]
+ n = functools.reduce(lambda n, act: (n + (2 if act == b'dname' else 1)), [0] + actions)
if len(msg) == 1:
rrs = []
rrs.append((i, b))
return
- rlist = [x.strip() for x in msg[1].split(',')]
+ rlist = [x.strip() for x in msg[1].split(b',')]
rrs = []
for item in rlist:
- if item[0] == 's':
+ if item[0] == b's'[0]:
i = int(item[1:].strip()) - 1
if i > n:
print ('invalid index %d' + (i + 1))
i = 0
for action in actions:
- if name <> 'test':
+ if name != 'test':
continue
- if action == 'xname':
+ if action == b'xname':
owner = curname + '.' + curdom
newname = 'cname%d' % i
i += 1
curdom = newdom
continue
- if action == 'cname':
+ if action == b'cname':
owner = curname + '.' + curdom
newname = 'cname%d' % i
target = newname + '.' + curdom
curname = newname
continue
- if action == 'dname':
+ if action == b'dname':
owner = curdom
newdom = 'domain%d.%s' % (i, tld)
i += 1
# prepare the response and convert to wire format
r = dns.message.make_response(m)
- if name <> 'test':
+ if name != 'test':
r.answer.append(answers[-1])
if wantsigs:
r.answer.append(sigs[-1])
print ("Shutting down now...")
os.remove('ans.pid')
running = 0
+ sys.exit(0)
############################################################################
# Main
signal.signal(signal.SIGTERM, sigterm)
-# Unbuffered ouput ensures we can always check current status in ans.run.
-sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
-
f = open('ans.pid', 'w')
pid = os.getpid()
print (pid, file=f)
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
-t=`expr $t + 1`
+n=`expr $n + 1`
echo "I:checking CNAME to signed external delgation is handled ($n)"
ret=0
$DIG $DIGOPTS @10.53.0.7 -p 5300 c.example > dig.out.$n
if [ $ret != 0 ]; then echo "I: failed"; fi
status=`expr $status + $ret`
-t=`expr $t + 1`
+n=`expr $n + 1`
echo "I:checking CNAME to signed internal delgation is handled ($n)"
ret=0
$DIG $DIGOPTS @10.53.0.7 -p 5300 d.example > dig.out.$n