From 4730480db96c1642582afa26f2325f1619195bdd Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Mon, 26 Feb 2018 17:35:00 +0200 Subject: [PATCH 1/2] Remove ClassCRange and RelativeRange --- infection_monkey/network/range.py | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/infection_monkey/network/range.py b/infection_monkey/network/range.py index 2698d6803..4e100378e 100644 --- a/infection_monkey/network/range.py +++ b/infection_monkey/network/range.py @@ -53,35 +53,6 @@ class NetworkRange(object): return socket.inet_ntoa(struct.pack(">L", num)) -class ClassCRange(NetworkRange): - def __init__(self, base_address, shuffle=True): - base_address = struct.unpack(">L", socket.inet_aton(base_address))[0] & 0xFFFFFF00 - super(ClassCRange, self).__init__(base_address, shuffle=shuffle) - - def __repr__(self): - return "" % (self._number_to_ip(self._base_address + 1), - self._number_to_ip(self._base_address + 254)) - - def _get_range(self): - return range(1, 254) - - -class RelativeRange(NetworkRange): - def __init__(self, base_address, shuffle=True): - base_address = struct.unpack(">L", socket.inet_aton(base_address))[0] - super(RelativeRange, self).__init__(base_address, shuffle=shuffle) - self._size = 1 - - def __repr__(self): - return "" % (self._number_to_ip(self._base_address - self._size), - self._number_to_ip(self._base_address + self._size)) - - def _get_range(self): - lower_end = -(self._size / 2) - higher_end = lower_end + self._size - return range(lower_end, higher_end + 1) - - class CidrRange(NetworkRange): def __init__(self, cidr_range, shuffle=True): base_address = 0 From 816be5191bd127ef73caa48bb66ebf93cfad8c23 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Mon, 26 Feb 2018 17:35:32 +0200 Subject: [PATCH 2/2] Add is_in_range as abstract method --- infection_monkey/network/range.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/infection_monkey/network/range.py b/infection_monkey/network/range.py index 4e100378e..4eb4e122c 100644 --- a/infection_monkey/network/range.py +++ b/infection_monkey/network/range.py @@ -29,6 +29,10 @@ class NetworkRange(object): for x in base_range: yield VictimHost(self._number_to_ip(self._base_address + x)) + @abstractmethod + def is_in_range(self, ip_address): + raise NotImplementedError() + @abstractmethod def _get_range(self): raise NotImplementedError()