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

Commit

Permalink
Merge pull request #99 from jjnicola/fix-ip-range
Browse files Browse the repository at this point in the history
Fix target_to_ipv4_short().
  • Loading branch information
ArnoStiefvater authored Apr 9, 2019
2 parents 43c50b6 + d570057 commit 5898b3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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)

0 comments on commit 5898b3a

Please sign in to comment.