Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Fix target_to_ipv4_short(). #99

Merged
merged 2 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion ospd/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def target_to_ipv4_short(target):
end_value = int(splitted[1])
except (socket.error, ValueError):
return None
start_value = int(binascii.hexlify(start_packed[3]), 16)
start_value = int(binascii.hexlify(bytes(start_packed[3])), 16)
if end_value < 0 or end_value > 255 or end_value < start_value:
return None
end_packed = start_packed[0:3] + struct.pack('B', end_value)
Expand Down
9 changes: 7 additions & 2 deletions tests/testTargetConvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@ def test24Net(self):
self.assertEqual(len(addresses), 254)
for i in range(1, 255):
self.assertTrue('195.70.81.%d' % i in addresses)



def testRange(self):
addresses = target_str_to_list('195.70.81.1-10')
self.assertFalse(addresses is None)
self.assertEqual(len(addresses), 10)
for i in range(1, 10):
self.assertTrue('195.70.81.%d' % i in addresses)