implement uncloudd daemon that starts a WireGuard network without peer probing

This commit is contained in:
Pavel Sviderski
2024-08-26 17:09:54 +10:00
parent 222edb7647
commit e074b6855f
13 changed files with 347 additions and 145 deletions
+34
View File
@@ -0,0 +1,34 @@
package daemon
import (
"context"
"fmt"
"uncloud/internal/machine"
"uncloud/internal/machine/network"
)
func Run(ctx context.Context, dataDir string) error {
cfg, err := machine.ParseConfig(machine.ConfigPath(dataDir))
if err != nil {
return fmt.Errorf("load machine config: %w", err)
}
wgnet, err := network.NewWireGuardNetwork()
if err != nil {
return fmt.Errorf("create WireGuard network: %w", err)
}
if err = wgnet.Configure(*cfg.Network); err != nil {
return fmt.Errorf("configure WireGuard network: %w", err)
}
//ctx, cancel := context.WithCancel(context.Background())
//go wgnet.WatchEndpoints(ctx, peerEndpointChangeNotifier)
//addrs, err := network.ListRoutableAddresses()
//if err != nil {
// return err
//}
//fmt.Println("Addresses:", addrs)
return wgnet.Run(ctx)
}