nickovs / slimDNS

Simple, Lightweight Implementation of Multicast DNS
Apache License 2.0
86 stars 9 forks source link

struct.error: pack_into expected 6 items for packing (got 7) #4

Open nevercast opened 5 years ago

nevercast commented 5 years ago

https://github.com/nickovs/slimDNS/blob/master/slimDNS.py#L326-L327

I'm trying to create a Server object in Python 3.6 on my Windows machine for testing, and I get a pack_into error, it seems there are 7 arguments for the 6 unsigned shorts that pack_into is expecting.

>>> server = SlimDNSServer('192.168.221.131', 'mp')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\REDACTED\slimDNS.py", line 197, in __init__
    self.advertise_hostname(hostname)
  File "C:\Users\REDACTED\slimDNS.py", line 226, in advertise_hostname
    addr = self.resolve_mdns_address(hostname, True)
  File "C:\Users\REDACTED\slimDNS.py", line 359, in resolve_mdns_address
    self.handle_question(q, _answer_handler, fast)
  File "C:\Users\REDACTED\slimDNS.py", line 327, in handle_question
    1, 0, 1, 0, 0, 0, 0)
struct.error: pack_into expected 6 items for packing (got 7)

I'm using master at the time of this issue (https://github.com/nickovs/slimDNS/tree/aac0c2f4c60900f5e213f1002f933b3444c260c3)

nickovs commented 5 years ago

Oops. That's a straightforward bug. There is one too many zeros in that list. I usually only use the code to serve a responder rather than send out questions, which is why I hadn't picked that up. I will fix the code but in the mean time you can just delete the last zero on line 327.

nickovs commented 5 years ago

FWIW, I just checked and it seems that the reason that I had not spotted this bug before is that the micropython implementation of struct.pack_into() ignores extra arguments.