added format 28 files reformatted black library

This commit is contained in:
mh4x0f 2021-10-09 22:40:05 -03:00
parent d6cf0a80b1
commit 47d79c3c21
29 changed files with 189 additions and 113 deletions

View File

@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
- added option for settings dhcp mode pydhcpserver or dhcpd_server
- added new support to run isc_dhcp_server for dns/ dhcp
- added support kali linux iptables nf_tables set iptables_legacy as default #140
- added format 28 files reformatted black library
### Changed

View File

@ -221,7 +221,9 @@ class PumpkinShell(Qt.QObject, ConsoleUI):
self.threads["RogueAP"].extend(self.mitm_controller.ActiveReactor)
self.wireless_controller.ActiveReactor.start()
self.wireless_controller.ActiveReactor.signalApIsRuning.connect(self.signalHostApdProcessIsRunning)
self.wireless_controller.ActiveReactor.signalApIsRuning.connect(
self.signalHostApdProcessIsRunning
)
# if not self.parse_args.restmode:
# self.wireless_controller.ActiveReactor.start()
@ -229,7 +231,7 @@ class PumpkinShell(Qt.QObject, ConsoleUI):
# self.signalHostApdProcessIsRunning
# )
# return
# self.wireless_controller.ActiveReactor.start()
# for thread in self.threads["RogueAP"]:
# if thread is not None:

View File

@ -207,7 +207,7 @@ class Linux(QtCore.QObject):
if not binary_path:
return ""
return binary_path.split("\n")[0]
@staticmethod
def checkIfIptablesVersion():
""" check if iptables version is nf_tables """
@ -215,6 +215,7 @@ class Linux(QtCore.QObject):
return Linux.getBinaryPath("iptables-legacy")
return Linux.getBinaryPath("iptables")
def is_hexadecimal(text):
try:
int(text, 16)

View File

@ -68,7 +68,7 @@ class DHCPController(ControllerBlueprint):
def setDhcpMode(self, id_module_dhcp):
if id_module_dhcp in self.mode.keys():
if 'dhcpd_server' in id_module_dhcp:
if "dhcpd_server" in id_module_dhcp:
self.parent.conf.set("accesspoint", "pydhcp_server", False)
self.parent.conf.set("accesspoint", "pydns_server", False)
self.parent.conf.set("accesspoint", "dhcpd_server", True)

View File

@ -4,6 +4,7 @@ from wifipumpkin3.core.servers.proxy import *
from wifipumpkin3.core.utility.component import ControllerBlueprint
import copy
from wifipumpkin3.exceptions.errors.iptablesException import IptablesPathError
# This file is part of the wifipumpkin3 Open Source Project.
# wifipumpkin3 is licensed under the Apache 2.0.
@ -72,7 +73,7 @@ class ProxyModeController(PluginsUI, ControllerBlueprint):
self.resolverIPtablesVersion()
def resolverIPtablesVersion(self):
iptables_path = Refactor.checkIfIptablesVersion()
iptables_path = Refactor.checkIfIptablesVersion()
if not iptables_path:
raise IptablesPathError("[Error] iptables tool not found")
self.conf.set("iptables", "path_binary", iptables_path)
@ -130,7 +131,6 @@ class ProxyModeController(PluginsUI, ControllerBlueprint):
if not subItem in excluded:
result[item][subItem] = self.proxies_infor[item][subItem]
return result
@classmethod
def disable(cls, val=True):

View File

@ -5,7 +5,10 @@ from wifipumpkin3.core.config.globalimport import *
from wifipumpkin3.core.common.uimodel import *
from wifipumpkin3.core.utility.component import ComponentBlueprint
from wifipumpkin3.core.common.threads import ProcessThread
from wifipumpkin3.exceptions.errors.dhcpException import DHCPServerSettingsError, DHCPdServerNotFound
from wifipumpkin3.exceptions.errors.dhcpException import (
DHCPServerSettingsError,
DHCPdServerNotFound,
)
from wifipumpkin3.core.widgets.default.logger_manager import LoggerManager
# This file is part of the wifipumpkin3 Open Source Project.

