From 4f5937e25d1ccd6f6b2e31806e6456a3cdeb01f2 Mon Sep 17 00:00:00 2001 From: xmonader Date: Mon, 4 Sep 2023 10:00:35 +0300 Subject: [PATCH 1/4] Rename LICENCE to LICENSE (#2041) --- LICENCE => LICENSE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENCE => LICENSE (100%) diff --git a/LICENCE b/LICENSE similarity index 100% rename from LICENCE rename to LICENSE From 0a5b091abbb3329b8522aadb446290176cdd6061 Mon Sep 17 00:00:00 2001 From: Muhamad Awad Date: Thu, 7 Sep 2023 14:32:54 +0200 Subject: [PATCH 2/4] fix dependencies (#2049) * fix dependencies * add missing dep --- go.mod | 13 +++++++------ go.sum | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 43da2e255..b0163e96f 100644 --- a/go.mod +++ b/go.mod @@ -26,9 +26,9 @@ require ( github.com/g0rbe/go-chattr v0.0.0-20190906133247-aa435a6a0a37 github.com/gizak/termui/v3 v3.1.0 github.com/go-redis/redis v6.15.9+incompatible - github.com/gomodule/redigo v2.0.0+incompatible + github.com/gomodule/redigo v1.8.9 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 - github.com/google/uuid v1.3.0 + github.com/google/uuid v1.3.1 github.com/gorilla/mux v1.8.0 github.com/gtank/merlin v0.1.1 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d @@ -39,12 +39,12 @@ require ( github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 - github.com/rs/zerolog v1.29.1 + github.com/rs/zerolog v1.30.0 github.com/shirou/gopsutil v3.21.11+incompatible - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 github.com/threefoldtech/0-fs v1.3.1-0.20230829115549-fb4c502d6d93 github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20230809064214-d8ef5ca360eb - github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.4.0 + github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.11.0 github.com/threefoldtech/zbus v1.0.1 github.com/tyler-smith/go-bip39 v1.1.0 github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa @@ -81,6 +81,7 @@ require ( github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect @@ -142,7 +143,7 @@ require ( google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect google.golang.org/grpc v1.41.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/djherbis/times.v1 v1.2.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index c11e31e72..8b1a270d5 100644 --- a/go.sum +++ b/go.sum @@ -182,6 +182,8 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -208,6 +210,7 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gologme/log v1.2.0/go.mod h1:gq31gQ8wEHkR+WekdWsqDuf8pXTUZA9BnnzTuPz1Y9U= +github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws= github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE= github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= @@ -232,6 +235,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= @@ -441,9 +446,12 @@ github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE= github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.14.3/go.mod h1:3WXPzbXEEliJ+a6UFE4vhIxV8qR1EML6ngzP9ug4eYg= github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -482,6 +490,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stripe/safesql v0.2.0/go.mod h1:q7b2n0JmzM1mVGfcYpanfVb2j23cXZeWFxcILPn3JV4= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/threefoldtech/0-fs v1.3.1-0.20230829115549-fb4c502d6d93 h1:zUuaeCpE92+1yOhMp267rslwdBiYl5UvE1K3lzlHBfk= @@ -490,6 +500,8 @@ github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20230809064214 github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20230809064214-d8ef5ca360eb/go.mod h1:dtDKAPiUDxAwIkfHV7xcAFZcOm+xwNIuOI1MLFS+MeQ= github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.4.0 h1:fmCYshC+u0/1nqlu10TnZjZeywioXOSWpm6n8zPKgkI= github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.4.0/go.mod h1:tttnc/l4F2lx1SyETTiLrMaiQEgMeGCvlVEIW6nUeJA= +github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.11.0 h1:jKhRXSuQFCMuUZ1VEPaqKZ/sxh6wsruwayCFI0vAFlI= +github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.11.0/go.mod h1:IAvYTKCMhl1ngwITEmMhmM7zJHbF1clywZ5kZ+ouPM0= github.com/threefoldtech/zbus v1.0.1 h1:3KaEpyOiDYAw+lrAyoQUGIvY9BcjVRXlQ1beBRqhRNk= github.com/threefoldtech/zbus v1.0.1/go.mod h1:E/v/xEvG/l6z/Oj0aDkuSUXFm/1RVJkhKBwDTAIdsHo= github.com/tinylib/msgp v1.1.5 h1:2gXmtWueD2HefZHQe1QOy9HVzmFrLOVvsXwXBQ0ayy0= @@ -771,6 +783,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From c4f03656dacb00bd0f7d12bfcd290c4673ec4a49 Mon Sep 17 00:00:00 2001 From: Rawda Fawzy <47260239+rawdaGastan@users.noreply.github.com> Date: Thu, 7 Sep 2023 17:01:20 +0300 Subject: [PATCH 3/4] add iperf service (#2042) * add iperf service * remove unused functions * change error msg * check service status * add port for iperf --- cmds/modules/networkd/main.go | 2 +- pkg/network/iperf/iperf.go | 42 +++++++++++++++++++++++++++++++++++ pkg/network/networker.go | 3 ++- pkg/network/public/public.go | 5 +++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 pkg/network/iperf/iperf.go diff --git a/cmds/modules/networkd/main.go b/cmds/modules/networkd/main.go index 13aee28ae..4d60e9630 100644 --- a/cmds/modules/networkd/main.go +++ b/cmds/modules/networkd/main.go @@ -122,7 +122,7 @@ func action(cli *cli.Context) error { ygg, err := yggdrasil.EnsureYggdrasil(ctx, identity.PrivateKey(cli.Context), yggNs) if err != nil { - return errors.Wrap(err, "fail to start yggdrasil") + return errors.Wrap(err, "failed to start yggdrasil") } if public.HasPublicSetup() { diff --git a/pkg/network/iperf/iperf.go b/pkg/network/iperf/iperf.go new file mode 100644 index 000000000..dc880615a --- /dev/null +++ b/pkg/network/iperf/iperf.go @@ -0,0 +1,42 @@ +package iperf + +import ( + "fmt" + "os/exec" + + "github.com/pkg/errors" + "github.com/threefoldtech/zos/pkg/zinit" +) + +const ( + zinitService = "iperf" + // IperfPort is the port for the iperf service + IperfPort = 300 +) + +// Ensure creates an iperf zinit service and monitors it +func Ensure(z *zinit.Client) error { + if _, err := z.Status(zinitService); err == nil { + return nil + } + + _, err := exec.LookPath("iperf") + if err != nil { + return err + } + + cmd := fmt.Sprintf("ip netns exec public iperf -s -p %d", IperfPort) + + err = zinit.AddService(zinitService, zinit.InitService{ + Exec: cmd, + After: []string{ + "networkd", + }, + }) + + if err != nil { + return errors.Wrap(err, "failed to add iperf service") + } + + return z.Monitor(zinitService) +} diff --git a/pkg/network/networker.go b/pkg/network/networker.go index 80906ac10..71f3a9b50 100644 --- a/pkg/network/networker.go +++ b/pkg/network/networker.go @@ -20,6 +20,7 @@ import ( "github.com/threefoldtech/zos/pkg/gridtypes" "github.com/threefoldtech/zos/pkg/gridtypes/zos" "github.com/threefoldtech/zos/pkg/network/bootstrap" + "github.com/threefoldtech/zos/pkg/network/iperf" "github.com/threefoldtech/zos/pkg/network/ndmz" "github.com/threefoldtech/zos/pkg/network/public" "github.com/threefoldtech/zos/pkg/network/tuntap" @@ -114,7 +115,7 @@ func NewNetworker(identity *stubs.IdentityManagerStub, ndmz ndmz.DMZ, ygg *yggdr // always add the reserved yggdrasil port to the port set so we make sure they are never // picked for wireguard endpoints // we also add http, https, and traefik metrics ports 8082 to the list. - for _, port := range []int{yggdrasil.YggListenTCP, yggdrasil.YggListenTLS, yggdrasil.YggListenLinkLocal, 80, 443, 8082} { + for _, port := range []int{yggdrasil.YggListenTCP, yggdrasil.YggListenTLS, yggdrasil.YggListenLinkLocal, iperf.IperfPort, 80, 443, 8082} { if err := nw.portSet.Add(uint(port)); err != nil && errors.Is(err, set.ErrConflict{}) { return nil, err } diff --git a/pkg/network/public/public.go b/pkg/network/public/public.go index 757fa561d..5ffa6f502 100644 --- a/pkg/network/public/public.go +++ b/pkg/network/public/public.go @@ -14,6 +14,7 @@ import ( "github.com/threefoldtech/zos/pkg/network/bootstrap" "github.com/threefoldtech/zos/pkg/network/bridge" "github.com/threefoldtech/zos/pkg/network/ifaceutil" + "github.com/threefoldtech/zos/pkg/network/iperf" "github.com/threefoldtech/zos/pkg/network/macvlan" "github.com/threefoldtech/zos/pkg/network/namespace" "github.com/threefoldtech/zos/pkg/network/options" @@ -339,6 +340,10 @@ func EnsurePublicSetup(nodeID pkg.Identifier, inf *pkg.PublicConfig) (*netlink.B if err := setupPublicNS(nodeID, inf); err != nil { return nil, errors.Wrap(err, "failed to ensure public namespace setup") } + + if err := iperf.Ensure(zinit.Default()); err != nil { + return nil, errors.Wrap(err, "failed to ensure iperf service") + } } return br, netlink.LinkSetUp(br) From da41ed4ac79468e9f21e44587d3cb195d17271a8 Mon Sep 17 00:00:00 2001 From: xmonader Date: Fri, 8 Sep 2023 14:11:26 +0300 Subject: [PATCH 4/4] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 88b9a9677..e34169304 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright TF TECH NV (Belgium) + Copyright 2023 TF TECH NV (Belgium) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.