From 8a4d5b3123b8395b6a81009a569b5851f9c89ce7 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 2 Sep 2019 14:33:12 +0100 Subject: [PATCH] Add ability to prevent users specifying their own dns nameservers --- modules/ip_addresses.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/ip_addresses.py b/modules/ip_addresses.py index 93c16c2d..66c59826 100644 --- a/modules/ip_addresses.py +++ b/modules/ip_addresses.py @@ -15,6 +15,8 @@ class DnsSetting(utils.Setting): return value return None +@utils.export("botset", utils.BoolSetting("configurable-nameservers", + "Whether or not users can configure their own nameservers")) @utils.export("serverset", DnsSetting("dns-nameserver", "Set DNS nameserver", example="8.8.8.8")) @utils.export("channelset", DnsSetting("dns-nameserver", @@ -28,12 +30,14 @@ class Module(ModuleManager.BaseModule): :prefix: DNS """ args = event["args_split"][:] - nameserver = event["channel"].get_setting("dns-nameserver", - event["server"].get_setting("dns-nameserver", None)) - for i, arg in enumerate(args): - if arg[0] == "@": - nameserver = args.pop(i)[1:] - break + nameserver = None + if self.bot.get_setting("configurable-nameservers", True): + nameserver = event["channel"].get_setting("dns-nameserver", + event["server"].get_setting("dns-nameserver", None)) + for i, arg in enumerate(args): + if arg[0] == "@": + nameserver = args.pop(i)[1:] + break hostname = args[0]