View File

@ -8,13 +8,13 @@ from grp import getgrnam
from re import sub
from isc_dhcp_leases.iscdhcpleases import IscDhcpLeases
class DhcpdServer(DHCPServers):
Name = "Dhcpd DHCP Server"
ID = "dhcpd_server"
LogFile = C.LOG_PYDHCPSERVER
ExecutableFile = "dhcpd"
def __init__(self, parent=0):
super(DhcpdServer, self).__init__(parent)
self._isRunning = False
@ -34,10 +34,10 @@ class DhcpdServer(DHCPServers):
if not path.exists(leases[:-12]):
mkdir(leases[:-12])
if not path.isfile(leases):
with open(leases, 'wb') as leaconf:
with open(leases, "wb") as leaconf:
leaconf.close()
uid = getpwnam('root').pw_uid
gid = getgrnam('root').gr_gid
uid = getpwnam("root").pw_uid
gid = getgrnam("root").gr_gid
chown(leases, uid, gid)
def boot(self):
@ -46,43 +46,59 @@ class DhcpdServer(DHCPServers):
self.reactor.setObjectName(self.Name)
def add_DHCP_Requests_clients(self, mac, user_info):
#self.parent.StationMonitor.addRequests(mac,user_info,True)
self.logger.info("{} on {} join the AP".format(user_info["IP"], user_info["MAC"]))
self.logger.info("DHCP: {} to {} hostname:[{}] vendor:[{}]".format(
user_info["MAC"],
user_info["IP"],
user_info["HOSTNAME"],
user_info["VENDOR"]
))
print(display_messages(
# self.parent.StationMonitor.addRequests(mac,user_info,True)
self.logger.info(
"{} on {} join the AP".format(user_info["IP"], user_info["MAC"])
)
self.logger.info(
"DHCP: {} to {} hostname:[{}] vendor:[{}]".format(
user_info["MAC"],
user_info["IP"],
user_info["HOSTNAME"],
user_info["VENDOR"],
)
)
print(
display_messages(
"{} client join the AP IpAddr::[{}]".format(
setcolor(mac, color="green"),
setcolor(user_info["IP"], color="green")
setcolor(user_info["IP"], color="green"),
),
info=True,
))
)
)
def logOutputDhcpServer(self, data):
''' filter: data info sended DHCPD request '''
""" filter: data info sended DHCPD request """
raw_data = data
data = data.split()
if self.conf.get("accesspoint", "status_ap", format=bool):
if len(data) == 8:
device = sub(r'[)|(]',r'',data[5])
if len(device) == 0: device = 'unknown'
device = sub(r"[)|(]", r"", data[5])
if len(device) == 0:
device = "unknown"
if Refactor.check_is_mac(data[4]):
if data[4] not in self.leases.keys():
self.leases[data[4]] = {'IP': data[2],
'HOSTNAME': device,'MAC': data[4],'VENDOR' : self.get_mac_vendor(data[4])}
self.add_DHCP_Requests_clients(data[4],self.leases[data[4]])
self.leases[data[4]] = {
"IP": data[2],
"HOSTNAME": device,
"MAC": data[4],
"VENDOR": self.get_mac_vendor(data[4]),
}
self.add_DHCP_Requests_clients(data[4], self.leases[data[4]])
elif len(data) == 9:
device = sub(r'[)|(]',r'',data[6])
if len(device) == 0: device = 'unknown'
device = sub(r"[)|(]", r"", data[6])
if len(device) == 0:
device = "unknown"
if Refactor.check_is_mac(data[5]):
if data[5] not in self.leases.keys():
self.leases[data[5]] = {'IP': data[2],
'HOSTNAME': device,'MAC': data[5],'VENDOR' : self.get_mac_vendor(data[5])}
self.add_DHCP_Requests_clients(data[5],self.leases[data[5]])
self.leases[data[5]] = {
"IP": data[2],
"HOSTNAME": device,
"MAC": data[5],
"VENDOR": self.get_mac_vendor(data[5]),
}
self.add_DHCP_Requests_clients(data[5], self.leases[data[5]])
elif len(data) == 7:
if Refactor.check_is_mac(data[4]):
if data[4] not in self.leases.keys():
@ -96,16 +112,28 @@ class DhcpdServer(DHCPServers):
item = leases.get_current()
hostname = item[data[4]]
except:
hostname = 'unknown'
if hostname == None or len(hostname) == 0:hostname = 'unknown'
self.leases[data[4]] = {'IP': data[2],'HOSTNAME': hostname,
'MAC': data[4], 'VENDOR': self.get_mac_vendor(data[4])}
self.add_DHCP_Requests_clients(data[4],self.leases[data[4]])
hostname = "unknown"
if hostname == None or len(hostname) == 0:
hostname = "unknown"
self.leases[data[4]] = {
"IP": data[2],
"HOSTNAME": hostname,
"MAC": data[4],
"VENDOR": self.get_mac_vendor(data[4]),
}
self.add_DHCP_Requests_clients(data[4], self.leases[data[4]])
self.logger.info(raw_data)
Refactor.writeFileDataToJson(C.CLIENTS_CONNECTED, self.leases, "w")
@property
def commandargs(self):
return ['-d', '-f', '-lf', C.DHCPLEASES_PATH, '-cf',
'/etc/dhcp/dhcpd.conf', self.ifaceHostapd]
return [
"-d",
"-f",
"-lf",
C.DHCPLEASES_PATH,
"-cf",
"/etc/dhcp/dhcpd.conf",
self.ifaceHostapd,
]

