Closed iliyazpasha1 closed 3 years ago
Please change the logging level to debug (add LOG_CONSOLE_SEVERITY = 'DEBUG'
to conf.py
) and let me know what you see between these lines:
2017-06-22 14:56:10,821 : INFO : DISCOVER from 50:7b:9d:0f:c2:73 via port 67 2017-06-22 14:56:10,822 : CRITICAL : Unable to handle DISCOVER from 50:7b:9d:0f:c2:73:
https://github.com/flan/staticdhcpd/blob/2.0.x/staticDHCPd/staticdhcpdlib/dhcp.py#L342 is the relevant bit of code being executed. To reach the point where it would try to filter the list, the database must be returning something, or more specifically, a bunch of somethings, but the INI database model is only supposed to be able to return a single match, as defined in https://github.com/flan/staticdhcpd/blob/2.0.x/staticDHCPd/staticdhcpdlib/databases/_ini.py#L247
Sorry, I meant to write LOG_FILE_SEVERITY = 'DEBUG'
, not console
This is what I am getting on console 2017-06-23 12:06:02,182 : DEBUG : Discarded packet of type 2017-06-23 12:06:19,143 : DEBUG : DISCOVER from 50:7b:9d:0f:c2:73 via port 67 2017-06-23 12:06:19,144 : INFO : DISCOVER from 50:7b:9d:0f:c2:73 via port 67 2017-06-23 12:06:19,144 : DEBUG : Multiple (count=10) definitions found 2017-06-23 12:06:19,144 : CRITICAL : Unable to handle DISCOVER from 50:7b:9d:0f:c2:73:
Please go through handleUnknownMAC() method implemented in conf file
def handleUnknownMAC(mac): return ('192.168.0.100','guestbox','255.255.255.0','192.168.0.255','guestbox.example.org.','192.168.0.5,192.168.0.6,192.168.0.7','192.168.0.8,192.168.0.9',600,'192.168.0.0/24',0)
Multiple(count=10) is nothing but length of tuple
I wasn't able to find that particular implementation in the file to which you linked or in any other branch, so I wasn't sure what the actual input-data was.
The issue seems to be that you're mixing 1.6.0 stuff with the 2.0.x codebase and, somehow, one of the patches I accepted broke backwards-compatibility with the old return-format. I'll write a fix for that now, wrapping old-style returns when the legacy signature is found, but the correct solution is explained in the docs: http://static.uguu.ca/projects/staticDHCPd/doc/customisation/scripting.html#handleunknownmac which, unfortunately, does not provide an example showing how to initialise one of the expected return-objects. I'll push what I'm writing here into the docs to help anyone who comes across this in the future:
import databases.generic.Definition
handleUnknownMAC(packet, method, mac, client_ip, relay_ip, port):
return databases.generic.Definition(
ip='192.168.0.100', lease_time=600,
subnet='192.168.0.0/24', serial=0,
hostname='guestbox',
#gateways=None, #The old format didn't support per-definition gateways
subnet_mask='255.255.255.0',
broadcast_address='192.168.0.255',
domain_name='guestbox.example.org.',
domain_name_servers=['192.168.0.5', '192.168.0.6', '192.168.0.7'],
ntp_servers=['192.168.0.8', '192.168.0.9'],
)
You can coerce the input parameters into strings or anything else by testing for equality, like client_ip == '127.0.0.1'
or do it explicitly with str(client_ip)
.
I have gone through this suggestion https://github.com/nzjrs/staticdhcpd/blob/master/conf.py . But it leads to other errors like :- 2017-06-22 14:55:59,644 : WARNING : ---------------------------------------- 2017-06-22 14:55:59,644 : WARNING : All subsystems initialised; now serving 2017-06-22 14:55:59,645 : WARNING : ---------------------------------------- 2017-06-22 14:56:10,821 : INFO : DISCOVER from 50:7b:9d:0f:c2:73 via port 67 2017-06-22 14:56:10,822 : CRITICAL : Unable to handle DISCOVER from 50:7b:9d:0f:c2:73: Traceback (most recent call last):
File "/home/spanidea/Downloads/staticdhcpd-2.0.x/staticDHCPd/staticdhcpdlib/dhcp.py", line 372, in wrappedHandler f(self, wrapper)
File "/home/spanidea/Downloads/staticdhcpd-2.0.x/staticDHCPd/staticdhcpdlib/dhcp.py", line 468, in _handleDHCPDiscover definition = wrapper.retrieveDefinition(override_ip=True, override_ip_value=None)
File "/home/spanidea/Downloads/staticdhcpd-2.0.x/staticDHCPd/staticdhcpdlib/dhcp.py", line 354, in retrieveDefinition self.giaddr, self.port,
File "/home/spanidea/Downloads/staticdhcpd-2.0.x/staticDHCPd/staticdhcpdlib/config.py", line 227, in filterRetrievedDefinitions raise ValueError('No handler exists for multi-definition matches; implement filterRetrievedDefinitions()')
ValueError: No handler exists for multi-definition matches; implement filterRetrievedDefinitions()