From d950b3627db2ded54ea20d97ef63ada0cb1f4914 Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Sun, 18 May 2025 07:50:36 +0200 Subject: [PATCH] feat: check if network connection already exists when adding a new one, update docs --- README.md | 23 +++++++++++++++++++++++ pkg/network/network.go | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/README.md b/README.md index b9edf2f..bcbf08a 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,29 @@ rcond: api_token: 1234567890 ``` +### Network + +Network connections can be configured in the `rcond.yaml` file, and these configurations are applied automatically when the node starts up. This allows for easy management of network settings, including the creation of access points and the sharing of network connections, without requiring manual intervention after each reboot. + +Here is an example for creating an access point and share network connection on wlan0: + +```yaml +network: + connections: + - name: MyHomeWiFi + type: 802-11-wireless + interface: wlan0 + ssid: MyHomeWiFi + mode: ap + band: bg + channel: 1 + keymgmt: wpa-psk + psk: SuperSecure + ipv4method: shared + ipv6method: ignore + autoconnect: true +``` + ### Cluster The cluster agent is a component of rcond that is responsible for joining and managing a cluster of rcond nodes. diff --git a/pkg/network/network.go b/pkg/network/network.go index 48afd5f..75227cb 100644 --- a/pkg/network/network.go +++ b/pkg/network/network.go @@ -237,6 +237,12 @@ func AddStationConnection(conn *dbus.Conn, uuid uuid.UUID, ssid string, password // Returns the D-Bus object path of the new connection profile. // Returns an error if the connection creation fails. func AddConnectionWithConfig(conn *dbus.Conn, cfg *ConnectionConfig) (dbus.ObjectPath, error) { + + // check of connection already exists and return existing connection path + if existingObjectPath, err := GetConnectionPath(conn, cfg.UUID); err == nil { + return existingObjectPath, nil + } + settingsObj := conn.Object( "org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings",