mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
bind: forwarding works fine now
This commit is contained in:
parent
95265426a9
commit
8c0d8e9db2
13
actions/bind
13
actions/bind
@ -28,6 +28,11 @@ from plinth import action_utils
|
||||
|
||||
CONFIG_FILE = '/etc/bind/named.conf.options'
|
||||
|
||||
value1 = 'acl goodclients { \n localhost;\n};\n'
|
||||
value2 = ' recursion yes;\n allow-query { goodclients; };\n\n'
|
||||
value3 = ' // 8.8.8.8;\n // 8.8.4.4;\n'
|
||||
value4 = ' //forward only;\n'
|
||||
|
||||
def parse_arguments():
|
||||
"""Return parsed command line arguments as dictionary"""
|
||||
parser = argparse.ArgumentParser()
|
||||
@ -52,11 +57,13 @@ def subcommand_setup(_):
|
||||
contents.insert(0, value1)
|
||||
contents.insert(4, value2)
|
||||
contents.insert(15, value3)
|
||||
contents.insert(18, value4)
|
||||
|
||||
f = open(CONFIG_FILE, "w")
|
||||
contents = "".join(contents)
|
||||
f.write(contents)
|
||||
f.close()
|
||||
action_utils.service_restart('bind9')
|
||||
|
||||
def subcommand_configure(arguments):
|
||||
"""Configure BIND."""
|
||||
@ -68,7 +75,7 @@ def subcommand_configure(arguments):
|
||||
|
||||
|
||||
def set_forwarding(choice):
|
||||
if choice == False:
|
||||
if choice == "false":
|
||||
flag = 0
|
||||
data = [line.strip() for line in open(CONFIG_FILE, 'r')]
|
||||
if 'forwarders {' in data and not '// forwarders {' in data:
|
||||
@ -77,7 +84,7 @@ def set_forwarding(choice):
|
||||
if 'forwarders {' in line and not '// forwarders {' in line:
|
||||
flag = 1
|
||||
if flag == 1:
|
||||
line = ' //'+line
|
||||
line = ' // '+line
|
||||
if 'forward only' in line:
|
||||
flag = 0
|
||||
f.write(line+'\n')
|
||||
@ -85,7 +92,7 @@ def set_forwarding(choice):
|
||||
|
||||
|
||||
|
||||
if choice == True:
|
||||
else:
|
||||
flag = 0
|
||||
data = [line.strip() for line in open(CONFIG_FILE, 'r')]
|
||||
if '// forwarders {' in data:
|
||||
|
||||
@ -32,7 +32,7 @@ from plinth.views import ServiceView
|
||||
|
||||
version = 1
|
||||
|
||||
depends = ['apps']
|
||||
depends = ['system']
|
||||
|
||||
title = _('Domain Name Server \n (BIND)')
|
||||
|
||||
@ -55,10 +55,6 @@ description = [
|
||||
|
||||
CONFIG_FILE = '/etc/bind/named.conf.options'
|
||||
|
||||
value1 = 'acl goodclients { \n localhost;\n};\n'
|
||||
value2 = ' recursion yes;\n allow-query { goodclients; };\n\n'
|
||||
value3 = ' // 8.8.8.8;\n // 8.8.4.4;\n'
|
||||
|
||||
|
||||
def init():
|
||||
"""Intialize the BIND module."""
|
||||
@ -96,13 +92,11 @@ def setup(helper, old_version=None):
|
||||
def enable():
|
||||
"""Enable the module."""
|
||||
actions.superuser_run('service', ['enable', managed_services[0]])
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def disable():
|
||||
"""Disable the module."""
|
||||
actions.superuser_run('service', ['disable', managed_services[0]])
|
||||
frontpage.remove_shortcut('bind')
|
||||
|
||||
|
||||
def diagnose():
|
||||
@ -113,20 +107,20 @@ def diagnose():
|
||||
results.append(action_utils.diagnose_port_listening(53, 'udp6'))
|
||||
|
||||
return results
|
||||
|
||||
|
||||
|
||||
def default_config():
|
||||
"""Setp BIND configuration"""
|
||||
actions.superuser_run('bind', ['setup'])
|
||||
|
||||
|
||||
|
||||
def get_default():
|
||||
"""Get initial value for forwarding"""
|
||||
f = open(CONFIG_FILE, "r")
|
||||
contents = f.readlines()
|
||||
if '// forwarders {' in contents:
|
||||
data = [line.strip() for line in open(CONFIG_FILE, 'r')]
|
||||
if '// forwarders {' in data:
|
||||
conf = {
|
||||
'set_forwarding': False}
|
||||
else:
|
||||
conf = {
|
||||
'set_forwarding': True}
|
||||
return conf
|
||||
|
||||
@ -29,4 +29,5 @@ class BindForm(ServiceForm):
|
||||
"""BIND configuration form"""
|
||||
set_forwarding = forms.BooleanField(
|
||||
label=_('Enable forwarding'),
|
||||
required=False)
|
||||
required=False,
|
||||
help_text=_('Enable forwarding on your BIND server'))
|
||||
|
||||
@ -21,9 +21,9 @@ URLs for the BIND module
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from plinth.modules.bind import BindServiceView
|
||||
from plinth.modules.bind.views import BindServiceView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/bind/$', BindServiceView.as_view(), name='index'),
|
||||
url(r'^sys/bind/$', BindServiceView.as_view(), name='index'),
|
||||
]
|
||||
|
||||
@ -53,7 +53,7 @@ class BindServiceView(ServiceView): # pylint: disable=too-many-ancestors
|
||||
value = 'true' if data['set_forwarding'] else 'false'
|
||||
actions.superuser_run(
|
||||
'bind',
|
||||
['configure', '--set_forwarding', value])
|
||||
['configure', '--set-forwarding', value])
|
||||
messages.success(self.request,
|
||||
_('Set forwarding configuration updated'))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user