View File

@ -58,7 +58,7 @@ class MitmMode(Widget):
sendError = QtCore.pyqtSignal(str)
sendSingal_disable = QtCore.pyqtSignal(object)
config = None
TypeButton = 1 # 0 for Switch, 1 for Radio
TypeButton = 1 # 0 for Switch, 1 for Radio
def __init__(self, parent=None):
super(MitmMode, self).__init__(parent)

View File

@ -55,7 +55,7 @@ class Responder3(MitmMode):
ModSettings = True
ModType = "server" # proxy or server
config = None
TypeButton = 0 # 0 for Switch, 1 for Radio
TypeButton = 0 # 0 for Switch, 1 for Radio
def __init__(self, parent, FSettingsUI=None, main_method=None, **kwargs):
super(Responder3, self).__init__(parent)

View File

@ -58,7 +58,7 @@ class Sniffkin3(MitmMode):
_cmd_array = []
ModSettings = True
ModType = "server"
TypeButton = 0 # 0 for Switch, 1 for Radio
TypeButton = 0 # 0 for Switch, 1 for Radio
def __init__(self, parent=None, **kwargs):
super(Sniffkin3, self).__init__(parent)

View File

@ -61,7 +61,7 @@ class CaptivePortal(ProxyMode):
RunningPort = 80
ModType = "proxy"
TypePlugin = 1
TypeButton = 1 # 0 for Switch, 1 for Radio
TypeButton = 1 # 0 for Switch, 1 for Radio
def __init__(self, parent=None, **kwargs):
super(CaptivePortal, self).__init__(parent)

View File

@ -26,7 +26,7 @@ class NoProxy(ProxyMode):
Author = "Pumpkin-Dev"
Hidden = True
TypePlugin = 1
TypeButton = 1 # 0 for Switch, 1 for Radio
TypeButton = 1 # 0 for Switch, 1 for Radio
def __init__(self, parent, **kwargs):
super(NoProxy, self).__init__(parent)

View File

