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')
|
database = filepath.joinpath('ddns.db')
|
||||||
logfile = filepath.joinpath('ddns.log')
|
logfile = filepath.joinpath('ddns.log')
|
||||||
logging.basicConfig(filename=logfile,level=logging.INFO,format='%(message)s')
|
logging.basicConfig(filename=logfile,level=logging.INFO,format='%(message)s')
|
||||||
app_version = '0.5.2'
|
app_version = '0.5.1'
|
||||||
|
|
||||||
|
|
||||||
def get_ip():
|
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]')
|
print('[red]Error:[/red]. Give the domain name in simple form e.g. [bold]test.domain.com[/bold]')
|
||||||
else:
|
else:
|
||||||
parts = domain.split('.')
|
parts = domain.split('.')
|
||||||
if len(parts) > 3:
|
topdomain = parts[1]+'.'+parts[2]
|
||||||
top = parts[1] + '.' + parts[2] + '.' + parts[3]
|
cursor.execute('SELECT id FROM domains WHERE name like ?', (topdomain,))
|
||||||
sub = parts[0]
|
|
||||||
else:
|
|
||||||
sub = parts[0]
|
|
||||||
top = parts[1] + '.' + parts[2]
|
|
||||||
cursor.execute('SELECT id FROM domains WHERE name like ?', (top,))
|
|
||||||
domainid = cursor.fetchone()[0]
|
domainid = cursor.fetchone()[0]
|
||||||
cursor.execute('SELECT * FROM subdomains WHERE main_id like ?', (domainid,))
|
cursor.execute('SELECT * FROM subdomains WHERE main_id like ?', (domainid,))
|
||||||
domains = cursor.fetchall()
|
domains = cursor.fetchall()
|
||||||
@ -491,15 +486,12 @@ def local_add_subdomain(domain,domainid):
|
|||||||
else:
|
else:
|
||||||
parts = domain.split('.')
|
parts = domain.split('.')
|
||||||
if len(parts) > 3:
|
if len(parts) > 3:
|
||||||
# longtop = parts[2] + '.' + parts[2] + '.' + parts[3]
|
|
||||||
top = parts[1] + '.' + parts[2] + '.' + parts[3]
|
top = parts[1] + '.' + parts[2] + '.' + parts[3]
|
||||||
sub = parts[0]
|
sub = parts[0]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
sub = parts[0]
|
sub = parts[0]
|
||||||
top = parts[1] + '.' + parts[2]
|
top = parts[1] + '.' + parts[2]
|
||||||
apikey = get_api()
|
apikey = get_api()
|
||||||
longtop=sub+'.'+top
|
|
||||||
if apikey == None:
|
if apikey == None:
|
||||||
print("[red]Error:[/red] Missing APIkey. Please add one!")
|
print("[red]Error:[/red] Missing APIkey. Please add one!")
|
||||||
else:
|
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))
|
print('[red]Error:[/red] Failed to get public IP. Do you have a typo in your URI? [red]Error %s.[/red]' % (ip))
|
||||||
else:
|
else:
|
||||||
cursor = conn.cursor()
|
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]
|
count = cursor.fetchone()[0]
|
||||||
if count == 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))
|
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:
|
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 = cursor.fetchone()
|
||||||
topdomain_id = topdomain_id[0]
|
topdomain_id = topdomain_id[0]
|
||||||
cursor.execute('SELECT count(*) FROM subdomains WHERE main_id LIKE ? AND name like ?',(topdomain_id,sub,))
|
cursor.execute('SELECT count(*) FROM subdomains WHERE main_id LIKE ? AND name like ?',(topdomain_id,sub,))
|
||||||
|
Loading…
Reference in New Issue
Block a user