mirror of
https://github.com/0x1d/rcond.git
synced 2025-12-16 18:55:04 +01:00
feat: improve ENV variable overrides, introduce Node struct, refactoring
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/0x1d/rcond/pkg/system"
|
||||
"github.com/0x1d/rcond/pkg/util"
|
||||
"github.com/godbus/dbus/v5"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
@@ -334,7 +334,7 @@ func GetHostname() (string, error) {
|
||||
// SetHostname changes the static hostname via the system bus.
|
||||
// newHost is your desired hostname, interactive=false skips any prompt.
|
||||
func SetHostname(newHost string) error {
|
||||
return system.WithDbus(func(conn *dbus.Conn) error {
|
||||
return util.WithConnection(func(conn *dbus.Conn) error {
|
||||
obj := conn.Object(
|
||||
"org.freedesktop.hostname1",
|
||||
dbus.ObjectPath("/org/freedesktop/hostname1"),
|
||||
@@ -355,7 +355,7 @@ func SetHostname(newHost string) error {
|
||||
func ConfigureSTA(iface string, ssid string, password string, autoconnect bool) (string, error) {
|
||||
uuid := uuid.New()
|
||||
|
||||
err := system.WithDbus(func(conn *dbus.Conn) error {
|
||||
err := util.WithConnection(func(conn *dbus.Conn) error {
|
||||
_, err := AddStationConnection(conn, uuid, ssid, password, autoconnect)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create station connection: %v", err)
|
||||
@@ -377,7 +377,7 @@ func ConfigureSTA(iface string, ssid string, password string, autoconnect bool)
|
||||
func ConfigureAP(iface string, ssid string, password string, autoconnect bool) (string, error) {
|
||||
uuid := uuid.New()
|
||||
|
||||
err := system.WithDbus(func(conn *dbus.Conn) error {
|
||||
err := util.WithConnection(func(conn *dbus.Conn) error {
|
||||
_, err := AddAccessPointConnection(conn, uuid, ssid, password, autoconnect)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create access point connection: %v", err)
|
||||
@@ -398,7 +398,7 @@ func ConfigureAP(iface string, ssid string, password string, autoconnect bool) (
|
||||
// The connection will be activated on the specified interface.
|
||||
// Returns an error if any operation fails.
|
||||
func Up(iface string, uuid string) error {
|
||||
return system.WithDbus(func(conn *dbus.Conn) error {
|
||||
return util.WithConnection(func(conn *dbus.Conn) error {
|
||||
connPath, err := GetConnectionPath(conn, uuid)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -428,7 +428,7 @@ func Up(iface string, uuid string) error {
|
||||
// It takes the interface name as an argument.
|
||||
// Returns an error if the device cannot be found or disconnected.
|
||||
func Down(iface string) error {
|
||||
return system.WithDbus(func(conn *dbus.Conn) error {
|
||||
return util.WithConnection(func(conn *dbus.Conn) error {
|
||||
devPath, err := GetDeviceByIpIface(conn, iface)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -446,7 +446,7 @@ func Down(iface string) error {
|
||||
// If no connection with the UUID exists, it returns nil.
|
||||
// Returns an error if the connection exists but cannot be deleted.
|
||||
func Remove(uuid string) error {
|
||||
return system.WithDbus(func(conn *dbus.Conn) error {
|
||||
return util.WithConnection(func(conn *dbus.Conn) error {
|
||||
connPath, err := GetConnectionPath(conn, uuid)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user