@ -47,7 +47,7 @@ class ProxyMode(Widget, ComponentBlueprint):
_cmd_array = []
Hidden = True
plugins = []
TypeButton = 0 # 0 for Switch, 1 for Radio
TypeButton = 0 # 0 for Switch, 1 for Radio
sendError = QtCore.pyqtSignal(str)
sendSingal_disable = QtCore.pyqtSignal(object)
addDock = QtCore.pyqtSignal(object)

View File

@ -58,7 +58,7 @@ class PumpKinProxy(ProxyMode):
RunningPort = 8080
ModType = "proxy"
TypePlugin = 1
TypeButton = 0 # 0 for Switch, 1 for Radio
TypeButton = 0 # 0 for Switch, 1 for Radio
def __init__(self, parent=None, **kwargs):
super(PumpKinProxy, self).__init__(parent)

View File

@ -56,7 +56,9 @@ def init_app(app):
api.add_resource(res_plugins.MitmPluginsResource, "/plugins/info")
api.add_resource(
res_plugins.PluginsInfoResource, "/plugins", "/plugins/<string:plugin_name>/info"
res_plugins.PluginsInfoResource,
"/plugins",
"/plugins/<string:plugin_name>/info",
)
api.add_resource(
@ -66,9 +68,7 @@ def init_app(app):
api.add_resource(
res_proxies.ProxiesInfoResource, "/proxies", "/proxies/<string:proxy_name>/info"
)
api.add_resource(
res_proxies.ProxiesAllInfoResource, "/proxies", "/proxies/info"
)
api.add_resource(res_proxies.ProxiesAllInfoResource, "/proxies", "/proxies/info")
api.add_resource(res_plugins.SettingsPluginsResource, "/<string:plugin_id>/plugins")

View File

@ -55,7 +55,8 @@ class LoginResource(Resource):
token = jwt.encode(
{
"public_id": admin_public_id,
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=3000),
"exp": datetime.datetime.utcnow()
+ datetime.timedelta(minutes=3000),
},
admin_SECRET_KEY,
)

View File

@ -5,6 +5,7 @@ from io import StringIO
import sys
from wifipumpkin3.core.servers.rest.ext.auth import token_required
from wifipumpkin3.core.servers.rest.ext.exceptions import exception
# This file is part of the wifipumpkin3 Open Source Project.
# wifipumpkin3 is licensed under the Apache 2.0.
@ -57,11 +58,8 @@ class CommandsPostResource(Resource):
def post(self, command=None):
data = request.get_json(force=True)
if not "commands" in data:
return exception(
"Cannot found that key commands on data",
code=400,
)
return exception("Cannot found that key commands on data", code=400,)
output = []
with Capturing(output) as output:
self.root.onecmd(data.get("commands"))
return jsonify(output)
return jsonify(output)

View File

@ -78,12 +78,18 @@ class getFileLogResource(Resource):
)
class getAllFileLogResource(Resource):
config = SettingsINI.getInstance()
args = ("page", "session", "excludes")
exludes_logs = []
filenames = ("pumpkin_proxy", "pydns_server", "pydhcp_server", "sniffkin3", "captiveportal", "responder3")
filenames = (
"pumpkin_proxy",
"pydns_server",
"pydhcp_server",
"sniffkin3",
"captiveportal",
"responder3",
)
limit_view = 10
session = None
@ -96,7 +102,11 @@ class getAllFileLogResource(Resource):
for line in list_data:
resp_data = {}
if line["record"]["extra"]["session"] == session:
resp_data["time"] = str(datetime.fromtimestamp(line["record"]["time"]["timestamp"]).replace(microsecond=0))
resp_data["time"] = str(
datetime.fromtimestamp(line["record"]["time"]["timestamp"]).replace(
microsecond=0
)
)
resp_data["timestamp"] = line["record"]["time"]["timestamp"]
resp_data["message"] = line["record"]["message"]
resp_data["text"] = line["text"]
@ -105,8 +115,7 @@ class getAllFileLogResource(Resource):
resp_list.append(resp_data)
return sorted(
resp_list,
key=lambda x: datetime.strptime(x['time'], "%Y-%m-%d %H:%M:%S")
resp_list, key=lambda x: datetime.strptime(x["time"], "%Y-%m-%d %H:%M:%S")
)
@token_required
@ -127,11 +136,14 @@ class getAllFileLogResource(Resource):
self.session = request.args.get("session")
for filename in self.filenames:
if os.path.isfile("{}/{}.log".format(C.LOG_BASE, filename)) and filename not in self.exludes_logs:
if (
os.path.isfile("{}/{}.log".format(C.LOG_BASE, filename))
and filename not in self.exludes_logs
):
with open("{}/{}.log".format(C.LOG_BASE, filename), "r") as f:
for line in f:
table.append(json.loads(line))
table = self.parser_data(table, self.session)
data_splited = list(self.chunk(table, self.limit_view))
@ -157,4 +169,4 @@ class getAllFileLogResource(Resource):
"total_count": len(table),
}
}
)
)

