Skip to content

Commit

Permalink
fix handling of top level domains
Browse files Browse the repository at this point in the history
  • Loading branch information
kofemann committed Nov 22, 2021
1 parent b7414c4 commit c28aefd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions livedns.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ def set_gandi_ip(addr, domain, hostname):
fqdn = sys.argv[3]
ip = sys.argv[4]

if '.' not in fqdn:
dot = fqdn.find('.')
if dot == -1:
print('notfqdn')
exit()

dot = fqdn.index('.')
hostname = fqdn[:dot]
domain = fqdn[dot+1:]
# if this is a top domain (a-la kofemann.dev) then use '@' as a special placeholder for empty name
if fqdn.find('.', dot + 1) == -1:
hostname = '@'
domain = fqdn
else:
hostname = fqdn[:dot]
domain = fqdn[dot+1:]

try:
set_gandi_ip(ip, domain, hostname)
Expand Down

0 comments on commit c28aefd

Please sign in to comment.