Fixed an error when adding sub domains already in DO DNS
This commit is contained in:
parent
5ccb9b90d4
commit
678c32b2ea
13
ddns.py
13
ddns.py
@ -315,7 +315,9 @@ def show_current_info():
|
||||
ipserver = '[red]Error:[/red] No IP resolvers in DB'
|
||||
else:
|
||||
cursor.execute('SELECT * FROM ipservers')
|
||||
ipserver = cursor.fetchall()[0][1]
|
||||
ipservers = cursor.fetchall()
|
||||
ip4server = ipservers[0][1]
|
||||
ip6server = ipservers[0][2]
|
||||
|
||||
if API == None:
|
||||
API = '[red]Error:[/red] API key not stored in DB'
|
||||
@ -329,8 +331,8 @@ def show_current_info():
|
||||
print('\n[b]ddns[/b] - a DigitalOcean dynamic DNS solution.')
|
||||
print('===================================================')
|
||||
print('API key : [b]%s[/b]' % (API))
|
||||
print('IP v4 resolver : [b]%s[/b]' % (ipserver))
|
||||
print('IP v6 resolver : [b]N/A[/b]')
|
||||
print('IP v4 resolver : [b]%s[/b]' % (ip4server))
|
||||
print('IP v6 resolver : [b]%s[/b]' % (ip6server))
|
||||
print('Logfile : [b]%s[/b]' % (logfile))
|
||||
print('Top domains : [b]%s[/b]' % (topdomains))
|
||||
print('sub domains : [b]%s[/b]' % (subdomains))
|
||||
@ -375,7 +377,7 @@ def updateip(force):
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT COUNT(*) FROM subdomains')
|
||||
count = cursor.fetchone()[0]
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M")
|
||||
now = datetime.now().strftime("%d-%m-%Y %H:%M")
|
||||
updated = None
|
||||
if count == 0:
|
||||
print('[red]Error: [/red]There are no dynamic domains active.'\
|
||||
@ -419,6 +421,7 @@ def updateip(force):
|
||||
|
||||
|
||||
def local_add_subdomain(domain,domainid):
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M")
|
||||
if set(domain).difference(ascii_letters + '.' + digits + '-'):
|
||||
print('[red]Error:[/red] Give the domain name in simple form e.g. [b]test.domain.com[/b]')
|
||||
else:
|
||||
@ -447,7 +450,7 @@ def local_add_subdomain(domain,domainid):
|
||||
if count != 0:
|
||||
print('[red]Error:[/red] [bold]%s[/bold] already exists.' % (domain))
|
||||
else:
|
||||
cursor.execute('INSERT INTO subdomains values(?,?,?,?,?)',(domainid,topdomain_id,sub,ip,None,))
|
||||
cursor.execute('INSERT INTO subdomains values(?,?,?,?,?,?,?,?)',(domainid,topdomain_id,sub,ip,None,now,now,now,))
|
||||
conn.commit()
|
||||
print('The domain %s has been added.' % (domain))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user