Версия 0.0.2

This commit is contained in:
commit 7b9c998224
530 changed files with 424916 additions and 0 deletions

134
debian/patches/1 vendored Normal file
View file

@ -0,0 +1,134 @@
Description: <short summary of the patch>
TODO: Put a short summary on the line above and replace this paragraph
with a longer explanation of this change. Complete the meta-information
with other relevant fields (see below for details). To make it easier, the
information below has been extracted from the changelog. Adjust it or drop
it.
.
gonets (0.2-2) UNRELEASED; urgency=medium
.
* Initial release. (Closes: #nnnn) <nnnn is the bug number of your ITP>
Author: GOSSYS LLC <devteam@gossys.dev>
---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:
Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2025-05-12
--- gonets-0.2.orig/SRV/services/ip_service.py
+++ gonets-0.2/SRV/services/ip_service.py
@@ -1,13 +1,8 @@
+from sdbus_async.networkmanager import NetworkManager, NetworkManagerSettings, NetworkConnectionSettings, NetworkDeviceGeneric, ActiveConnection
import asyncio
+from sdbus_async.networkmanager.settings import ConnectionProfile
from typing import Dict, Any
-from sdbus_async.networkmanager import (
- NetworkManager,
- NetworkManagerSettings,
- NetworkConnectionSettings,
- NetworkDeviceGeneric,
-)
import sdbus
-from sdbus_async.networkmanager.settings import ConnectionProfile
from services.arp_service import NetworkScanner
class IPService:
@@ -33,23 +28,24 @@ class IPService:
clients = self.arp_scanner.scan_network()
new_ip = args["ipv4_updates"]["ipv4.address-data"][0]["address"]
if any(client['ip'] == new_ip for client in clients):
- return {"available": False, "message": f"IP address {new_ip} уже занят."}
+ return {"available": False, "message": f"IP address {new_ip} уже доступен."}
return {"available": True, "message": "Network profile settings are available for use."}
async def apply_ip_config(self, args: Dict[str, Any]) -> None:
""" Применяет проверенные настройки IP """
self._reset_bus()
- nm = NetworkManager()
- settings = NetworkManagerSettings()
+ nm = NetworkManager(self.bus)
+ settings = NetworkManagerSettings(self.bus)
connection_paths = await settings.get_connections_by_id(args["connection_id"])
if not connection_paths:
raise ValueError(f"Подключение {args['connection_id']} не найдено")
- connection = NetworkConnectionSettings(connection_paths[0])
+ connection = NetworkConnectionSettings(connection_paths[0], self.bus)
profile = await connection.get_profile()
settings_dict = profile.to_settings_dict()
+ # Обновляем настройки IPv4
for key_path, value in args["ipv4_updates"].items():
section, *props = key_path.split('.')
current = settings_dict[section]
@@ -61,10 +57,51 @@ class IPService:
await connection.update(new_profile.to_dbus())
print(f"Обновлены настройки для {args['connection_id']}:")
- interface_name = settings_dict['connection']['interface-name']
+ # Проверяем interface-name
+ interface_name = settings_dict['connection'].get('interface-name')
+ if not interface_name:
+ # Ищем устройство, связанное с connection_id через активное соединение
+ devices = await nm.get_devices()
+ for device_path in devices:
+ device = NetworkDeviceGeneric(device_path, self.bus)
+ active_connection = await device.active_connection
+ if active_connection != '/':
+ active_conn = ActiveConnection(active_connection, self.bus)
+ conn_path = await active_conn.connection # Путь к настройкам соединения
+ if conn_path != '/':
+ conn_settings = NetworkConnectionSettings(conn_path, self.bus)
+ active_profile = await conn_settings.get_profile()
+ if active_profile.to_settings_dict()['connection']['id'] == args["connection_id"]:
+ interface_name = await device.interface
+ settings_dict['connection']['interface-name'] = interface_name
+ new_profile = ConnectionProfile.from_settings_dict(settings_dict)
+ await connection.update(new_profile.to_dbus())
+ print(f"Добавлен interface-name: {interface_name} для {args['connection_id']}")
+ break
+
+ if not interface_name:
+ # Если не нашли активное соединение, пробуем получить интерфейс из настроек устройства
+ devices = await nm.get_devices()
+ for device_path in devices:
+ device = NetworkDeviceGeneric(device_path, self.bus)
+ applied_connection = await device.get_applied_connection()
+ connection_settings = applied_connection[0]
+ conn_id = connection_settings.get('connection', {}).get('id', ('s', ''))[1]
+ if conn_id == args["connection_id"]:
+ interface_name = await device.interface
+ settings_dict['connection']['interface-name'] = interface_name
+ new_profile = ConnectionProfile.from_settings_dict(settings_dict)
+ await connection.update(new_profile.to_dbus())
+ print(f"Добавлен interface-name: {interface_name} для {args['connection_id']}")
+ break
+
+ if not interface_name:
+ raise ValueError(f"Не удалось определить interface-name для {args['connection_id']}")
+
+ # Переподключаем устройство
devices = await nm.get_devices()
for device_path in devices:
- device = NetworkDeviceGeneric(device_path)
+ device = NetworkDeviceGeneric(device_path, self.bus)
if await device.interface == interface_name:
await device.disconnect()
print(f"Отключён от {interface_name}")
@@ -72,4 +109,4 @@ class IPService:
print(f"Переподключён к {args['connection_id']}")
return
- raise RuntimeError(f"Устройство для интерфейса {interface_name} не найдено")
+ raise RuntimeError(f"Устройство для интерфейса {interface_name} не найдено")
\ No newline at end of file