Skip to content

Commit

Permalink
Merge pull request #210 from mauromorales/master
Browse files Browse the repository at this point in the history
Bump urfave/cli to v2
  • Loading branch information
mudler authored Apr 23, 2024
2 parents f7f8137 + 9cd56fc commit 8cf7992
Show file tree
Hide file tree
Showing 12 changed files with 340 additions and 322 deletions.
10 changes: 5 additions & 5 deletions cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ import (
"github.com/mudler/edgevpn/api"
"github.com/mudler/edgevpn/pkg/node"
"github.com/mudler/edgevpn/pkg/services"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

func API() cli.Command {
return cli.Command{
func API() *cli.Command {
return &cli.Command{
Name: "api",
Usage: "Starts an http server to display network informations",
Description: `Start listening locally, providing an API for the network.
A simple UI interface is available to display network data.`,
UsageText: "edgevpn api",
Flags: append(CommonFlags,
&cli.BoolFlag{
Name: "enable-healthchecks",
EnvVar: "ENABLE_HEALTHCHECKS",
Name: "enable-healthchecks",
EnvVars: []string{"ENABLE_HEALTHCHECKS"},
},
&cli.BoolFlag{
Name: "debug",
Expand Down
39 changes: 20 additions & 19 deletions cmd/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,39 @@ import (

"github.com/mudler/edgevpn/pkg/node"
"github.com/mudler/edgevpn/pkg/services"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

func DNS() cli.Command {
return cli.Command{
func DNS() *cli.Command {
return &cli.Command{
Name: "dns",
Usage: "Starts a local dns server",
Description: `Start a local dns server which uses the blockchain to resolve addresses`,
UsageText: "edgevpn dns",
Flags: append(CommonFlags,
&cli.StringFlag{
Name: "listen",
Usage: "DNS listening address. Empty to disable dns server",
EnvVar: "DNSADDRESS",
Value: "",
Name: "listen",
Usage: "DNS listening address. Empty to disable dns server",
EnvVars: []string{"DNSADDRESS"},
Value: "",
},
&cli.BoolTFlag{
Name: "dns-forwarder",
Usage: "Enables dns forwarding",
EnvVar: "DNSFORWARD",
&cli.BoolFlag{
Name: "dns-forwarder",
Usage: "Enables dns forwarding",
EnvVars: []string{"DNSFORWARD"},
Value: true,
},
&cli.IntFlag{
Name: "dns-cache-size",
Usage: "DNS LRU cache size",
EnvVar: "DNSCACHESIZE",
Value: 200,
Name: "dns-cache-size",
Usage: "DNS LRU cache size",
EnvVars: []string{"DNSCACHESIZE"},
Value: 200,
},
&cli.StringSliceFlag{
Name: "dns-forward-server",
Usage: "List of DNS forward server, e.g. 8.8.8.8:53, 192.168.1.1:53 ...",
EnvVar: "DNSFORWARDSERVER",
Value: &cli.StringSlice{"8.8.8.8:53", "1.1.1.1:53"},
Name: "dns-forward-server",
Usage: "List of DNS forward server, e.g. 8.8.8.8:53, 192.168.1.1:53 ...",
EnvVars: []string{"DNSFORWARDSERVER"},
Value: cli.NewStringSlice("8.8.8.8:53", "1.1.1.1:53"),
},
),
Action: func(c *cli.Context) error {
Expand Down
18 changes: 9 additions & 9 deletions cmd/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/mudler/edgevpn/pkg/node"
"github.com/mudler/edgevpn/pkg/services"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

func cliNamePath(c *cli.Context) (name, path string, err error) {
Expand All @@ -43,21 +43,21 @@ func cliNamePath(c *cli.Context) (name, path string, err error) {
return name, path, nil
}

func FileSend() cli.Command {
return cli.Command{
func FileSend() *cli.Command {
return &cli.Command{
Name: "file-send",
Aliases: []string{"fs"},
Usage: "Serve a file to the network",
Description: `Serve a file to the network without connecting over VPN`,
UsageText: "edgevpn file-send unique-id /src/path",
Flags: append(CommonFlags,
cli.StringFlag{
&cli.StringFlag{
Name: "name",
Required: true,
Usage: `Unique name of the file to be served over the network.
This is also the ID used to refer when receiving it.`,
},
cli.StringFlag{
&cli.StringFlag{
Name: "path",
Usage: `File to serve`,
Required: true,
Expand Down Expand Up @@ -103,19 +103,19 @@ This is also the ID used to refer when receiving it.`,
}
}

func FileReceive() cli.Command {
return cli.Command{
func FileReceive() *cli.Command {
return &cli.Command{
Name: "file-receive",
Aliases: []string{"fr"},
Usage: "Receive a file which is served from the network",
Description: `Receive a file from the network without connecting over VPN`,
UsageText: "edgevpn file-receive unique-id /dst/path",
Flags: append(CommonFlags,
cli.StringFlag{
&cli.StringFlag{
Name: "name",
Usage: `Unique name of the file to be received over the network.`,
},
cli.StringFlag{
&cli.StringFlag{
Name: "path",
Usage: `Destination where to save the file`,
},
Expand Down
6 changes: 3 additions & 3 deletions cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
"context"

"github.com/mudler/edgevpn/pkg/node"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

func Start() cli.Command {
return cli.Command{
func Start() *cli.Command {
return &cli.Command{
Name: "start",
Usage: "Start the network without activating any interface",
Description: `Connect over the p2p network without establishing a VPN.
Expand Down
105 changes: 53 additions & 52 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
edgevpn "github.com/mudler/edgevpn/pkg/node"
"github.com/mudler/edgevpn/pkg/services"
"github.com/mudler/edgevpn/pkg/vpn"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

const Copyright string = ` edgevpn Copyright (C) 2021-2022 Ettore Di Giacinto
Expand Down Expand Up @@ -63,82 +63,83 @@ func MainFlags() []cli.Flag {
Usage: "Starts API with pprof attached",
},
&cli.BoolFlag{
Name: "api",
Usage: "Starts also the API daemon locally for inspecting the network status",
EnvVar: "API",
Name: "api",
Usage: "Starts also the API daemon locally for inspecting the network status",
EnvVars: []string{"API"},
},
&cli.StringFlag{
Name: "api-listen",
Value: "127.0.0.1:8080",
Usage: "API listening port",
EnvVar: "APILISTEN",
Name: "api-listen",
Value: "127.0.0.1:8080",
Usage: "API listening port",
EnvVars: []string{"APILISTEN"},
},
&cli.BoolFlag{
Name: "dhcp",
Usage: "Enables p2p ip negotiation (experimental)",
EnvVar: "DHCP",
Name: "dhcp",
Usage: "Enables p2p ip negotiation (experimental)",
EnvVars: []string{"DHCP"},
},
&cli.BoolFlag{
Name: "transient-conn",
Usage: "Allow transient connections",
EnvVar: "TRANSIENTCONN",
Name: "transient-conn",
Usage: "Allow transient connections",
EnvVars: []string{"TRANSIENTCONN"},
},
&cli.StringFlag{
Name: "lease-dir",
Value: filepath.Join(basedir, ".edgevpn", "leases"),
Usage: "DHCP leases directory",
EnvVar: "DHCPLEASEDIR",
Name: "lease-dir",
Value: filepath.Join(basedir, ".edgevpn", "leases"),
Usage: "DHCP leases directory",
EnvVars: []string{"DHCPLEASEDIR"},
},
&cli.StringFlag{
Name: "address",
Usage: "VPN virtual address",
EnvVar: "ADDRESS",
Value: "10.1.0.1/24",
Name: "address",
Usage: "VPN virtual address",
EnvVars: []string{"ADDRESS"},
Value: "10.1.0.1/24",
},
&cli.StringFlag{
Name: "dns",
Usage: "DNS listening address. Empty to disable dns server",
EnvVar: "DNSADDRESS",
Value: "",
Name: "dns",
Usage: "DNS listening address. Empty to disable dns server",
EnvVars: []string{"DNSADDRESS"},
Value: "",
},
&cli.BoolTFlag{
Name: "dns-forwarder",
Usage: "Enables dns forwarding",
EnvVar: "DNSFORWARD",
&cli.BoolFlag{
Name: "dns-forwarder",
Usage: "Enables dns forwarding",
EnvVars: []string{"DNSFORWARD"},
Value: true,
},
&cli.BoolFlag{
Name: "egress",
Usage: "Enables nodes for egress",
EnvVar: "EGRESS",
Name: "egress",
Usage: "Enables nodes for egress",
EnvVars: []string{"EGRESS"},
},
&cli.IntFlag{
Name: "egress-announce-time",
Usage: "Egress announce time (s)",
EnvVar: "EGRESSANNOUNCE",
Value: 200,
Name: "egress-announce-time",
Usage: "Egress announce time (s)",
EnvVars: []string{"EGRESSANNOUNCE"},
Value: 200,
},
&cli.IntFlag{
Name: "dns-cache-size",
Usage: "DNS LRU cache size",
EnvVar: "DNSCACHESIZE",
Value: 200,
Name: "dns-cache-size",
Usage: "DNS LRU cache size",
EnvVars: []string{"DNSCACHESIZE"},
Value: 200,
},
&cli.StringSliceFlag{
Name: "dns-forward-server",
Usage: "List of DNS forward server, e.g. 8.8.8.8:53, 192.168.1.1:53 ...",
EnvVar: "DNSFORWARDSERVER",
Value: &cli.StringSlice{"8.8.8.8:53", "1.1.1.1:53"},
Name: "dns-forward-server",
Usage: "List of DNS forward server, e.g. 8.8.8.8:53, 192.168.1.1:53 ...",
EnvVars: []string{"DNSFORWARDSERVER"},
Value: cli.NewStringSlice("8.8.8.8:53", "1.1.1.1:53"),
},
&cli.StringFlag{
Name: "router",
Usage: "Sends all packets to this node",
EnvVar: "ROUTER",
Name: "router",
Usage: "Sends all packets to this node",
EnvVars: []string{"ROUTER"},
},
&cli.StringFlag{
Name: "interface",
Usage: "Interface name",
Value: "edgevpn0",
EnvVar: "IFACE",
Name: "interface",
Usage: "Interface name",
Value: "edgevpn0",
EnvVars: []string{"IFACE"},
}}, CommonFlags...)
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/peergate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
"fmt"

"github.com/mudler/edgevpn/pkg/trustzone/authprovider/ecdsa"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

func Peergate() cli.Command {
return cli.Command{
func Peergate() *cli.Command {
return &cli.Command{
Name: "peergater",
Usage: "peergater ecdsa-genkey",
Description: `Peergater auth utilities`,
Expand Down
30 changes: 15 additions & 15 deletions cmd/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,36 @@ import (
"github.com/mudler/edgevpn/api"
"github.com/mudler/edgevpn/pkg/node"
"github.com/mudler/edgevpn/pkg/services"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

func Proxy() cli.Command {
return cli.Command{
func Proxy() *cli.Command {
return &cli.Command{
Name: "proxy",
Usage: "Starts a local http proxy server to egress nodes",
Description: `Start a proxy locally, providing an ingress point for the network.`,
UsageText: "edgevpn proxy",
Flags: append(CommonFlags,
&cli.StringFlag{
Name: "listen",
Value: ":8080",
Usage: "Listening address",
EnvVar: "PROXYLISTEN",
Name: "listen",
Value: ":8080",
Usage: "Listening address",
EnvVars: []string{"PROXYLISTEN"},
},
&cli.BoolFlag{
Name: "debug",
},
&cli.IntFlag{
Name: "interval",
Usage: "proxy announce time interval",
EnvVar: "PROXYINTERVAL",
Value: 120,
Name: "interval",
Usage: "proxy announce time interval",
EnvVars: []string{"PROXYINTERVAL"},
Value: 120,
},
&cli.IntFlag{
Name: "dead-interval",
Usage: "interval (in seconds) wether detect egress nodes offline",
EnvVar: "PROXYDEADINTERVAL",
Value: 600,
Name: "dead-interval",
Usage: "interval (in seconds) wether detect egress nodes offline",
EnvVars: []string{"PROXYDEADINTERVAL"},
Value: 600,
},
),
Action: func(c *cli.Context) error {
Expand Down
Loading

0 comments on commit 8cf7992

Please sign in to comment.