File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -45,5 +45,4 @@ def get_frame(self) -> numpy.ndarray:
4545 logger .error (
4646 "An error occurred while capturing the frame: %s" , error )
4747 raise RuntimeError from error
48- return cv2 .rotate (frame ,
49- cv2 .ROTATE_90_COUNTERCLOCKWISE )
48+ return frame
Original file line number Diff line number Diff line change 22The strategy which searches for IP addresses.
33"""
44from core .strategies .wifi .base_wifi_strategy import BaseWiFiStrategy
5- from core .utils .datatypes import WiFiStrategyResult
5+ from core .utils .datatypes import ConnectedDeviceResult , WiFiStrategyResult
66from core .utils .logger import get_logger
7- from core .utils .program_launcher import PingCommands , run_program
7+ from core .utils .program_launcher import ArpScanCommands , PingCommands , run_program
88
99# Add logging support.
1010logger = get_logger (__name__ )
@@ -37,3 +37,12 @@ def check_protectors(self) -> WiFiStrategyResult:
3737 return WiFiStrategyResult (protector , True )
3838 logger .debug ("No protectors found." )
3939 return WiFiStrategyResult (None , False )
40+
41+ # Internal methods
42+ def _get_all_connected (self ) -> list [ConnectedDeviceResult ]:
43+ """This method returns a list of addresses of the clients connected to the network."""
44+ output = run_program (ArpScanCommands .GET_CONNECTED_IP_ADDRESSES )
45+ ip_addrs = output .split ('\n ' )
46+ ip_addrs = ip_addrs [:- 1 ]
47+ logger .debug ("Connected devices: %s" , str (ip_addrs ))
48+ return [ConnectedDeviceResult (mac_addr .upper ()) for mac_addr in ip_addrs ]
Original file line number Diff line number Diff line change 55from enum import Enum
66
77
8- class ICommand (Enum , str ):
8+ class ICommand (str , Enum ):
99 """Interface for program commands."""
1010
1111
@@ -15,6 +15,8 @@ class ArpScanCommands(ICommand):
1515 INSTALL_PROGRAM = "sudo apt-get install arp-scan"
1616 GET_CONNECTED_MAC_ADDRESSES = "sudo arp-scan --localnet " \
1717 "| grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'"
18+ GET_CONNECTED_IP_ADDRESSES = "sudo arp-scan --localnet " \
19+ "| grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}'"
1820
1921
2022class PingCommands (ICommand ):
Original file line number Diff line number Diff line change 1414from core .strategies .eye .picamera_strategy import PiCameraStrategy
1515from core .strategies .notifier .telegram_strategy import TelegramStrategy
1616from core .strategies .notifier .whatsapp_strategy import WhatsappStrategy
17- from core .strategies .wifi .admin_panel_strategy import AdminPanelStrategy
17+ from core .strategies .wifi .ipaddress_strategy import IpAddressStrategy
1818from core .utils .datatypes import Protector , TelegramReciever
1919from core .utils .fileio_adaptor import upload_to_fileio
2020
@@ -44,7 +44,7 @@ def main():
4444 reciever ['chat_id' ]))
4545
4646 # Create a Protector within IpAddressStrategy.
47- network_strategy = AdminPanelStrategy ( strategy_config [ 'admin_panel_strategy' ] )
47+ network_strategy = IpAddressStrategy ( )
4848 for protector in config ['protectors' ]:
4949 network_strategy .add_protector (Protector (protector ['name' ],
5050 protector ['address' ]))
You can’t perform that action at this time.
0 commit comments