mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
implement uncloudd daemon that starts a WireGuard network without peer probing
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user