Skip to content

Commit

Permalink
fixed: command set dhcpmode console ref.
Browse files Browse the repository at this point in the history
  • Loading branch information
mh4x0f committed Oct 23, 2023
1 parent 4a3ce9e commit 5328f08
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion wifipumpkin3/core/common/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def initialize_core(self):
"parser_set_security": self.wireless_controller.Settings,
"parser_set_hostapd_config": self.wireless_controller.Settings,
"parser_set_dhcpconf": self.wireless_controller.Settings,
"parser_set_dhcpmode": self.dns_controller.Active,
"parser_set_dhcpmode": self.dhcp_controller.Active,
}
self.parser_autcomplete_func = {}

Expand Down
35 changes: 35 additions & 0 deletions wifipumpkin3/core/servers/dhcp/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,41 @@ def removeInactivityClient(self, mac: str):
def getStaClients(self):
return self._connected

def parser_set_dhcpmode(self, status, command):
if len(command.split(".")) == 2:
try:
# command = dhcpmode.pydns_verbose true
dhcpmode, key_setting = (
command.split(".")[0],
command.split(".")[1].split()[0],
)
if key_setting in self.conf.get_all_childname("accesspoint"):
self.conf.set("accesspoint", key_setting, status)
else:
print(
display_messages(
"unknown setting: {}".format(key_setting), error=True
)
)
except IndexError:
print(display_messages("unknown sintax command", error=True))
else:
try:
id_dhcp = command.split()[1]
if not id_dhcp in self.parent.dhcp_controller.getInfo().keys():
print(
display_messages(
"the parameter id {} was not found.".format(
setcolor(id_dhcp, color="red")
),
error=True,
)
)
return
self.parent.dhcp_controller.setDhcpMode(id_dhcp)
except IndexError:
print(display_messages("unknown sintax command", error=True))

class DHCPSettings(CoreSettings):
Name = "WP DHCP"
ID = "DHCP"
Expand Down
35 changes: 1 addition & 34 deletions wifipumpkin3/core/servers/dns/pyDNSServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,4 @@ def boot(self):
self.reactor.sendRequests.connect(self.LogOutput)
self.reactor.setObjectName(self.ID)

def parser_set_dhcpmode(self, status, command):
if len(command.split(".")) == 2:
try:
# command = dhcpmode.pydns_verbose true
dhcpmode, key_setting = (
command.split(".")[0],
command.split(".")[1].split()[0],
)
if key_setting in self.conf.get_all_childname("accesspoint"):
self.conf.set("accesspoint", key_setting, status)
else:
print(
display_messages(
"unknown setting: {}".format(key_setting), error=True
)
)
except IndexError:
print(display_messages("unknown sintax command", error=True))
else:
try:
id_dhcp = command.split()[1]
if not id_dhcp in self.root.dhcp_controller.getInfo().keys():
print(
display_messages(
"the parameter id {} was not found.".format(
setcolor(id_dhcp, color="red")
),
error=True,
)
)
return
self.root.dhcp_controller.setDhcpMode(id_dhcp)
except IndexError:
print(display_messages("unknown sintax command", error=True))

0 comments on commit 5328f08

Please sign in to comment.