|
|
|
@@ -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)
|
|
|
|
|
app_version = '0.4.2'
|
|
|
|
|
app_version = '0.4.2.1'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_ip():
|
|
|
|
@@ -161,7 +161,7 @@ def add_subdomain(domain):
|
|
|
|
|
if response != 'Fail':
|
|
|
|
|
response_data = response.json()
|
|
|
|
|
domainid = str(response_data['domain_record']['id'])
|
|
|
|
|
cursor.execute('INSERT INTO subdomains values(?,?,?,?,?,?,?)',(domainid,topdomain_id,sub,ip,None,now,now,now,))
|
|
|
|
|
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))
|
|
|
|
|
logging.info(time.strftime("%Y-%m-%d %H:%M") + ' - Info : subdomain %s added'%(domain))
|
|
|
|
@@ -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))
|
|
|
|
|
|
|
|
|
|