Skip to content

Commit

Permalink
make sure TTL is 0-86400 inclusive when add or update
Browse files Browse the repository at this point in the history
  • Loading branch information
xmok committed Oct 25, 2023
1 parent fde3560 commit 041a27b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dns/dnsManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ def addDNSRecord(self, userID = None, data = None):
recordType = data['recordType']
recordName = data['recordName']
ttl = int(data['ttl'])
if ttl < 0:
raise ValueError("TTL: The item must be greater than 0")
elif ttl > 86400:
raise ValueError("TTL: The item must be lesser than 86401")

admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnershipZone(zoneDomain, admin, currentACL) == 1:
Expand Down Expand Up @@ -444,6 +448,10 @@ def updateRecord(self, userID = None, data = None):

if data['ttlNow'] != None:
record.ttl = int(data['ttlNow'])
if record.ttl < 0:
raise ValueError("TTL: The item must be greater than 0")
elif record.ttl > 86400:
raise ValueError("TTL: The item must be lesser than 86401")

if data['priorityNow'] != None:
record.prio = int(data['priorityNow'])
Expand Down Expand Up @@ -826,6 +834,10 @@ def addDNSRecordCloudFlare(self, userID = None, data = None):
recordType = data['recordType']
recordName = data['recordName']
ttl = int(data['ttl'])
if ttl < 0:
raise ValueError("TTL: The item must be greater than 0")
elif ttl > 86400:
raise ValueError("TTL: The item must be lesser than 86401")

admin = Administrator.objects.get(pk=userID)
self.admin = admin
Expand Down

0 comments on commit 041a27b

Please sign in to comment.