Speling: nameserver is name server
This commit is contained in:
17
dnsupdate.py
17
dnsupdate.py
@@ -43,7 +43,7 @@ def getparams(msg):
|
|||||||
help="Alternate config file")
|
help="Alternate config file")
|
||||||
parser.add_option("--delete",
|
parser.add_option("--delete",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Remove the host from the nameserver")
|
help="Remove the host from the name server")
|
||||||
parser.add_option("-d", "--domain",
|
parser.add_option("-d", "--domain",
|
||||||
type="string",
|
type="string",
|
||||||
help="Domain to update")
|
help="Domain to update")
|
||||||
@@ -61,7 +61,7 @@ def getparams(msg):
|
|||||||
help="Hostname to publish")
|
help="Hostname to publish")
|
||||||
parser.add_option("--nameserver",
|
parser.add_option("--nameserver",
|
||||||
type="string",
|
type="string",
|
||||||
help="IP-address to the nameserver")
|
help="IP-address to the name server")
|
||||||
parser.add_option("-q", "--quiet",
|
parser.add_option("-q", "--quiet",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Quit mode")
|
help="Quit mode")
|
||||||
@@ -159,8 +159,10 @@ def update(msg):
|
|||||||
import dns.query
|
import dns.query
|
||||||
import dns.tsigkeyring
|
import dns.tsigkeyring
|
||||||
import dns.update
|
import dns.update
|
||||||
# The name of the key and the secret
|
import binascii # for exception handling in keyring generation
|
||||||
import binascii # for exception handling
|
import socket # for exception handling in server communictions
|
||||||
|
|
||||||
|
# The name of the key and the secret
|
||||||
try:
|
try:
|
||||||
keyring = dns.tsigkeyring.from_text({
|
keyring = dns.tsigkeyring.from_text({
|
||||||
msg['keyname']: msg['keysecret']
|
msg['keyname']: msg['keysecret']
|
||||||
@@ -179,7 +181,6 @@ def update(msg):
|
|||||||
update.replace(msg['hostname'], msg['ttl'], 'a', msg['ipaddress'])
|
update.replace(msg['hostname'], msg['ttl'], 'a', msg['ipaddress'])
|
||||||
|
|
||||||
# doit, servername
|
# doit, servername
|
||||||
import socket # Import socket so we can catch exceptions
|
|
||||||
try:
|
try:
|
||||||
response = dns.query.tcp(update, msg['nameserver'])
|
response = dns.query.tcp(update, msg['nameserver'])
|
||||||
except socket.error:
|
except socket.error:
|
||||||
@@ -237,14 +238,14 @@ def verify_ip(msg):
|
|||||||
for res in ans:
|
for res in ans:
|
||||||
ip = res.to_text()
|
ip = res.to_text()
|
||||||
except dns.exception.Timeout:
|
except dns.exception.Timeout:
|
||||||
msg['error'].append("Connection timeout, could not connect to nameserver.\n")
|
msg['error'].append("Connection timeout, could not connect to name server.\n")
|
||||||
except dns.resolver.NXDOMAIN:
|
except dns.resolver.NXDOMAIN:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if ip == msg['ipaddress'] and not msg.has_key('delete'):
|
if ip == msg['ipaddress'] and not msg.has_key('delete'):
|
||||||
msg['error'].append("Nameserver already up to date")
|
msg['error'].append("name server already up to date")
|
||||||
elif ip == "" and msg.has_key('delete'):
|
elif ip == "" and msg.has_key('delete'):
|
||||||
msg['error'].append("Nameserver does not recognise the hostname")
|
msg['error'].append("name server does not recognise the hostname")
|
||||||
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user