Alternative method scan subnet

This commit is contained in:
parent a69c5ac5fb
commit 660fb66fc0
2 changed files with 357 additions and 2 deletions

View file

@ -134,3 +134,292 @@ task: <Task pending name='Task-5' coro=<broadcast_data() done, defined at /home/
task: <Task pending name='Task-3' coro=<broadcast_data() done, defined at /home/merelden/main/compiler/gonets/SRV/api/v1/websocket.py:130> wait_for=<Future pending cb=[Task.task_wakeup()]>> task: <Task pending name='Task-3' coro=<broadcast_data() done, defined at /home/merelden/main/compiler/gonets/SRV/api/v1/websocket.py:130> wait_for=<Future pending cb=[Task.task_wakeup()]>>
2025-11-25 14:10:18,471 - asyncio - ERROR - Task was destroyed but it is pending! 2025-11-25 14:10:18,471 - asyncio - ERROR - Task was destroyed but it is pending!
task: <Task pending name='Task-4' coro=<broadcast_data() done, defined at /home/merelden/main/compiler/gonets/SRV/api/v1/websocket.py:130> wait_for=<Future pending cb=[Task.task_wakeup()]>> task: <Task pending name='Task-4' coro=<broadcast_data() done, defined at /home/merelden/main/compiler/gonets/SRV/api/v1/websocket.py:130> wait_for=<Future pending cb=[Task.task_wakeup()]>>
2025-11-25 16:01:37,990 - asyncio - ERROR - Task was destroyed but it is pending!
task: <Task pending name='Task-3' coro=<broadcast_data() done, defined at /home/merelden/main/compiler/gonets/SRV/api/v1/websocket.py:130> wait_for=<Future pending cb=[Task.task_wakeup()]>>
2025-11-25 16:01:37,990 - asyncio - ERROR - Task was destroyed but it is pending!
task: <Task pending name='Task-5' coro=<broadcast_data() done, defined at /home/merelden/main/compiler/gonets/SRV/api/v1/websocket.py:130> wait_for=<Future pending cb=[Task.task_wakeup()]>>
2025-11-25 16:01:38,310 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:01:38,310 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:01:38,310 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:01:38,310 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:01:38,310 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:01:39,158 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:01:39,159 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:01:39,160 - api.v1.subnet - INFO - Requested subnet scan for: auto-detected
2025-11-25 16:01:39,162 - services.subnet_service - INFO - Auto-detected subnet: 10.0.0.0/8 (IP: 10.1.1.31, Mask: 255.0.0.0 -> /8)
2025-11-25 16:01:39,176 - services.subnet_service - INFO - Local device detected: IP=10.1.1.31, MAC=dc:97:ba:3a:33:0b, Interface=wlp0s20f3
2025-11-25 16:01:39,177 - services.subnet_service - INFO - Detected local device: 10.1.1.31, MAC: dc:97:ba:3a:33:0b
2025-11-25 16:01:39,177 - services.subnet_service - INFO - Scanning subnet: 10.0.0.0/8 with interface: wlp0s20f3
2025-11-25 16:02:45,243 - asyncio - ERROR - Task was destroyed but it is pending!
task: <Task pending name='Task-3' coro=<broadcast_data() done, defined at /home/merelden/main/compiler/gonets/SRV/api/v1/websocket.py:130> wait_for=<Future pending cb=[Task.task_wakeup()]>>
2025-11-25 16:02:45,244 - asyncio - ERROR - Task was destroyed but it is pending!
task: <Task pending name='Task-4' coro=<broadcast_data() done, defined at /home/merelden/main/compiler/gonets/SRV/api/v1/websocket.py:130> wait_for=<Future pending cb=[Task.task_wakeup()]>>
2025-11-25 16:02:51,958 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:02:51,958 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:02:51,959 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:02:51,959 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:02:51,960 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:03:01,569 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:03:01,570 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:03:01,571 - api.v1.subnet - INFO - Requested subnet scan for: 10.1.1.0
2025-11-25 16:03:01,571 - services.subnet_service - WARNING - Local device not found in subnet 10.1.1.0
2025-11-25 16:03:01,571 - services.subnet_service - INFO - Scanning subnet: 10.1.1.0 with interface: wlp0s20f3
2025-11-25 16:03:03,649 - services.subnet_service - INFO - Discovered devices: 0
2025-11-25 16:03:03,662 - services.subnet_service - WARNING - No devices found in subnet 10.1.1.0
2025-11-25 16:03:03,662 - api.v1.subnet - WARNING - No devices found in subnet 10.1.1.0
2025-11-25 16:03:05,021 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:03:05,021 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:03:05,022 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:03:05,023 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:03:05,023 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:03:06,420 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:03:06,420 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:03:06,421 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:03:06,421 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:03:06,422 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:03:15,472 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:03:15,473 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:03:15,474 - api.v1.subnet - INFO - Requested subnet scan for: 10.1.1.0/24
2025-11-25 16:03:15,487 - services.subnet_service - INFO - Local device detected: IP=10.1.1.31, MAC=dc:97:ba:3a:33:0b, Interface=wlp0s20f3
2025-11-25 16:03:15,487 - services.subnet_service - INFO - Detected local device: 10.1.1.31, MAC: dc:97:ba:3a:33:0b
2025-11-25 16:03:15,488 - services.subnet_service - INFO - Scanning subnet: 10.1.1.0/24 with interface: wlp0s20f3
2025-11-25 16:03:17,674 - services.subnet_service - INFO - Discovered devices: 19
2025-11-25 16:03:17,683 - services.subnet_service - WARNING - Failed to determine vendor for MAC c0:83:c9:22:76:14: this event loop is already running.
2025-11-25 16:03:17,684 - services.subnet_service - WARNING - Failed to determine vendor for MAC 94:c6:91:99:d1:61: this event loop is already running.
2025-11-25 16:03:17,684 - services.subnet_service - WARNING - Failed to determine vendor for MAC 20:11:a2:68:02:0f: The vendor for MAC b'2011A268020F' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:03:17,685 - services.subnet_service - WARNING - Failed to determine vendor for MAC b4:4c:3b:33:c1:fa: this event loop is already running.
2025-11-25 16:03:17,692 - services.subnet_service - WARNING - Failed to determine vendor for MAC 5e:28:1f:e5:7d:18: The vendor for MAC b'5E281FE57D18' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:03:17,693 - services.subnet_service - WARNING - Failed to determine vendor for MAC 02:7d:d8:c1:30:04: The vendor for MAC b'027DD8C13004' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:03:17,693 - services.subnet_service - WARNING - Failed to determine vendor for MAC e2:ec:26:f8:6b:25: this event loop is already running.
2025-11-25 16:03:17,693 - services.subnet_service - WARNING - Failed to determine vendor for MAC 38:1f:8d:d2:77:e5: this event loop is already running.
2025-11-25 16:03:17,694 - services.subnet_service - WARNING - Failed to determine vendor for MAC be:61:82:6d:9d:e4: this event loop is already running.
2025-11-25 16:03:17,693 - services.subnet_service - WARNING - Failed to determine vendor for MAC 38:1f:8d:d4:50:d5: this event loop is already running.
2025-11-25 16:03:17,694 - services.subnet_service - WARNING - Failed to determine vendor for MAC 38:1f:8d:d2:02:b5: this event loop is already running.
2025-11-25 16:03:17,694 - asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-32' coro=<AsyncMacLookup.lookup() done, defined at /root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py:97> exception=VendorNotFoundError(b'E2EC26F86B25')>
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 104, in lookup
return self.prefixes[mac[:6]].decode("utf8")
~~~~~~~~~~~~~^^^^^^^^^
KeyError: b'E2EC26'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 106, in lookup
raise VendorNotFoundError(mac)
mac_vendor_lookup.VendorNotFoundError: The vendor for MAC b'E2EC26F86B25' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:03:17,701 - asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-35' coro=<AsyncMacLookup.lookup() done, defined at /root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py:97> exception=VendorNotFoundError(b'BE61826D9DE4')>
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 104, in lookup
return self.prefixes[mac[:6]].decode("utf8")
~~~~~~~~~~~~~^^^^^^^^^
KeyError: b'BE6182'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 106, in lookup
raise VendorNotFoundError(mac)
mac_vendor_lookup.VendorNotFoundError: The vendor for MAC b'BE61826D9DE4' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:03:17,706 - services.subnet_service - INFO - Saved 20 devices to storage/subnets/10.1.1.0_24.json
2025-11-25 16:03:17,706 - services.subnet_service - INFO - Subnet scan 10.1.1.0/24 completed in 2.23 seconds, found 20 devices (active: 20)
2025-11-25 16:03:27,512 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:03:27,512 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:03:27,513 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:03:27,513 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:03:27,514 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:03:29,035 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:03:29,035 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:03:29,035 - api.v1.subnet - INFO - Requested subnet scan for: auto-detected
2025-11-25 16:03:29,037 - services.subnet_service - INFO - Auto-detected subnet: 10.0.0.0/8 (IP: 10.1.1.31, Mask: 255.0.0.0 -> /8)
2025-11-25 16:03:29,049 - services.subnet_service - INFO - Local device detected: IP=10.1.1.31, MAC=dc:97:ba:3a:33:0b, Interface=wlp0s20f3
2025-11-25 16:03:29,049 - services.subnet_service - INFO - Detected local device: 10.1.1.31, MAC: dc:97:ba:3a:33:0b
2025-11-25 16:03:29,049 - services.subnet_service - INFO - Scanning subnet: 10.0.0.0/8 with interface: wlp0s20f3
2025-11-25 16:06:03,717 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:06:03,718 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:06:03,718 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:06:03,719 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:06:03,719 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:06:05,071 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:06:05,072 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:06:05,073 - api.v1.subnet - INFO - Requested subnet scan for: auto-detected
2025-11-25 16:06:05,075 - services.subnet_service - INFO - Auto-detected subnet: 10.0.0.0/8 (IP: 10.1.1.31, Mask: 255.0.0.0 -> /8)
2025-11-25 16:06:05,087 - services.subnet_service - INFO - Local device detected: IP=10.1.1.31, MAC=dc:97:ba:3a:33:0b, Interface=wlp0s20f3
2025-11-25 16:06:05,087 - services.subnet_service - INFO - Detected local device: 10.1.1.31, MAC: dc:97:ba:3a:33:0b
2025-11-25 16:06:05,087 - services.subnet_service - INFO - Scanning subnet: 10.0.0.0/8 with interface: wlp0s20f3
2025-11-25 16:06:17,889 - api.v1.websocket - INFO - Client disconnected
2025-11-25 16:07:07,658 - api.v1.websocket - INFO - Client disconnected
2025-11-25 16:07:12,680 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:07:12,680 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:07:12,680 - api.v1.subnet - INFO - Requested subnet scan for: 10.1.1.0
2025-11-25 16:07:12,681 - services.subnet_service - WARNING - Local device not found in subnet 10.1.1.0
2025-11-25 16:07:12,681 - services.subnet_service - INFO - Scanning subnet: 10.1.1.0 with interface: wlp0s20f3
2025-11-25 16:07:14,770 - services.subnet_service - INFO - Discovered devices: 0
2025-11-25 16:07:14,777 - services.subnet_service - WARNING - No devices found in subnet 10.1.1.0
2025-11-25 16:07:14,778 - api.v1.subnet - WARNING - No devices found in subnet 10.1.1.0
2025-11-25 16:07:22,413 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:07:22,414 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:07:22,415 - api.v1.subnet - INFO - Requested subnet scan for: 10.1.1.0/24
2025-11-25 16:07:22,429 - services.subnet_service - INFO - Local device detected: IP=10.1.1.31, MAC=dc:97:ba:3a:33:0b, Interface=wlp0s20f3
2025-11-25 16:07:22,429 - services.subnet_service - INFO - Detected local device: 10.1.1.31, MAC: dc:97:ba:3a:33:0b
2025-11-25 16:07:22,430 - services.subnet_service - INFO - Scanning subnet: 10.1.1.0/24 with interface: wlp0s20f3
2025-11-25 16:07:24,629 - services.subnet_service - INFO - Discovered devices: 0
2025-11-25 16:07:24,637 - services.subnet_service - INFO - Saved 20 devices to storage/subnets/10.1.1.0_24.json
2025-11-25 16:07:24,637 - services.subnet_service - INFO - Subnet scan 10.1.1.0/24 completed in 2.22 seconds, found 20 devices (active: 1)
2025-11-25 16:07:55,744 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:07:55,745 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:07:55,746 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:07:55,748 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:07:55,749 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:07:57,100 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:07:57,102 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:07:57,102 - api.v1.subnet - INFO - Requested subnet scan for: auto-detected
2025-11-25 16:07:57,105 - services.subnet_service - INFO - Auto-detected subnet: 10.0.0.0/8 (IP: 10.1.1.31, Mask: 255.0.0.0 -> /8)
2025-11-25 16:07:57,125 - services.subnet_service - INFO - Local device detected: IP=10.1.1.31, MAC=dc:97:ba:3a:33:0b, Interface=wlp0s20f3
2025-11-25 16:07:57,125 - services.subnet_service - INFO - Detected local device: 10.1.1.31, MAC: dc:97:ba:3a:33:0b
2025-11-25 16:07:57,125 - services.subnet_service - INFO - Scanning subnet: 10.0.0.0/8 with interface: wlp0s20f3
2025-11-25 16:08:01,742 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:08:01,743 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:08:01,745 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:08:01,749 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:08:01,751 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:08:06,690 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:08:06,702 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:08:06,744 - api.v1.subnet - INFO - Requested subnet scan for: 10.1.1.0/24
2025-11-25 16:08:06,772 - services.subnet_service - WARNING - Invalid last_seen format for device dc:91:66:59:0c:1c
2025-11-25 16:08:06,785 - services.subnet_service - WARNING - Invalid last_seen format for device c0:83:c9:22:76:14
2025-11-25 16:08:06,806 - services.subnet_service - WARNING - Invalid last_seen format for device c0:83:c9:22:76:27
2025-11-25 16:08:06,813 - services.subnet_service - WARNING - Invalid last_seen format for device 54:16:51:32:d0:df
2025-11-25 16:08:06,813 - services.subnet_service - WARNING - Invalid last_seen format for device 20:11:a2:68:02:0f
2025-11-25 16:08:06,813 - services.subnet_service - WARNING - Invalid last_seen format for device 38:1f:8d:d2:77:e5
2025-11-25 16:08:06,830 - services.subnet_service - WARNING - Invalid last_seen format for device 38:1f:8d:d4:50:d5
2025-11-25 16:08:06,842 - services.subnet_service - WARNING - Invalid last_seen format for device e2:ec:26:f8:6b:25
2025-11-25 16:08:06,847 - services.subnet_service - WARNING - Invalid last_seen format for device 5e:28:1f:e5:7d:18
2025-11-25 16:08:06,859 - services.subnet_service - WARNING - Invalid last_seen format for device 94:c6:91:99:d1:61
2025-11-25 16:08:06,888 - services.subnet_service - WARNING - Invalid last_seen format for device 02:7d:d8:c1:30:04
2025-11-25 16:08:06,895 - services.subnet_service - WARNING - Invalid last_seen format for device be:61:82:6d:9d:e4
2025-11-25 16:08:06,908 - services.subnet_service - WARNING - Invalid last_seen format for device cc:4b:73:e4:17:7e
2025-11-25 16:08:06,914 - services.subnet_service - WARNING - Invalid last_seen format for device c0:39:5a:1a:9c:c8
2025-11-25 16:08:06,915 - services.subnet_service - WARNING - Invalid last_seen format for device c0:39:5a:1a:9d:02
2025-11-25 16:08:06,921 - services.subnet_service - WARNING - Invalid last_seen format for device c0:39:5a:1a:a3:a4
2025-11-25 16:08:06,928 - services.subnet_service - WARNING - Invalid last_seen format for device c0:39:5a:1a:a3:c0
2025-11-25 16:08:06,934 - services.subnet_service - WARNING - Invalid last_seen format for device b4:4c:3b:33:c1:fa
2025-11-25 16:08:06,941 - services.subnet_service - WARNING - Invalid last_seen format for device 38:1f:8d:d2:02:b5
2025-11-25 16:08:07,042 - services.subnet_service - INFO - Local device detected: IP=10.1.1.31, MAC=dc:97:ba:3a:33:0b, Interface=wlp0s20f3
2025-11-25 16:08:07,043 - services.subnet_service - INFO - Detected local device: 10.1.1.31, MAC: dc:97:ba:3a:33:0b
2025-11-25 16:08:07,048 - services.subnet_service - INFO - Scanning subnet: 10.1.1.0/24 with interface: wlp0s20f3
2025-11-25 16:08:13,093 - services.subnet_service - INFO - Discovered devices: 15
2025-11-25 16:08:13,227 - services.subnet_service - WARNING - Failed to determine vendor for MAC c0:83:c9:22:76:14: this event loop is already running.
2025-11-25 16:08:13,244 - services.subnet_service - WARNING - Failed to determine vendor for MAC c0:83:c9:22:76:27: this event loop is already running.
2025-11-25 16:08:13,256 - services.subnet_service - WARNING - Failed to determine vendor for MAC 20:11:a2:68:02:0f: The vendor for MAC b'2011A268020F' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:08:13,301 - services.subnet_service - WARNING - Failed to determine vendor for MAC 52:c4:40:b1:21:4c: this event loop is already running.
2025-11-25 16:08:13,302 - services.subnet_service - WARNING - Failed to determine vendor for MAC fa:6d:85:71:b4:6f: this event loop is already running.
2025-11-25 16:08:13,311 - asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-40' coro=<AsyncMacLookup.lookup() done, defined at /root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py:97> exception=VendorNotFoundError(b'52C440B1214C')>
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 104, in lookup
return self.prefixes[mac[:6]].decode("utf8")
~~~~~~~~~~~~~^^^^^^^^^
KeyError: b'52C440'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 106, in lookup
raise VendorNotFoundError(mac)
mac_vendor_lookup.VendorNotFoundError: The vendor for MAC b'52C440B1214C' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:08:13,312 - services.subnet_service - WARNING - Failed to determine vendor for MAC 94:c6:91:99:d1:61: this event loop is already running.
2025-11-25 16:08:13,323 - services.subnet_service - WARNING - Failed to determine vendor for MAC be:61:82:6d:9d:e4: this event loop is already running.
2025-11-25 16:08:13,345 - services.subnet_service - WARNING - Failed to determine vendor for MAC 02:7d:d8:c1:30:04: this event loop is already running.
2025-11-25 16:08:13,356 - services.subnet_service - WARNING - Failed to determine vendor for MAC cc:4b:73:e4:17:7e: this event loop is already running.
2025-11-25 16:08:13,363 - services.subnet_service - WARNING - Failed to determine vendor for MAC c0:39:5a:1a:9c:c8: this event loop is already running.
2025-11-25 16:08:13,363 - services.subnet_service - WARNING - Failed to determine vendor for MAC c0:39:5a:1a:9d:02: this event loop is already running.
2025-11-25 16:08:13,391 - services.subnet_service - WARNING - Failed to determine vendor for MAC c0:39:5a:1a:a3:a4: this event loop is already running.
2025-11-25 16:08:13,527 - asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-41' coro=<AsyncMacLookup.lookup() done, defined at /root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py:97> exception=VendorNotFoundError(b'FA6D8571B46F')>
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 104, in lookup
return self.prefixes[mac[:6]].decode("utf8")
~~~~~~~~~~~~~^^^^^^^^^
KeyError: b'FA6D85'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 106, in lookup
raise VendorNotFoundError(mac)
mac_vendor_lookup.VendorNotFoundError: The vendor for MAC b'FA6D8571B46F' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:08:13,798 - asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-43' coro=<AsyncMacLookup.lookup() done, defined at /root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py:97> exception=VendorNotFoundError(b'BE61826D9DE4')>
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 104, in lookup
return self.prefixes[mac[:6]].decode("utf8")
~~~~~~~~~~~~~^^^^^^^^^
KeyError: b'BE6182'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 106, in lookup
raise VendorNotFoundError(mac)
mac_vendor_lookup.VendorNotFoundError: The vendor for MAC b'BE61826D9DE4' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:08:13,832 - asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-44' coro=<AsyncMacLookup.lookup() done, defined at /root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py:97> exception=VendorNotFoundError(b'027DD8C13004')>
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 104, in lookup
return self.prefixes[mac[:6]].decode("utf8")
~~~~~~~~~~~~~^^^^^^^^^
KeyError: b'027DD8'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/gonets-MdAedEct-py3.11/lib/python3.11/site-packages/mac_vendor_lookup.py", line 106, in lookup
raise VendorNotFoundError(mac)
mac_vendor_lookup.VendorNotFoundError: The vendor for MAC b'027DD8C13004' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:08:14,251 - services.subnet_service - INFO - Saved 16 devices to storage/subnets/10.1.1.0_24.json
2025-11-25 16:08:14,273 - services.subnet_service - INFO - Subnet scan 10.1.1.0/24 completed in 7.52 seconds, found 16 devices (active: 16)
2025-11-25 16:10:39,551 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:10:39,553 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:10:39,556 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:10:39,559 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:10:39,561 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:10:40,737 - api.v1.websocket - INFO - Client disconnected
2025-11-25 16:10:46,126 - api.v1.websocket - INFO - Client disconnected
2025-11-25 16:10:47,610 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:10:47,627 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:10:47,644 - api.v1.subnet - INFO - Requested subnet scan for: auto-detected
2025-11-25 16:10:47,703 - services.subnet_service - INFO - Auto-detected subnet: 10.0.0.0/8 (IP: 10.1.1.31, Mask: 255.0.0.0 -> /8)
2025-11-25 16:10:47,965 - services.subnet_service - INFO - Local device detected: IP=10.1.1.31, MAC=dc:97:ba:3a:33:0b, Interface=wlp0s20f3
2025-11-25 16:10:47,971 - services.subnet_service - INFO - Detected local device: 10.1.1.31, MAC: dc:97:ba:3a:33:0b
2025-11-25 16:10:47,987 - services.subnet_service - INFO - Scanning subnet: 10.0.0.0/8 with interface: wlp0s20f3
2025-11-25 16:11:12,067 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:11:12,068 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:11:12,072 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:11:12,084 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:11:12,086 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:23:32,518 - asyncio - ERROR - Task was destroyed but it is pending!
task: <Task pending name='Task-4' coro=<broadcast_data() done, defined at /home/merelden/main/compiler/gonets/SRV/api/v1/websocket.py:130> wait_for=<Future pending cb=[Task.task_wakeup()]>>
2025-11-25 16:23:37,298 - storage.session_storage - INFO - Сессия для client_id 127.0.0.1 не найдена
2025-11-25 16:23:37,298 - services.auth_service - ERROR - Session for client_id 127.0.0.1 not found or expired
2025-11-25 16:23:37,299 - storage.json_storage - INFO - Проверка существования файла /etc/gonets/users.json
2025-11-25 16:23:37,299 - storage.json_storage - INFO - Файл /etc/gonets/users.json уже существует
2025-11-25 16:23:37,299 - api.v1.auth - INFO - Файл /etc/gonets/users.json существует и содержит пользователей
2025-11-25 16:23:48,170 - services.subnet_service - INFO - Default interface from gateway: wlp0s20f3
2025-11-25 16:23:48,170 - services.subnet_service - INFO - Initialized SubnetService with interface: wlp0s20f3
2025-11-25 16:23:48,171 - api.v1.subnet - INFO - Requested subnet scan for: auto-detected
2025-11-25 16:23:48,173 - services.subnet_service - INFO - Auto-detected subnet: 10.1.1.0/24 (IP: 10.1.1.31, Mask: 255.255.255.0 -> /24)
2025-11-25 16:23:48,189 - services.subnet_service - INFO - Local device detected: IP=10.1.1.31, MAC=dc:97:ba:3a:33:0b, Interface=wlp0s20f3
2025-11-25 16:23:48,189 - services.subnet_service - INFO - Detected local device: 10.1.1.31, MAC: dc:97:ba:3a:33:0b
2025-11-25 16:23:48,189 - services.subnet_service - INFO - Scanning subnet: 10.1.1.0/24 with interface: wlp0s20f3
2025-11-25 16:23:50,337 - services.subnet_service - INFO - Discovered devices: 18
2025-11-25 16:23:50,434 - services.subnet_service - WARNING - Failed to determine vendor for MAC c0:83:c9:22:76:14: this event loop is already running.
2025-11-25 16:23:50,436 - services.subnet_service - WARNING - Failed to determine vendor for MAC 20:11:a2:68:02:0f: The vendor for MAC b'2011A268020F' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:23:50,517 - services.subnet_service - WARNING - Failed to determine vendor for MAC be:61:82:6d:9d:e4: The vendor for MAC b'BE61826D9DE4' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:23:50,518 - services.subnet_service - WARNING - Failed to determine vendor for MAC 02:7d:d8:c1:30:04: The vendor for MAC b'027DD8C13004' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:23:50,594 - services.subnet_service - WARNING - Failed to determine vendor for MAC cc:4b:73:e4:17:7e: this event loop is already running.
2025-11-25 16:23:50,594 - services.subnet_service - WARNING - Failed to determine vendor for MAC fa:6d:85:71:b4:6f: The vendor for MAC b'FA6D8571B46F' could not be found. Either it's not registered or the local list is out of date. Try MacLookup().update_vendors()
2025-11-25 16:23:50,596 - services.subnet_service - INFO - Saved 20 devices to storage/subnets/10.1.1.0_24.json
2025-11-25 16:23:50,596 - services.subnet_service - INFO - Subnet scan 10.1.1.0/24 completed in 2.42 seconds, found 20 devices (active: 19)

