mirror of
https://github.com/kairos-io/provider-kairos.git
synced 2025-09-13 05:39:29 +00:00
✨ Refactor edgevpn integration (#549)
Just a cleanup left from last weeks work --------- Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
This commit is contained in:
2
go.mod
2
go.mod
@@ -11,7 +11,7 @@ require (
|
||||
github.com/ipfs/go-log/v2 v2.5.1 // indirect
|
||||
github.com/kairos-io/kairos-agent/v2 v2.9.1
|
||||
github.com/kairos-io/kairos-sdk v0.1.1
|
||||
github.com/mudler/edgevpn v0.25.3-0.20240423154352-8cf7992723be
|
||||
github.com/mudler/edgevpn v0.25.3
|
||||
github.com/mudler/go-pluggable v0.0.0-20230126220627-7710299a0ae5
|
||||
github.com/mudler/go-processmanager v0.0.0-20230818213616-f204007f963c
|
||||
github.com/onsi/ginkgo/v2 v2.17.1
|
||||
|
2
go.sum
2
go.sum
@@ -542,6 +542,8 @@ github.com/mudler/edgevpn v0.25.2 h1:9VH1eSUkObEa0WzO+ohBAO/FTLKG0WENVfJ1ad3UPr0
|
||||
github.com/mudler/edgevpn v0.25.2/go.mod h1:/TNk/6bdSjzs7UsALlsw4c3GbJk/kzephVeIpTQ20Xk=
|
||||
github.com/mudler/edgevpn v0.25.3-0.20240423154352-8cf7992723be h1:aIWSHmZj3XmcowS4/Za253gR2dEoMogmqkFNGCkpCqg=
|
||||
github.com/mudler/edgevpn v0.25.3-0.20240423154352-8cf7992723be/go.mod h1:fzwR+lqzXYEaOEv1kMYqSIBcH1SJ+bxvi+p4N2s/9D4=
|
||||
github.com/mudler/edgevpn v0.25.3 h1:mfz1L8ks+Qdbf6VuD7JhB6xNDgjCYCdcOUE5pUVUemQ=
|
||||
github.com/mudler/edgevpn v0.25.3/go.mod h1:SQdr1svvxv6vqADXSpdWGn/cMCJse2nNNFDu+AT913M=
|
||||
github.com/mudler/entities v0.0.0-20220905203055-68348bae0f49 h1:P1QgHLh0hX935j6m9K6rlSxc0mkD1UuIAOQEu+1VCW4=
|
||||
github.com/mudler/entities v0.0.0-20220905203055-68348bae0f49/go.mod h1:qquFT9tYp+/NO7tTotto4BT9zSRYSMDxo2PGZwujpFA=
|
||||
github.com/mudler/go-pluggable v0.0.0-20230126220627-7710299a0ae5 h1:FaZD86+A9mVt7lh9glAryzQblMsbJYU2VnrdZ8yHlTs=
|
||||
|
@@ -9,15 +9,12 @@ import (
|
||||
"github.com/ipfs/go-log"
|
||||
qr "github.com/kairos-io/go-nodepair/qrcode"
|
||||
"github.com/kairos-io/kairos-sdk/utils"
|
||||
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
|
||||
"github.com/mudler/edgevpn/api"
|
||||
"github.com/mudler/edgevpn/cmd"
|
||||
"github.com/mudler/edgevpn/pkg/config"
|
||||
"github.com/mudler/edgevpn/pkg/logger"
|
||||
"github.com/mudler/edgevpn/pkg/node"
|
||||
"github.com/mudler/edgevpn/pkg/services"
|
||||
"github.com/mudler/edgevpn/pkg/vpn"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -113,90 +110,6 @@ func BridgeCMD(toolName string) *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func stringsToMultiAddr(peers []string) []multiaddr.Multiaddr {
|
||||
res := []multiaddr.Multiaddr{}
|
||||
for _, p := range peers {
|
||||
addr, err := multiaddr.NewMultiaddr(p)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
res = append(res, addr)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func configFromContext(c *cli.Context) *config.Config {
|
||||
autorelayInterval, err := time.ParseDuration(c.String("autorelay-discovery-interval"))
|
||||
if err != nil {
|
||||
autorelayInterval = 0
|
||||
}
|
||||
var limitConfig *rcmgr.PartialLimitConfig
|
||||
d := map[string]map[string]interface{}{}
|
||||
|
||||
return &config.Config{
|
||||
NetworkConfig: c.String("config"),
|
||||
NetworkToken: c.String("token"),
|
||||
Address: c.String("address"),
|
||||
Router: c.String("router"),
|
||||
Interface: c.String("interface"),
|
||||
Libp2pLogLevel: c.String("libp2p-log-level"),
|
||||
LogLevel: c.String("log-level"),
|
||||
LowProfile: c.Bool("low-profile"),
|
||||
Blacklist: c.StringSlice("blacklist"),
|
||||
Concurrency: c.Int("concurrency"),
|
||||
FrameTimeout: c.String("timeout"),
|
||||
ChannelBufferSize: c.Int("channel-buffer-size"),
|
||||
InterfaceMTU: c.Int("mtu"),
|
||||
PacketMTU: c.Int("packet-mtu"),
|
||||
BootstrapIface: c.Bool("bootstrap-iface"),
|
||||
Whitelist: stringsToMultiAddr(c.StringSlice("whitelist")),
|
||||
Ledger: config.Ledger{
|
||||
StateDir: c.String("ledger-state"),
|
||||
AnnounceInterval: time.Duration(c.Int("ledger-announce-interval")) * time.Second,
|
||||
SyncInterval: time.Duration(c.Int("ledger-syncronization-interval")) * time.Second,
|
||||
},
|
||||
NAT: config.NAT{
|
||||
Service: c.Bool("natservice"),
|
||||
Map: c.Bool("natmap"),
|
||||
RateLimit: c.Bool("nat-ratelimit"),
|
||||
RateLimitGlobal: c.Int("nat-ratelimit-global"),
|
||||
RateLimitPeer: c.Int("nat-ratelimit-peer"),
|
||||
RateLimitInterval: time.Duration(c.Int("nat-ratelimit-interval")) * time.Second,
|
||||
},
|
||||
Discovery: config.Discovery{
|
||||
BootstrapPeers: c.StringSlice("discovery-bootstrap-peers"),
|
||||
DHT: c.Bool("dht"),
|
||||
MDNS: c.Bool("mdns"),
|
||||
Interval: time.Duration(c.Int("discovery-interval")) * time.Second,
|
||||
},
|
||||
Connection: config.Connection{
|
||||
AutoRelay: c.Bool("autorelay"),
|
||||
MaxConnections: c.Int("max-connections"),
|
||||
HolePunch: c.Bool("holepunch"),
|
||||
StaticRelays: c.StringSlice("autorelay-static-peer"),
|
||||
AutoRelayDiscoveryInterval: autorelayInterval,
|
||||
OnlyStaticRelays: c.Bool("autorelay-static-only"),
|
||||
HighWater: c.Int("connection-high-water"),
|
||||
LowWater: c.Int("connection-low-water"),
|
||||
},
|
||||
Limit: config.ResourceLimit{
|
||||
Enable: c.Bool("limit-enable"),
|
||||
FileLimit: c.String("limit-file"),
|
||||
Scope: c.String("limit-scope"),
|
||||
MaxConns: c.Int("max-connections"), // Turn to 0 to use other way of limiting. Files take precedence
|
||||
LimitConfig: limitConfig,
|
||||
},
|
||||
PeerGuard: config.PeerGuard{
|
||||
Enable: c.Bool("peerguard"),
|
||||
PeerGate: c.Bool("peergate"),
|
||||
Relaxed: c.Bool("peergate-relaxed"),
|
||||
Autocleanup: c.Bool("peergate-autoclean"),
|
||||
SyncInterval: time.Duration(c.Int("peergate-interval")) * time.Second,
|
||||
AuthProviders: d,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// bridge is just starting a VPN with edgevpn to the given network token.
|
||||
func bridge(c *cli.Context) error {
|
||||
qrCodePath := ""
|
||||
@@ -234,7 +147,7 @@ func bridge(c *cli.Context) error {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
nc := configFromContext(c)
|
||||
nc := cmd.ConfigFromContext(c)
|
||||
|
||||
lvl, err := log.LevelFromString(nc.LogLevel)
|
||||
if err != nil {
|
||||
|
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/creack/pty"
|
||||
"github.com/gliderlabs/ssh"
|
||||
"github.com/mudler/edgevpn/cmd"
|
||||
"github.com/mudler/edgevpn/pkg/logger"
|
||||
"github.com/mudler/edgevpn/pkg/node"
|
||||
"github.com/mudler/edgevpn/pkg/services"
|
||||
@@ -24,7 +25,7 @@ func startRecoveryService(ctx context.Context, loglevel string, c *cliV2.Context
|
||||
return err
|
||||
}
|
||||
|
||||
nc := configFromContext(c)
|
||||
nc := cmd.ConfigFromContext(c)
|
||||
|
||||
lvl, err := log.LevelFromString(loglevel)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user