Skip to content

Commit

Permalink
Switch path and ip variable to closer match most DDNS services
Browse files Browse the repository at this point in the history
  • Loading branch information
clayoster committed Sep 18, 2024
1 parent 098822c commit 79ee592
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ The primary purposes for building yet another DDNS tool for updating Cloudflare
- Unforunately Cloudflare does not allow limiting the edit privileges to a single DNS record in a zone at this point.
- Self-hosted option for receving DDNS updates from a router or other local source rather than depending on querying an external API for public IP address changes

Valid response codes were gathered from here:
Valid response codes were gathered from here:\
https://help.dyn.com/remote-access-api/\
https://github.com/troglobit/inadyn/blob/master/plugins/common.c

This service requires a GET request in the following format

https://<username>:<password>@ddns.example.com/update?hostname=<dns record to update>&ip=<public ip>
https://<username>:<password>@ddns.example.com/nic/update?hostname=<dns record to update>&myip=<public ip>
5 changes: 3 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def unauthorized():
return "badauth"

@app.route('/update')
@app.route('/nic/update')
@auth.login_required
def main():
# Set hostname variable
Expand All @@ -39,8 +40,8 @@ def main():
hostname = 'blank'

# Set ip variable
if 'ip' in request.args:
ip = request.args.get('ip')
if 'myip' in request.args:
ip = request.args.get('myip')
else:
ip = 'blank'

Expand Down
8 changes: 4 additions & 4 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ def basic_auth(username, password):

def test_good_auth(app, client):
auth_headers = basic_auth('testuser', 'testpass')
res = client.get('/update?hostname=test.domain.com&ip=0.0.0.0', headers=auth_headers)
res = client.get('/nic/update?hostname=test.domain.com&myip=0.0.0.0', headers=auth_headers)
assert b'noapitoken' in res.data
assert res.status_code == 200

def test_bad_auth(app, client):
auth_headers = basic_auth('testuser', 'badpass')
res = client.get('/update?hostname=test.domain.com&ip=0.0.0.0', headers=auth_headers)
res = client.get('/nic/update?hostname=test.domain.com&myip=0.0.0.0', headers=auth_headers)
assert b'badauth' in res.data
assert res.status_code == 401


def test_missing_hostname(app, client):
auth_headers = basic_auth('testuser', 'testpass')
res = client.get('/update?ip=0.0.0.0', headers=auth_headers)
res = client.get('/nic/update?myip=0.0.0.0', headers=auth_headers)
assert b'nohost' in res.data
assert res.status_code == 200

def test_missing_ip(app, client):
auth_headers = basic_auth('testuser', 'testpass')
res = client.get('/update?hostname=test.domain.com', headers=auth_headers)
res = client.get('/nic/update?hostname=test.domain.com', headers=auth_headers)
assert b'noip' in res.data
assert res.status_code == 200

0 comments on commit 79ee592

Please sign in to comment.