View file

@ -433,6 +433,65 @@ class SubnetService:
logger.warning(f"Failed to determine interface: {str(e)}, defaulting to eth0") logger.warning(f"Failed to determine interface: {str(e)}, defaulting to eth0")
return "eth0" return "eth0"
def _get_prefix_from_ip_cmd(self, iface: str) -> Optional[int]:
"""Пытается получить префикс подсети из вывода `ip addr`, если netifaces дал неточную маску."""
try:
result = subprocess.run(
["ip", "-o", "-f", "inet", "addr", "show", "dev", iface],
capture_output=True,
text=True,
check=False,
timeout=2,
)
if result.returncode != 0 or not result.stdout:
return None
# пример строки: "3: wlp0s20f3 inet 10.1.1.31/24 brd 10.1.1.255 scope global dynamic noprefixroute wlp0s20f3"
for part in result.stdout.split():
if "/" in part and part.count(".") == 3:
try:
return int(part.split("/")[1])
except ValueError:
continue
return None
except Exception as e:
logger.debug(f"ip addr prefix detection failed for {iface}: {e}")
return None
def _get_prefix_from_proc_route(self, iface: str) -> Optional[int]:
"""Читает маску для интерфейса из /proc/net/route (не требует прав netlink)."""
try:
with open("/proc/net/route") as f:
for line in f:
parts = line.strip().split()
if len(parts) < 8 or parts[0] != iface:
continue
mask_hex = parts[7]
try:
mask_int = int(mask_hex, 16)
except ValueError:
continue
# mask_int в host byte order, например FF000000 для 255.0.0.0
mask_str = socket.inet_ntoa(mask_int.to_bytes(4, byteorder="little"))
return ipaddress.ip_network(f"0.0.0.0/{mask_str}", strict=False).prefixlen
return None
except Exception as e:
logger.debug(f"/proc/net/route prefix detection failed for {iface}: {e}")
return None
def _get_prefix_from_broadcast(self, ip: str, broadcast: Optional[str]) -> Optional[int]:
"""Вычисляет префикс из пары IP + broadcast, если она присутствует (часто точнее для 10.x)."""
if not ip or not broadcast:
return None
try:
ip_int = int(ipaddress.IPv4Address(ip))
bcast_int = int(ipaddress.IPv4Address(broadcast))
mask_int = ~(ip_int ^ bcast_int) & 0xFFFFFFFF
mask = ipaddress.ip_network(f"0.0.0.0/{ipaddress.IPv4Address(mask_int)}", strict=False).prefixlen
return mask
except Exception as e:
logger.debug(f"Broadcast-based prefix detection failed for {ip}/{broadcast}: {e}")
return None
def _get_default_subnet(self) -> str: def _get_default_subnet(self) -> str:
"""Автоматически определяет подсеть локального устройства. """Автоматически определяет подсеть локального устройства.
@ -454,8 +513,15 @@ class SubnetService:
ip_info = addrs[netifaces.AF_INET][0] ip_info = addrs[netifaces.AF_INET][0]
ip = ip_info["addr"] ip = ip_info["addr"]
netmask = ip_info["netmask"] netmask = ip_info["netmask"]
# Преобразуем маску из строки (например, "255.255.255.0") в CIDR broadcast = ip_info.get("broadcast")
mask = ipaddress.ip_network(f"0.0.0.0/{netmask}", strict=False).prefixlen # netifaces иногда отдаёт неточную маску (например, 255.0.0.0 для 10.x),
# пробуем уточнить через `ip addr`, затем /proc/net/route, затем по broadcast, и только потом берём netmask.
mask = (
self._get_prefix_from_ip_cmd(iface)
or self._get_prefix_from_proc_route(iface)
or self._get_prefix_from_broadcast(ip, broadcast)
or ipaddress.ip_network(f"0.0.0.0/{netmask}", strict=False).prefixlen
)
network = ipaddress.ip_network(f"{ip}/{mask}", strict=False) network = ipaddress.ip_network(f"{ip}/{mask}", strict=False)
logger.info(f"Auto-detected subnet: {network} (IP: {ip}, Mask: {netmask} -> /{mask})") logger.info(f"Auto-detected subnet: {network} (IP: {ip}, Mask: {netmask} -> /{mask})")
return str(network) return str(network)