View File

@ -59,7 +59,7 @@ class PluginsInfoResource(Resource):
plugin_name, self.key_name
),
code=400,
)
)
proxy_plugins = self.root.mitm_controller.getInfo(excluded=("Config"))
for item in proxy_plugins:
proxy_plugins[item]["Activate"] = self.config.get(
@ -67,6 +67,7 @@ class PluginsInfoResource(Resource):
)
return jsonify(proxy_plugins.get(plugin_name))
class SettingsPluginResource(Resource):
config = SettingsINI.getInstance()
key_name = "mitm_modules"

View File

@ -43,6 +43,7 @@ class ProxysPluginsResource(Resource):
list_plugins.append(proxy_plugins[item])
return jsonify({"proxys": list_plugins})
class ProxiesInfoResource(Resource):
config = SettingsINI.getInstance()
key_name = "proxy_plugins"
@ -60,7 +61,7 @@ class ProxiesInfoResource(Resource):
proxy_name, self.key_name
),
code=400,
)
)
proxy_plugins = self.root.proxy_controller.getInfo(excluded=("Config"))
for item in proxy_plugins:
proxy_plugins[item]["Activate"] = self.config.get(
@ -68,9 +69,11 @@ class ProxiesInfoResource(Resource):
)
return jsonify(proxy_plugins.get(proxy_name))
class ProxiesAllInfoResource(Resource):
config = SettingsINI.getInstance()
key_name = "proxy_plugins"
def __init__(self):
self.root = PumpkinShell.getInstance()
super(ProxiesAllInfoResource, self).__init__()
@ -82,7 +85,7 @@ class ProxiesAllInfoResource(Resource):
proxy_plugins[item]["Activate"] = self.config.get(
self.key_name, proxy_plugins[item]["ID"], format=bool
)
return jsonify({"proxies" : proxy_plugins})
return jsonify({"proxies": proxy_plugins})
class SettingsProxyResource(Resource):

View File

@ -31,10 +31,7 @@ def token_required(f):
token = request.headers["x-access-token"]
if not token:
return make_response(
jsonify({"message": "Token is invalid!"}),
401
)
return make_response(jsonify({"message": "Token is invalid!"}), 401)
conf = SettingsINI.getInstance()
try:
@ -42,15 +39,9 @@ def token_required(f):
data = jwt.decode(token, app_secret_key)
app_public_id = conf.get("rest_api_settings", "public_id")
if app_public_id != data["public_id"]:
return make_response(
jsonify({"message": "Token is invalid!"}),
401
)
return make_response(jsonify({"message": "Token is invalid!"}), 401)
except:
return make_response(
jsonify({"message": "Token is invalid!"}),
401
)
return make_response(jsonify({"message": "Token is invalid!"}), 401)
return f(*args, **kwargs)

View File

@ -1,6 +1,7 @@
from flask import jsonify
def exception(error_message, code=200):
response = jsonify({"code": code, "message": error_message})
response.status_code = code
return response
return response

View File

