Compare commits
No commits in common. "f39ca9c9978fb3f14c0a3b600c12900d84fe9094" and "c6bdca6562b2faf623b39010010d6114c0f2382f" have entirely different histories.
f39ca9c997
...
c6bdca6562
18
ddns.py
18
ddns.py
@ -19,7 +19,7 @@ filepath = homefilepath.joinpath('.config/ddns')
|
||||
database = filepath.joinpath('ddns.db')
|
||||
logfile = filepath.joinpath('ddns.log')
|
||||
logging.basicConfig(filename=logfile,level=logging.INFO,format='%(message)s')
|
||||
app_version = '0.5.2'
|
||||
app_version = '0.5.1'
|
||||
|
||||
|
||||
def get_ip():
|
||||
@ -347,13 +347,8 @@ def domaininfo(domain):
|
||||
print('[red]Error:[/red]. Give the domain name in simple form e.g. [bold]test.domain.com[/bold]')
|
||||
else:
|
||||
parts = domain.split('.')
|
||||
if len(parts) > 3:
|
||||
top = parts[1] + '.' + parts[2] + '.' + parts[3]
|
||||
sub = parts[0]
|
||||
else:
|
||||
sub = parts[0]
|
||||
top = parts[1] + '.' + parts[2]
|
||||
cursor.execute('SELECT id FROM domains WHERE name like ?', (top,))
|
||||
topdomain = parts[1]+'.'+parts[2]
|
||||
cursor.execute('SELECT id FROM domains WHERE name like ?', (topdomain,))
|
||||
domainid = cursor.fetchone()[0]
|
||||
cursor.execute('SELECT * FROM subdomains WHERE main_id like ?', (domainid,))
|
||||
domains = cursor.fetchall()
|
||||
@ -491,15 +486,12 @@ def local_add_subdomain(domain,domainid):
|
||||
else:
|
||||
parts = domain.split('.')
|
||||
if len(parts) > 3:
|
||||
# longtop = parts[2] + '.' + parts[2] + '.' + parts[3]
|
||||
top = parts[1] + '.' + parts[2] + '.' + parts[3]
|
||||
sub = parts[0]
|
||||
|
||||
else:
|
||||
sub = parts[0]
|
||||
top = parts[1] + '.' + parts[2]
|
||||
apikey = get_api()
|
||||
longtop=sub+'.'+top
|
||||
if apikey == None:
|
||||
print("[red]Error:[/red] Missing APIkey. Please add one!")
|
||||
else:
|
||||
@ -508,12 +500,12 @@ def local_add_subdomain(domain,domainid):
|
||||
print('[red]Error:[/red] Failed to get public IP. Do you have a typo in your URI? [red]Error %s.[/red]' % (ip))
|
||||
else:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ? or name like ?',(top,longtop,))
|
||||
cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ?',(top,))
|
||||
count = cursor.fetchone()[0]
|
||||
if count == 0:
|
||||
print('[red]Error:[/red] Top domain [bold]%s[/bold] does not exist in the DB. Please add it with [i]ddns -t %s[/i].' % (top,top))
|
||||
else:
|
||||
cursor.execute('SELECT id FROM domains WHERE name LIKE ? or name like ?',(top,longtop,))
|
||||
cursor.execute('SELECT id FROM domains WHERE name LIKE ?',(top,))
|
||||
topdomain_id = cursor.fetchone()
|
||||
topdomain_id = topdomain_id[0]
|
||||
cursor.execute('SELECT count(*) FROM subdomains WHERE main_id LIKE ? AND name like ?',(topdomain_id,sub,))
|
||||
|
Loading…
Reference in New Issue
Block a user