Skip to content

Commit

Permalink
little improve on skywire and setup-node (#1723)
Browse files Browse the repository at this point in the history
* set default min session on dmsg servers 2

* add randomize on getHTTPClient dmsg servers list

* add setupNode context value for setup-node request to dmsg

* update dmsg@develop

* use env variable instead fix 2 value on min sess

* revert MINDMSGSESS to 8 on env
  • Loading branch information
mrpalide authored Feb 5, 2024
1 parent fa090e6 commit f00c68a
Show file tree
Hide file tree
Showing 29 changed files with 271 additions and 168 deletions.
2 changes: 1 addition & 1 deletion cmd/skywire-cli/commands/config/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func init() {
gHiddenFlags = append(gHiddenFlags, "noauth")
genConfigCmd.Flags().BoolVarP(&isDmsgHTTP, "dmsghttp", "d", scriptExecBool("${DMSGHTTP:-false}"), "use dmsg connection to skywire services\033[0m")
gHiddenFlags = append(gHiddenFlags, "dmsghttp")
genConfigCmd.Flags().IntVar(&minDmsgSess, "minsess", scriptExecInt("${MINDMSGSESS:-1}"), "number of dmsg servers to connect to (0 = unlimited)\033[0m")
genConfigCmd.Flags().IntVar(&minDmsgSess, "minsess", scriptExecInt("${MINDMSGSESS:-2}"), "number of dmsg servers to connect to (0 = unlimited)\033[0m")
gHiddenFlags = append(gHiddenFlags, "minsess")
genConfigCmd.Flags().BoolVarP(&isEnableAuth, "auth", "e", false, "enable auth on hypervisor UI\033[0m")
gHiddenFlags = append(gHiddenFlags, "auth")
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/ccding/go-stun/stun v0.0.0-20200514191101-4dc67bcdb029
github.com/gen2brain/dlgs v0.0.0-20220603100644-40c77870fa8d
github.com/gin-gonic/gin v1.9.1
github.com/go-chi/chi/v5 v5.0.10
github.com/go-chi/chi/v5 v5.0.11
github.com/gocarina/gocsv v0.0.0-20230616125104-99d496ca653d
github.com/google/uuid v1.3.1
github.com/gorilla/securecookie v1.1.1
Expand All @@ -27,7 +27,7 @@ require (
github.com/orandin/lumberjackrus v1.0.1
github.com/pterm/pterm v0.12.66
github.com/sirupsen/logrus v1.9.3
github.com/skycoin/dmsg v1.3.14
github.com/skycoin/dmsg v1.3.15-0.20240201143600-b1d1d1012348
github.com/skycoin/skycoin v0.27.1
github.com/skycoin/skycoin-service-discovery v0.0.0-20231221001759-d1af6ec27db1
github.com/skycoin/skywire-services v0.0.0-20231221001820-3212895ddf12
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec=
github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk=
github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA=
github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
Expand Down Expand Up @@ -429,8 +429,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skycoin/dmsg v1.3.14 h1:UK3/XxMFoG9xEabJ25u0jJiu143BsBhVM5tXY/gl8YI=
github.com/skycoin/dmsg v1.3.14/go.mod h1:r49d63rqTsiUUj2JG9P9Sl3MkmMbO9+YuB19vGQOfHE=
github.com/skycoin/dmsg v1.3.15-0.20240201143600-b1d1d1012348 h1:UYKHYIcwI/cHcdctJFkMXTR94vgRuYvNejU7vecLOi8=
github.com/skycoin/dmsg v1.3.15-0.20240201143600-b1d1d1012348/go.mod h1:I4Bgha3DPNOoimvUtQmAjGUSknw4o/jaBVMY+KNz9vY=
github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 h1:1Nc5EBY6pjfw1kwW0duwyG+7WliWz5u9kgk1h5MnLuA=
github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:UXghlricA7J3aRD/k7p/zBObQfmBawwCxIVPVjz2Q3o=
github.com/skycoin/skycoin v0.27.1 h1:HatxsRwVSPaV4qxH6290xPBmkH/HgiuAoY2qC+e8C9I=
Expand Down
3 changes: 2 additions & 1 deletion pkg/router/setupnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func NewNode(conf *SetupConfig) (*Node, error) {
dmsgDisc := disc.NewHTTP(conf.Dmsg.Discovery, &http.Client{}, packageLogger)
dmsgConf := &dmsg.Config{MinSessions: conf.Dmsg.SessionsCount}
dmsgC := dmsg.NewClient(conf.PK, conf.SK, dmsgDisc, dmsgConf)
go dmsgC.Serve(context.Background())
ctx := context.WithValue(context.Background(), "setupNode", true) //nolint
go dmsgC.Serve(ctx)

log.WithField("local_pk", conf.PK).WithField("dmsg_conf", conf.Dmsg).
Info("Connecting to the dmsg network.")
Expand Down
6 changes: 5 additions & 1 deletion pkg/visor/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"errors"
"fmt"
"io"
"math/rand"
"mime"
"net"
"net/http"
Expand Down Expand Up @@ -1601,7 +1602,10 @@ func getHTTPClient(ctx context.Context, v *Visor, service string) (*http.Client,
if err != nil {
return nil, fmt.Errorf("error getting AvailableServers: %w", err)
}

// randomize dmsg servers list
rand.Shuffle(len(servers), func(i, j int) {
servers[i], servers[j] = servers[j], servers[i]
})
for _, server := range servers {
delegatedServers = append(delegatedServers, server.Static)
}
Expand Down
9 changes: 7 additions & 2 deletions vendor/github.com/go-chi/chi/v5/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/go-chi/chi/v5/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/go-chi/chi/v5/SECURITY.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 13 additions & 10 deletions vendor/github.com/go-chi/chi/v5/context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 17 additions & 22 deletions vendor/github.com/go-chi/chi/v5/middleware/compress.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions vendor/github.com/go-chi/chi/v5/middleware/logger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions vendor/github.com/go-chi/chi/v5/middleware/nocache.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 8 additions & 24 deletions vendor/github.com/go-chi/chi/v5/middleware/profiler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions vendor/github.com/go-chi/chi/v5/middleware/recoverer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f00c68a

Please sign in to comment.