From: Philipp Spitzer Date: Tue, 8 Apr 2014 20:16:04 +0000 (+0200) Subject: Now the ip address is given to nsupdate_dyndns in case of offline (if given). X-Git-Tag: 0.0.2~6 X-Git-Url: https://git.toastfreeware.priv.at/toast/tdyndns.git/commitdiff_plain/99029787d501fc1ac8a107dbfe390ec9b8d3de47 Now the ip address is given to nsupdate_dyndns in case of offline (if given). --- diff --git a/cgi-bin/dyndns.py b/cgi-bin/dyndns.py index c5f0e4f..cb48a18 100755 --- a/cgi-bin/dyndns.py +++ b/cgi-bin/dyndns.py @@ -152,16 +152,20 @@ try: myip = os.environ.get('REMOTE_ADDR') if not myip: # empty string if not present raise MyipMissing() + if not myip is None: try: - ip = ipaddr.IPAddress(myip) # throws an exception if the IP address is not valid + ipaddr.IPAddress(myip) # throws an exception if the IP address is not valid except ValueError: raise MyipInvalid() # update bind + call_params = ['sudo', '/usr/local/bin/nsupdate_dyndns'] if offline: - call(['sudo', '/usr/local/bin/nsupdate_dyndns', '--delete', hostname]) - else: - call(['sudo', '/usr/local/bin/nsupdate_dyndns', '--ip', myip, hostname]) + call_params.append('--delete') + if myip is not None: + call_params.extend(['--ip', myip]) + call_params.append(hostname) + call(call_params) # return success print "Content-Type: text/html"