@ -38,12 +38,12 @@ class ui_DhcpSettingsClass(WidgetBase):
def setup_view(self):
self.radio_dhcpd_server_status = self._conf.get("accesspoint", "dhcpd_server",format=bool)
self.radio_dhcpd_server_status = self._conf.get(
"accesspoint", "dhcpd_server", format=bool
)
self.widget_main = urwid.Padding(
self.menu(u"DHCP Server", self.class_headers.keys()),
left=2,
right=2,
self.menu(u"DHCP Server", self.class_headers.keys()), left=2, right=2,
)
self.top = urwid.Overlay(
self.widget_main,
@ -56,7 +56,6 @@ class ui_DhcpSettingsClass(WidgetBase):
min_height=12,
)
def on_radioButton_changes(self, w, state, user_data):
if "pydhcp_server" == user_data:
self.radio_dhcpd_server_status = False
@ -64,22 +63,30 @@ class ui_DhcpSettingsClass(WidgetBase):
self.radio_dhcpd_server_status = True
def menu(self, title, choices):
body = [urwid.Text(title), urwid.Divider(),urwid.Text(self.desc_dhcp_server) ]
bgroup = [] # button group
self.radioPyDhcpServer = urwid.RadioButton(bgroup, u"PyDHCPServer",
state=not self.radio_dhcpd_server_status,
on_state_change=self.on_radioButton_changes, user_data="pydhcp_server")
body = [urwid.Text(title), urwid.Divider(), urwid.Text(self.desc_dhcp_server)]
self.radioDhcpdServer = urwid.RadioButton(bgroup, u"ISC DHCPServer",
state=self.radio_dhcpd_server_status,
on_state_change=self.on_radioButton_changes, user_data="dhcp_server")
bgroup = [] # button group
self.radioPyDhcpServer = urwid.RadioButton(
bgroup,
u"PyDHCPServer",
state=not self.radio_dhcpd_server_status,
on_state_change=self.on_radioButton_changes,
user_data="pydhcp_server",
)
self.radioDhcpdServer = urwid.RadioButton(
bgroup,
u"ISC DHCPServer",
state=self.radio_dhcpd_server_status,
on_state_change=self.on_radioButton_changes,
user_data="dhcp_server",
)
body.append(self.radioPyDhcpServer)
body.append(self.radioDhcpdServer)
body.append(urwid.Divider())
body.append(urwid.Text(self.desc_ip_range))
for c in choices:
button = urwid.Button(c)
urwid.connect_signal(button, "click", self.item_chosen, c)
@ -111,7 +118,7 @@ class ui_DhcpSettingsClass(WidgetBase):
data_config.append(u"-----------DHCP-----------\n")
for key, value in data_set.items():
self._conf.set("dhcp", key, value)
self._conf.set("dhcp", key, value)
if self.radioDhcpdServer.get_state():
self._conf.set("accesspoint", "pydhcp_server", False)
@ -120,7 +127,7 @@ class ui_DhcpSettingsClass(WidgetBase):
else:
self._conf.set("accesspoint", "pydhcp_server", True)
self._conf.set("accesspoint", "pydns_server", True)
self._conf.set("accesspoint", "dhcpd_server", False)
self._conf.set("accesspoint", "dhcpd_server", False)
response = urwid.Text([u"[DHCP configuration]", u"\n"] + data_config)
done = urwid.Button(u"Ok")
@ -134,7 +141,11 @@ class ui_DhcpSettingsClass(WidgetBase):
def main(self):
self.setup_view()
urwid.MainLoop(self.top, palette=[("reversed", "standout", "")], unhandled_input=self.handleWindow).run()
urwid.MainLoop(
self.top,
palette=[("reversed", "standout", "")],
unhandled_input=self.handleWindow,
).run()
def start(self):
self.main()

View File

