5 Commits

Author SHA1 Message Date
Rune Olsen
d1e2b06f13 Updated the README.md 2025-01-02 11:16:28 +01:00
Rune Olsen
a29a20b58b Adding image for Wiki pages 2025-01-02 11:07:39 +01:00
Rune Olsen
757c3f606d Adding image folder for Wiki pages 2025-01-02 10:51:12 +01:00
40c4476081 Quick fix 2023-04-17 11:02:08 +02:00
890dfea5ab Quick fix 2023-04-17 10:55:01 +02:00
4 changed files with 9 additions and 9 deletions

View File

@@ -27,7 +27,7 @@ to discuss what you would like to change.
## Support ## Support
If you found a bug or you have suggestion for new features create an issue. If you found a bug or you have suggestion for new features create an issue. There is also a [Wiki here](https://gitlab.pm/rune/ddns/wiki)
## Future development ## Future development

16
ddns.py
View File

@@ -185,14 +185,14 @@ def remove_subdomain(domain):
else: else:
sub = parts[0] sub = parts[0]
top = parts[1] + '.' + parts[2] top = parts[1] + '.' + parts[2]
longtop=sub+'.'+top
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ?',(top,)) cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ? or name like ?',(top,longtop,))
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. So I\'m giving up!.' % (top)) print('[red]Error:[/red] Top domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (top))
else: else:
cursor.execute('SELECT COUNT(*) FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name=?)',(sub,top,)) cursor.execute('SELECT COUNT(*) FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name like ? or name like ?)',(sub,top,longtop,))
count = cursor.fetchone()[0] count = cursor.fetchone()[0]
if count == 0: if count == 0:
print('[red]Error:[/red] Domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (domain)) print('[red]Error:[/red] Domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (domain))
@@ -201,7 +201,7 @@ def remove_subdomain(domain):
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:
cursor.execute('SELECT id FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name=?)',(sub,top,)) cursor.execute('SELECT id FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name like ? or name like ?)',(sub,top,longtop,))
subdomain_id = str(cursor.fetchone()[0]) subdomain_id = str(cursor.fetchone()[0])
headers = {'Authorization': 'Bearer ' + apikey, "Content-Type": "application/json"} headers = {'Authorization': 'Bearer ' + apikey, "Content-Type": "application/json"}
response = requests.delete('https://api.digitalocean.com/v2/domains/'+top+'/records/' + subdomain_id, headers=headers) response = requests.delete('https://api.digitalocean.com/v2/domains/'+top+'/records/' + subdomain_id, headers=headers)
@@ -225,13 +225,14 @@ def edit_subdomain(domain):
else: else:
sub = parts[0] sub = parts[0]
top = parts[1] + '.' + parts[2] top = parts[1] + '.' + parts[2]
longtop=sub+'.'+top
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ?',(top,)) cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ? or name like ?',(top,longtop,))
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. So I\'m giving up!.' % (top)) print('[red]Error:[/red] Top domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (top))
else: else:
cursor.execute('SELECT COUNT(*) FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name=?)',(sub,top,)) cursor.execute('SELECT COUNT(*) FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name like ? or name like ?)',(sub,top,longtop))
count = cursor.fetchone()[0] count = cursor.fetchone()[0]
if count == 0: if count == 0:
print('[red]Error:[/red] Domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (domain)) print('[red]Error:[/red] Domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (domain))
@@ -240,7 +241,7 @@ def edit_subdomain(domain):
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:
cursor.execute('SELECT id,active FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name=?)',(sub,top,)) cursor.execute('SELECT id,active FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name like ? or name like ?)',(sub,top,longtop))
domain_info = cursor.fetchone() domain_info = cursor.fetchone()
subdomain_id = str(domain_info[0]) subdomain_id = str(domain_info[0])
status = domain_info[1] status = domain_info[1]
@@ -491,7 +492,6 @@ 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]

BIN
images/wiki_image_01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

BIN
images/wiki_image_02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB