Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ptftplib/dhcpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def __init__(self, pkt):

# Strip off the ethernet frame and check the IP packet type. It should
# be UDP (0x11)
# for python3 it's bytes, need to decode to str first
if type(pkt) is bytes:
pkt = pkt.decode(errors='ignore')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that I think this should happen in DHCPServer.serve_forever() (line 251):

import six
...
pkt = DhcpPacket(six.ensure_str(data))
self.handle_dhcp_request(pkt)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about this:
zhouronghua#1 (comment)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Can you get this into this PR? Don't forget to add six to the requirements.txt file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Can you get this into this PR? Don't forget to add six to the requirements.txt file.

sorry, it doesn't work, the content of the data have changed, i prefer to drop this PR, and adapt ord only

pkt = pkt[14:]
if ord(pkt[9]) != IP_UDP_PROTO:
raise NotDhcpPacketError()
Expand Down