@ -239,7 +239,8 @@ class DockerSettings(CoreSettings):
"bssid={}\n".format(self.conf.get("accesspoint", "bssid")),
],
"dhcp-server": [
"subnet %s netmask %s {\n"% (self.DHCP["subnet"], self.DHCP["netmask"]),
"subnet %s netmask %s {\n"
% (self.DHCP["subnet"], self.DHCP["netmask"]),
"authoritative;\n",
"default-lease-time {};\n".format(self.DHCP["leasetimeDef"]),
"max-lease-time {};\n".format(self.DHCP["leasetimeMax"]),

View File

@ -200,7 +200,8 @@ class RestApiSettings(CoreSettings):
"bssid={}\n".format(self.conf.get("accesspoint", "bssid")),
],
"dhcp-server": [
"subnet %s netmask %s {\n"% (self.DHCP["subnet"], self.DHCP["netmask"]),
"subnet %s netmask %s {\n"
% (self.DHCP["subnet"], self.DHCP["netmask"]),
"authoritative;\n",
"default-lease-time {};\n".format(self.DHCP["leasetimeDef"]),
"max-lease-time {};\n".format(self.DHCP["leasetimeMax"]),

View File

@ -188,7 +188,8 @@ class StaticSettings(CoreSettings):
"bssid={}\n".format(self.conf.get("accesspoint", "bssid")),
],
"dhcp-server": [
"subnet %s netmask %s {\n"% (self.DHCP["subnet"], self.DHCP["netmask"]),
"subnet %s netmask %s {\n"
% (self.DHCP["subnet"], self.DHCP["netmask"]),
"authoritative;\n",
"default-lease-time {};\n".format(self.DHCP["leasetimeDef"]),
"max-lease-time {};\n".format(self.DHCP["leasetimeMax"]),

View File

@ -23,4 +23,4 @@ class DHCPServerSettingsError(ExceptionTemplate):
class DHCPdServerNotFound(ExceptionTemplate):
filename = "dhcp_server_dhcpd_not_found"
filename = "dhcp_server_dhcpd_not_found"

View File

@ -19,4 +19,4 @@ from wifipumpkin3.exceptions.base import ExceptionTemplate
class IptablesPathError(ExceptionTemplate):
filename = "iptables_path_not_found"
filename = "iptables_path_not_found"

View File

@ -39,12 +39,27 @@ class DhcpMode(ExtensionUI):
super(DhcpMode, self).__init__(parse_args=self.parse_args, root=self.root)
def help_dhcpmode(self):
print(display_messages("use the command `{} dhcp_id` for change the default dhcp implementation.".format(
print(
display_messages(
"use the command `{} dhcp_id` for change the default dhcp implementation.".format(
setcolor("dhcpmode", color="orange")
), info=True))
),
info=True,
)
)
print(display_messages("Info: ", info=True, sublime=True))
print(display_messages("dhcpd_server : use the ISC DHCP for configure the dns/dhcp server.", info=True))
print(display_messages("pydhcp_server : use the python implementation for configure the dns/dhcp server.", info=True))
print(
display_messages(
"dhcpd_server : use the ISC DHCP for configure the dns/dhcp server.",
info=True,
)
)
print(
display_messages(
"pydhcp_server : use the python implementation for configure the dns/dhcp server.",
info=True,
)
)
print("\n")
def complete_dhcpmode(self, text, args, start_index, end_index):
@ -63,9 +78,14 @@ class DhcpMode(ExtensionUI):
try:
id_dhcp = args.split()[0]
if not id_dhcp in self.root.dhcp_controller.getInfo().keys():
print(display_messages("the parameter id {} was not found.".format(
setcolor(args, color="orange")
), error=True))
print(
display_messages(
"the parameter id {} was not found.".format(
setcolor(args, color="orange")
),
error=True,
)
)
return
self.root.dhcp_controller.setDhcpMode(id_dhcp)
return
@ -84,7 +104,7 @@ class DhcpMode(ExtensionUI):
setcolor("True", color="green")
if instance.isChecked()
else setcolor("False", color="red"),
instance.Name
instance.Name,
]
)
display_tabulate(headers_table, output_table)