{"id":34837112,"url":"https://github.com/modelingevolution/networking","last_synced_at":"2026-05-24T17:05:26.810Z","repository":{"id":303269738,"uuid":"1014909173","full_name":"modelingevolution/networking","owner":"modelingevolution","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-06T17:20:06.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-06T18:31:48.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/modelingevolution.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-06T16:37:32.000Z","updated_at":"2025-07-06T17:19:57.000Z","dependencies_parsed_at":"2025-07-06T18:34:15.256Z","dependency_job_id":"b0cc834e-bf57-429f-94de-6860a856997e","html_url":"https://github.com/modelingevolution/networking","commit_stats":null,"previous_names":["modelingevolution/networking"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/modelingevolution/networking","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modelingevolution%2Fnetworking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modelingevolution%2Fnetworking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modelingevolution%2Fnetworking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modelingevolution%2Fnetworking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modelingevolution","download_url":"https://codeload.github.com/modelingevolution/networking/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modelingevolution%2Fnetworking/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28032375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-25T02:00:05.988Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-25T16:07:11.601Z","updated_at":"2025-12-25T16:09:04.071Z","avatar_url":"https://github.com/modelingevolution.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ModelingEvolution.NetworkManager\n\n[![NuGet](https://img.shields.io/nuget/v/ModelingEvolution.NetworkManager.svg)](https://www.nuget.org/packages/ModelingEvolution.NetworkManager/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![.NET](https://img.shields.io/badge/.NET-9.0-blue.svg)](https://dotnet.microsoft.com/download)\n\nA comprehensive .NET wrapper for the NetworkManager D-Bus interface, providing powerful network management capabilities for Linux systems. This library enables full control over WiFi, Ethernet, bridging, VPN, and advanced network configuration through a type-safe, async-first API.\n\n## Features\n\n- 🌐 **Complete NetworkManager D-Bus Wrapper**: Full access to all NetworkManager functionality\n- 📶 **WiFi Management**: Connect, scan, manage access points and wireless networks\n- 🔌 **Ethernet Support**: Wired network configuration and monitoring\n- 🌉 **Bridge Configuration**: Create and manage network bridges\n- 🔒 **VPN Integration**: Support for VPN connections and profiles\n- ⚡ **Async/Await Support**: Modern async programming patterns throughout\n- 🎯 **Type Safety**: Strongly-typed interfaces with full IntelliSense support\n- 📊 **Real-time Monitoring**: Event-driven network state changes and device monitoring\n- 🔧 **IPv4/IPv6 Support**: Complete IP configuration management\n- 🚀 **High Performance**: Efficient D-Bus communication with minimal overhead\n\n## Installation\n\n```bash\ndotnet add package ModelingEvolution.NetworkManager\n```\n\n## Quick Start\n\n### Basic Network Client\n\n```csharp\nusing ModelingEvolution.NetworkManager;\n\n// Create NetworkManager client\nusing var client = await NetworkManagerClient.Create();\n\n// Get all network devices\nvar devices = await client.GetDevices();\nforeach (var device in devices)\n{\n    Console.WriteLine($\"Device: {device.InterfaceName} ({device.DeviceType})\");\n    Console.WriteLine($\"State: {device.State}\");\n    \n    // Get connection info if connected\n    var connectionInfo = await device.GetConnectionInfo();\n    if (connectionInfo != null)\n    {\n        Console.WriteLine($\"IP: {connectionInfo.Ip4Config}\");\n    }\n}\n```\n\n### WiFi Network Management\n\n```csharp\nusing ModelingEvolution.NetworkManager;\n\nusing var client = await NetworkManagerClient.Create();\n\n// Get WiFi devices\nvar wifiDevices = await client.GetWifiDevices();\n\nforeach (var wifiDevice in wifiDevices)\n{\n    Console.WriteLine($\"WiFi Device: {wifiDevice.InterfaceName}\");\n    \n    // Scan for available networks\n    var networks = await client.GetAccessPoints().ToListAsync();\n    \n    foreach (var network in networks.Take(5))\n    {\n        Console.WriteLine($\"  SSID: {network.Ssid}\");\n        Console.WriteLine($\"  Signal: {network.Strength}%\");\n        Console.WriteLine($\"  Security: {network.WpaFlags}\");\n    }\n    \n    // Connect to a specific network\n    try\n    {\n        await wifiDevice.ConnectAccessPoint(\"MyWiFiNetwork\");\n        Console.WriteLine(\"Connected successfully!\");\n    }\n    catch (AccessPointNotFoundException)\n    {\n        Console.WriteLine(\"Network not found\");\n    }\n    catch (ActivationFailedException ex)\n    {\n        Console.WriteLine($\"Connection failed: {ex.Reason}\");\n    }\n}\n```\n\n### Real-time Network Monitoring\n\n```csharp\nusing ModelingEvolution.NetworkManager;\n\nusing var client = await NetworkManagerClient.Create();\nvar devices = await client.GetDevices();\n\n// Monitor device state changes\nforeach (var device in devices)\n{\n    await device.SubscribeStateChanged();\n    device.StateChanged += (sender, args) =\u003e\n    {\n        Console.WriteLine($\"Device {device.InterfaceName}: {args.OldState} → {args.NewState}\");\n    };\n}\n\n// Monitor WiFi access point discovery\nvar wifiDevices = await client.GetWifiDevices();\nforeach (var wifiDevice in wifiDevices)\n{\n    await wifiDevice.SubscribeAccessPoint(monitorSignal: true);\n    \n    wifiDevice.AccessPointVisilibityChanged += (sender, args) =\u003e\n    {\n        Console.WriteLine($\"Access Point {args.Path}: {args.Operation}\");\n    };\n    \n    wifiDevice.AccessPointSignalChanged += (sender, args) =\u003e\n    {\n        Console.WriteLine($\"Signal strength changed: {args.Ssid} → {args.Strength}%\");\n    };\n}\n\n// Keep monitoring\nConsole.WriteLine(\"Monitoring network changes... Press any key to stop.\");\nConsole.ReadKey();\n```\n\n### Advanced Network Configuration\n\n```csharp\nusing ModelingEvolution.NetworkManager;\nusing ModelingEvolution.Ipv4;\n\nusing var client = await NetworkManagerClient.Create();\n\n// Create a static IP configuration\nvar staticConfig = new Dictionary\u003cstring, Dictionary\u003cstring, Variant\u003e\u003e\n{\n    [\"connection\"] = new()\n    {\n        [\"id\"] = Variant.String(\"Static Connection\"),\n        [\"type\"] = Variant.String(\"802-3-ethernet\"),\n        [\"autoconnect\"] = Variant.Bool(true)\n    },\n    [\"ipv4\"] = new()\n    {\n        [\"method\"] = Variant.String(\"manual\"),\n        [\"addresses\"] = Variant.Array(new[]\n        {\n            Variant.Array(new[]\n            {\n                Variant.UInt32(Ipv4Address.Parse(\"192.168.1.100\").Value),\n                Variant.UInt32(24),\n                Variant.UInt32(Ipv4Address.Parse(\"192.168.1.1\").Value)\n            })\n        }),\n        [\"dns\"] = Variant.Array(new[]\n        {\n            Variant.UInt32(Ipv4Address.Parse(\"8.8.8.8\").Value),\n            Variant.UInt32(Ipv4Address.Parse(\"8.8.4.4\").Value)\n        })\n    }\n};\n\n// Get ethernet device\nvar ethernetDevice = (await client.GetDevices())\n    .FirstOrDefault(d =\u003e d.DeviceType == DeviceType.Ethernet);\n\nif (ethernetDevice != null)\n{\n    // Create and activate the connection\n    var (connectionPath, activeConnectionPath) = await client.NetworkManager\n        .AddAndActivateConnectionAsync(staticConfig, ethernetDevice.Id, \"/\");\n    \n    Console.WriteLine($\"Static connection activated: {activeConnectionPath}\");\n}\n```\n\n### Connection Profile Management\n\n```csharp\nusing ModelingEvolution.NetworkManager;\n\nusing var client = await NetworkManagerClient.Create();\n\n// List all saved connection profiles\nvar connections = await client.GetConnections();\nConsole.WriteLine(\"Saved Connections:\");\n\nforeach (var connection in connections)\n{\n    var profile = await connection.GetProfileInfo();\n    if (profile != null)\n    {\n        Console.WriteLine($\"  {profile.FileName}\");\n    }\n}\n\n// Get active connections\nvar activeConnections = await client.GetActiveConnections();\nConsole.WriteLine($\"\\nActive Connections: {activeConnections.Count}\");\n\n// Check if a specific connection is active\nbool isVpnActive = await client.IsConnectionActive(\"My VPN\");\nConsole.WriteLine($\"VPN Active: {isVpnActive}\");\n```\n\n## Advanced Usage\n\n### Custom Connection Types\n\n```csharp\n// Create a bridge connection\nvar bridgeConfig = new Dictionary\u003cstring, Dictionary\u003cstring, Variant\u003e\u003e\n{\n    [\"connection\"] = new()\n    {\n        [\"id\"] = Variant.String(\"Bridge0\"),\n        [\"type\"] = Variant.String(\"bridge\")\n    },\n    [\"bridge\"] = new()\n    {\n        [\"stp\"] = Variant.Bool(false)\n    },\n    [\"ipv4\"] = new()\n    {\n        [\"method\"] = Variant.String(\"auto\")\n    }\n};\n\n// Add bridge connection\nvar settings = client.Service.CreateSettings(\"/org/freedesktop/NetworkManager/Settings\");\nvar bridgeConnectionPath = await settings.AddConnectionAsync(bridgeConfig);\n```\n\n### Device Information and Statistics\n\n```csharp\nvar device = (await client.GetDevices()).First();\n\n// Get comprehensive device information\nvar connectionInfo = await device.GetConnectionInfo();\nif (connectionInfo != null)\n{\n    var config = connectionInfo.Ip4Config;\n    Console.WriteLine($\"IP Address: {config.Address}\");\n    Console.WriteLine($\"Subnet: {config.Network}\");\n    Console.WriteLine($\"Gateway: {config.Gateway}\");\n    Console.WriteLine($\"Can reach 8.8.8.8 directly: {config.CanReachDirectly(\"8.8.8.8\")}\");\n}\n\n// Monitor connection profile changes\nvar profile = await device.GetConnectionProfile();\nif (profile != null)\n{\n    Console.WriteLine($\"Active Profile: {profile.FileName}\");\n}\n```\n\n### Error Handling and Diagnostics\n\n```csharp\ntry\n{\n    using var client = await NetworkManagerClient.Create();\n    var wifiDevice = (await client.GetWifiDevices()).FirstOrDefault();\n    \n    if (wifiDevice == null)\n    {\n        throw new InvalidOperationException(\"No WiFi device found\");\n    }\n    \n    await wifiDevice.ConnectAccessPoint(\"SecureNetwork\", wait: true);\n}\ncatch (AccessPointNotFoundException)\n{\n    Console.WriteLine(\"The specified network was not found in the scan results\");\n}\ncatch (ActivationFailedException ex)\n{\n    Console.WriteLine($\"Connection failed: {ex.Reason}\");\n    Console.WriteLine($\"Profile: {ex.ProfileFileName}\");\n    \n    switch (ex.Reason)\n    {\n        case ActivationFailedReason.NoSecrets:\n            Console.WriteLine(\"Authentication required - check credentials\");\n            break;\n        case ActivationFailedReason.SsidNotFound:\n            Console.WriteLine(\"Network out of range or hidden\");\n            break;\n        case ActivationFailedReason.ConnectTimeout:\n            Console.WriteLine(\"Connection timed out - check signal strength\");\n            break;\n    }\n}\ncatch (TimeoutException)\n{\n    Console.WriteLine(\"Operation timed out after 110 seconds\");\n}\n```\n\n## API Reference\n\n### Core Classes\n\n#### NetworkManagerClient\nMain entry point for NetworkManager operations.\n\n**Key Methods:**\n- `Create()` - Creates and initializes a new client\n- `GetDevices()` - Retrieve all network devices\n- `GetWifiDevices()` - Get WiFi-capable devices\n- `GetActiveConnections()` - List active connections\n- `IsConnectionActive(string name)` - Check connection status\n\n#### DeviceInfo\nRepresents a network device with comprehensive management capabilities.\n\n**Key Properties:**\n- `InterfaceName` - Network interface name (e.g., \"wlan0\", \"eth0\")\n- `DeviceType` - Type of device (WiFi, Ethernet, Bridge, etc.)\n- `State` - Current device state (Connected, Disconnected, etc.)\n\n**Key Methods:**\n- `GetConnectionInfo()` - Get current IP configuration\n- `GetConnectionProfile()` - Get active connection profile\n- `ActivateProfile(ProfileInfo)` - Activate a saved profile\n- `DisconnectAsync()` - Disconnect the device\n- `SubscribeStateChanged()` - Monitor state changes\n\n#### WifiDeviceInfo\nExtended device information for WiFi devices.\n\n**Key Methods:**\n- `ConnectAccessPoint(string ssid, bool wait = true)` - Connect to WiFi network\n- `AccessPoint()` - Get current access point information\n- `SubscribeAccessPoint(bool monitorSignal = false)` - Monitor access points\n\n**Events:**\n- `AccessPointVisibilityChanged` - Access point discovered/lost\n- `AccessPointSignalChanged` - Signal strength changes\n\n### Network Configuration\n\n#### ConnectionInfo\nCurrent network connection information.\n\n**Properties:**\n- `Ip4Config` - IPv4 configuration with address, network, gateway\n\n#### Ipv4Configuration (from ModelingEvolution.Ipv4)\nComprehensive IPv4 network configuration.\n\n**Key Methods:**\n- `CanReachDirectly(string address)` - Check if address is in same network\n- `IsValid()` - Validate configuration consistency\n\n### Device Types\n\nSupported NetworkManager device types:\n- `Ethernet` - Wired network interfaces\n- `Wifi` - Wireless network interfaces  \n- `Bridge` - Network bridges\n- `Bond` - Link aggregation\n- `VLAN` - Virtual LANs\n- `VPN` - VPN connections\n- `Modem` - Mobile broadband\n- `Bluetooth` - Bluetooth networking\n- And many more...\n\n### Connection States\n\nDevice and connection states:\n- `Connected` - Fully connected and configured\n- `Connecting` - Connection in progress\n- `Disconnected` - Not connected\n- `Unavailable` - Device not available\n- `Failed` - Connection failed\n\n## Requirements\n\n- **.NET 9.0** or higher\n- **Linux** operating system with NetworkManager\n- **D-Bus** system bus access\n- **ModelingEvolution.Ipv4** (automatically included)\n- **Tmds.DBus.Protocol** (automatically included)\n\n## Platform Support\n\nThis library is designed for Linux systems running NetworkManager:\n- **Ubuntu** 18.04+\n- **Debian** 10+\n- **CentOS/RHEL** 8+\n- **Fedora** 30+\n- **Arch Linux**\n- **openSUSE**\n\n## Performance\n\nThe library is optimized for:\n- **Minimal allocations** with efficient D-Bus communication\n- **Async-first design** for responsive applications\n- **Event-driven architecture** for real-time monitoring\n- **Type safety** without runtime overhead\n- **Batched operations** for bulk network management\n\n## Deployment Considerations\n\n### Permissions\nYour application needs appropriate D-Bus permissions to access NetworkManager:\n\n```xml\n\u003c!-- /etc/dbus-1/system.d/your-app.conf --\u003e\n\u003cpolicy user=\"your-app-user\"\u003e\n  \u003callow send_destination=\"org.freedesktop.NetworkManager\"/\u003e\n  \u003callow receive_sender=\"org.freedesktop.NetworkManager\"/\u003e\n\u003c/policy\u003e\n```\n\n### Service Configuration\nFor system services, ensure NetworkManager is running:\n\n```bash\nsudo systemctl enable NetworkManager\nsudo systemctl start NetworkManager\n```\n\n### Security\n- Always validate user input for network configurations\n- Implement proper authentication for network management operations\n- Use connection profiles for sensitive configurations\n- Monitor for unauthorized network changes\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\nThis library extracts and enhances NetworkManager functionality from the [EventPi NetworkMonitor](https://github.com/modelingevolution/rocket-welder2) project, providing a focused, production-ready package for .NET NetworkManager integration.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodelingevolution%2Fnetworking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodelingevolution%2Fnetworking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodelingevolution%2Fnetworking/lists"}