mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
bind: Add validator
This commit is contained in:
1 parent
0312c41415
commit
e0abdbd0e9
3 files changed
+38
-12
No files matched your search
@@ -19,8 +19,11 @@
|
||||
Plinth module to configure BIND server
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.validators import validate_ipv46_address
|
||||
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
@@ -123,7 +126,7 @@ def get_default():
|
||||
set_forwarding = False
|
||||
else:
|
||||
set_forwarding = True
|
||||
if '//dnssec-enable yes;' in data:
|
||||
if '// dnssec-enable yes;' in data or '//dnssec-enable yes;' in data:
|
||||
enable_dnssec = False
|
||||
else:
|
||||
enable_dnssec = True
|
||||
@@ -132,7 +135,10 @@ def get_default():
|
||||
for line in data:
|
||||
|
||||
if flag == 1:
|
||||
dns_set = line[:len(line)-1]
|
||||
if '//' in line:
|
||||
dns_set = ''
|
||||
else:
|
||||
dns_set = re.sub('[;]', '', line)
|
||||
flag = 0
|
||||
if 'forwarders {' in line:
|
||||
flag = 1
|
||||
@@ -143,3 +149,12 @@ def get_default():
|
||||
'dns_set': dns_set
|
||||
}
|
||||
return conf
|
||||
|
||||
|
||||
def validate(IP):
|
||||
for ip in IP.split():
|
||||
try :
|
||||
validate_ipv46_address(ip)
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
Reference in new issue
Block a user