diff -r dd959601e67a -r 0a3103cd825d runtime/Stunnel.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/runtime/Stunnel.py Tue Oct 23 13:36:07 2018 +0200 @@ -0,0 +1,18 @@ +import os +from binascii import hexlify + +restart_stunnel_cmdline = ["/etc/init.d/S50stunnel","restart"] + +def pskgen(ID, pskpath): + secretstring = hexlify(os.urandom(256)) + pskstring = ID+":"+secretstring + with open(pskpath, 'w') as f: + f.write(pskstring) + call(restart_stunnel_cmdline) + +def ensurepsk(ID, pskpath): + # check if already there + if not os.path.exists(pskpath): + # create if needed + pskgen(IS, pskpath) +