From c3241c27649ce64c46729920983ad7b6fa9dce65 Mon Sep 17 00:00:00 2001 From: Tim Beatham Date: Sun, 11 Aug 2024 12:24:15 +0100 Subject: [PATCH] Improving the command help messages --- .gitmodules | 3 --- README.md | 4 ++++ cmd/smegctl/main.go | 12 +++++------- cmd/smegd/main.go | 7 ------- conf/client.yaml | 2 -- conf/peer.yaml | 2 -- examples/simple/docker-compose.yaml | 14 +++++++++++--- examples/simple/shared/configuration.yaml | 2 -- pkg/conf/conf.go | 2 -- pkg/conf/conf_test.go | 1 - pkg/crdt/datastore_test.go | 1 - pkg/ctrlserver/ctrlserver.go | 4 ++-- pkg/mesh/config.go | 2 +- pkg/mesh/manager_test.go | 3 +-- pkg/robin/requester.go | 4 ++-- smegmesh-web | 1 - 16 files changed, 26 insertions(+), 38 deletions(-) delete mode 160000 smegmesh-web diff --git a/.gitmodules b/.gitmodules index 7e60de2..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "smegmesh-web"] - path = smegmesh-web - url = git@github.com:tim-beatham/smegmesh-web.git diff --git a/README.md b/README.md index b8e7bf1..703b28e 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ Redundant routing is possible to create multiple exit points to the same mesh network. In which case consistent hashing is performed to split traffic between the exit points. +## Scalability + +The prototype has been tested to a scale of 3000 peers. + ## Installation To build the project do: `go build -v ./...`. A Docker file is provided diff --git a/cmd/smegctl/main.go b/cmd/smegctl/main.go index 21dd8cb..d7a704a 100644 --- a/cmd/smegctl/main.go +++ b/cmd/smegctl/main.go @@ -219,13 +219,11 @@ func main() { }) var newMeshRole *string = newMeshCmd.Selector("r", "role", []string{"peer", "client"}, &argparse.Options{ - Help: "Role in the mesh network. A value of peer means that the node is publicly routeable and thus considered" + - " in the gossip protocol. Client means that the node is not publicly routeable and is not a candidate in the gossip" + - " protocol", + Help: "Role in the mesh network. A peer is publicly route-able, whereas a client sits behind a private endpoint", }) var newMeshKeepAliveWg *int = newMeshCmd.Int("k", "KeepAliveWg", &argparse.Options{ Default: 0, - Help: "WireGuard KeepAlive value for NAT traversal and firewall holepunching", + Help: "WireGuard KeepAlive value for NAT traversal and firewall hole-punching", }) var newMeshAdvertiseRoutes *bool = newMeshCmd.Flag("a", "advertise", &argparse.Options{ @@ -251,9 +249,9 @@ func main() { }) var joinMeshRole *string = joinMeshCmd.Selector("r", "role", []string{"peer", "client"}, &argparse.Options{ - Help: "Role in the mesh network. A value of peer means that the node is publicly routeable and thus considered" + - " in the gossip protocol. Client means that the node is not publicly routeable and is not a candidate in the gossip" + - " protocol", + Help: "Role in the mesh network. A value of peer means that the node is publicly route-able acting as a router " + + "for clients to route packets through. A client sits behind a private endpoint and routes traffic through a single " + + "endpoint", }) var joinMeshPort *int = joinMeshCmd.Int("p", "wgport", &argparse.Options{ diff --git a/cmd/smegd/main.go b/cmd/smegd/main.go index c5db5a7..2ff0d73 100644 --- a/cmd/smegd/main.go +++ b/cmd/smegd/main.go @@ -1,7 +1,6 @@ package main import ( - "net/http" _ "net/http/pprof" "os" "os/signal" @@ -37,12 +36,6 @@ func main() { return } - if configuration.Profile { - go func() { - http.ListenAndServe("localhost:6060", nil) - }() - } - var robinRpc robin.WgRpc var robinIpc robin.IpcHandler var syncProvider sync.SyncServiceImpl diff --git a/conf/client.yaml b/conf/client.yaml index 8801de7..667f0eb 100644 --- a/conf/client.yaml +++ b/conf/client.yaml @@ -8,8 +8,6 @@ skipCertVerification: true timeout: 5 # gRPC port to run the solution gRPCPort: 4000 -# whether or not to run go profiler -profile: false # stubWg: whether to install WireGuard configurations # if true just tests the control plane stubWg: false diff --git a/conf/peer.yaml b/conf/peer.yaml index 1c4990c..b60cb73 100644 --- a/conf/peer.yaml +++ b/conf/peer.yaml @@ -8,8 +8,6 @@ skipCertVerification: true timeout: 5 # gRPC port to run the solution gRPCPort: 4000 -# whether or not to run go profiler -profile: false # stubWg: whether to install WireGuard configurations # if true just tests the control plane stubWg: false diff --git a/examples/simple/docker-compose.yaml b/examples/simple/docker-compose.yaml index 9fd3b6a..a1a7eef 100644 --- a/examples/simple/docker-compose.yaml +++ b/examples/simple/docker-compose.yaml @@ -1,9 +1,14 @@ version: '3' networks: net-1: + enable_ipv6: true + ipam: + driver: default + config: + - subnet: 2001:db8::/64 services: wg-1: - image: localhost/smegmesh-base:latest + image: smegmesh-base:latest cap_add: - NET_ADMIN - NET_RAW @@ -15,8 +20,9 @@ services: command: "smegd /shared/configuration.yaml" sysctls: - net.ipv6.conf.all.forwarding=1 + - net.ipv6.conf.all.disable_ipv6=0 wg-2: - image: localhost/smegmesh-base:latest + image: smegmesh-base:latest cap_add: - NET_ADMIN - NET_RAW @@ -28,8 +34,9 @@ services: command: "smegd /shared/configuration.yaml" sysctls: - net.ipv6.conf.all.forwarding=1 + - net.ipv6.conf.all.disable_ipv6=0 wg-3: - image: localhost/smegmesh-base:latest + image: smegmesh-base:latest cap_add: - NET_ADMIN - NET_RAW @@ -41,3 +48,4 @@ services: command: "smegd /shared/configuration.yaml" sysctls: - net.ipv6.conf.all.forwarding=1 + - net.ipv6.conf.all.disable_ipv6=0 diff --git a/examples/simple/shared/configuration.yaml b/examples/simple/shared/configuration.yaml index c722ac8..a1d7a14 100644 --- a/examples/simple/shared/configuration.yaml +++ b/examples/simple/shared/configuration.yaml @@ -8,8 +8,6 @@ skipCertVerification: true timeout: 5 # gRPC port to run the solution gRPCPort: 4000 -# whether or not to run go profiler -profile: false # stubWg: whether to install WireGuard configurations # if true just tests the control plane stubWg: false diff --git a/pkg/conf/conf.go b/pkg/conf/conf.go index 0d3f5e9..4814d85 100644 --- a/pkg/conf/conf.go +++ b/pkg/conf/conf.go @@ -77,8 +77,6 @@ type DaemonConfiguration struct { GrpcPort int `yaml:"gRPCPort" validate:"required"` // Timeout number of seconds without response that a node is considered unreachable by gRPC Timeout int `yaml:"timeout" validate:"required,gte=1"` - // Profile whether or not to include a http server that profiles the code - Profile bool `yaml:"profile"` // StubWg whether or not to stub the WireGuard types StubWg bool `yaml:"stubWg"` // SyncInterval specifies how long the minimum time should be between synchronisation diff --git a/pkg/conf/conf_test.go b/pkg/conf/conf_test.go index e7066f8..d36ec82 100644 --- a/pkg/conf/conf_test.go +++ b/pkg/conf/conf_test.go @@ -19,7 +19,6 @@ func getExampleConfiguration() *DaemonConfiguration { SkipCertVerification: true, GrpcPort: 25, Timeout: 5, - Profile: false, StubWg: false, SyncInterval: 2, Heartbeat: 2, diff --git a/pkg/crdt/datastore_test.go b/pkg/crdt/datastore_test.go index 5927349..936be7a 100644 --- a/pkg/crdt/datastore_test.go +++ b/pkg/crdt/datastore_test.go @@ -31,7 +31,6 @@ func setUpTests() *TestParams { SkipCertVerification: true, GrpcPort: 0, Timeout: 20, - Profile: false, SyncInterval: 2, Heartbeat: 10, ClusterSize: 32, diff --git a/pkg/ctrlserver/ctrlserver.go b/pkg/ctrlserver/ctrlserver.go index 440949f..32b7d28 100644 --- a/pkg/ctrlserver/ctrlserver.go +++ b/pkg/ctrlserver/ctrlserver.go @@ -15,7 +15,7 @@ import ( "golang.zx2c4.com/wireguard/wgctrl" ) -// NewCtrlServerParams are the params requried to create a new ctrl server +// NewCtrlServerParams are the params required to create a new ctrl server type NewCtrlServerParams struct { Conf *conf.DaemonConfiguration Client *wgctrl.Client @@ -52,7 +52,7 @@ func NewCtrlServer(params *NewCtrlServerParams) (*MeshCtrlServer, error) { IdGenerator: idGenerator, IPAllocator: ipAllocator, InterfaceManipulator: interfaceManipulator, - ConfigApplyer: configApplyer, + ConfigApplier: configApplyer, OnDelete: func(mesh mesh.MeshProvider) { _, err := syncer.Sync(mesh) diff --git a/pkg/mesh/config.go b/pkg/mesh/config.go index 248b210..5a79020 100644 --- a/pkg/mesh/config.go +++ b/pkg/mesh/config.go @@ -279,7 +279,7 @@ func (m *WgMeshConfigApplyer) getClientConfig(params *GetConfigParams) (*wgtypes installedRoutes := make([]lib.Route, 0) for _, route := range peerCfgs[0].AllowedIPs { - // Don't install routes that we are directly apart + // Don't install routes that we are directly a part // Dont install default route wgctrl handles this for us if !meshNet.Contains(route.IP) { installedRoutes = append(installedRoutes, lib.Route{ diff --git a/pkg/mesh/manager_test.go b/pkg/mesh/manager_test.go index 1d35e03..c3b23b8 100644 --- a/pkg/mesh/manager_test.go +++ b/pkg/mesh/manager_test.go @@ -22,7 +22,6 @@ func getMeshConfiguration() *conf.DaemonConfiguration { CaCertificatePath: "./somecacertificatepath", SkipCertVerification: true, Timeout: 5, - Profile: false, StubWg: true, SyncInterval: 2, Heartbeat: 60, @@ -48,7 +47,7 @@ func getMeshManager() MeshManager { IdGenerator: &lib.UUIDGenerator{}, IPAllocator: &ip.ULABuilder{}, InterfaceManipulator: &wg.WgInterfaceManipulatorStub{}, - ConfigApplyer: &MeshConfigApplyerStub{}, + ConfigApplier: &MeshConfigApplyerStub{}, RouteManager: &RouteManagerStub{}, }) diff --git a/pkg/robin/requester.go b/pkg/robin/requester.go index 775ac2e..d91f362 100644 --- a/pkg/robin/requester.go +++ b/pkg/robin/requester.go @@ -62,7 +62,7 @@ func (n *IpcHandler) CreateMesh(args *ipc.NewMeshArgs, reply *string) error { }) if err != nil { - return errors.New("could not create mesh") + return errors.New("could not create mesh: " + err.Error()) } *reply = meshId @@ -89,7 +89,7 @@ func (n *IpcHandler) JoinMesh(args *ipc.JoinMeshArgs, reply *string) error { overrideConf := getOverrideConfiguration(&args.WgArgs) if n.Server.GetMeshManager().GetMesh(args.MeshId) != nil { - return fmt.Errorf("user is already apart of the mesh") + return fmt.Errorf("user is already a part of the mesh") } peerConnection, err := n.Server.GetConnectionManager().GetConnection(args.IpAddress) diff --git a/smegmesh-web b/smegmesh-web deleted file mode 160000 index c1128bc..0000000 --- a/smegmesh-web +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c1128bcd98a6ce4a04d4fe55c210d115d564419a