diff --git a/go.mod b/go.mod index ddf2add57d..67093b3c53 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/jaypipes/ghw v0.9.0 github.com/lib/pq v1.10.7 github.com/pterm/pterm v0.12.49 - github.com/skycoin/dmsg v0.0.0-20221007110410-643ca4fc9f82 + github.com/skycoin/dmsg v0.0.0-20221210172640-25f2ccd24123 github.com/skycoin/skywire-utilities v0.0.0-20220812192633-7137eb730383 github.com/skycoin/systray v1.10.1-0.20220630135132-48d2a1fb85d8 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 08102072d5..7be1bb95bd 100644 --- a/go.sum +++ b/go.sum @@ -535,6 +535,8 @@ github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/skycoin/dmsg v0.0.0-20221007110410-643ca4fc9f82 h1:AOjOMys6Ew+IkUHf0lIuaoW42cxQ7JUuq8J5A0mbloI= github.com/skycoin/dmsg v0.0.0-20221007110410-643ca4fc9f82/go.mod h1:ykPIRMpkSLssjwNKJpD/DF+F2NVTA/7Ja59gfOSDoh0= +github.com/skycoin/dmsg v0.0.0-20221210172640-25f2ccd24123 h1:yCZem366UX05jbiVoe4dKXYU+NRxZbnJjRu1CcNZBXg= +github.com/skycoin/dmsg v0.0.0-20221210172640-25f2ccd24123/go.mod h1:ykPIRMpkSLssjwNKJpD/DF+F2NVTA/7Ja59gfOSDoh0= 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= diff --git a/vendor/github.com/godbus/dbus/v5/conn.go b/vendor/github.com/godbus/dbus/v5/conn.go index 8080f3e918..69978ea26a 100644 --- a/vendor/github.com/godbus/dbus/v5/conn.go +++ b/vendor/github.com/godbus/dbus/v5/conn.go @@ -432,7 +432,7 @@ func (conn *Conn) inWorker() { case TypeSignal: conn.handleSignal(sequence, msg) case TypeMethodCall: -conn.handleCall(msg) + go conn.handleCall(msg) } } diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go b/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go index 9ab12a2e17..3e65b8e122 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go @@ -155,16 +155,36 @@ func (ce *Client) Serve(ctx context.Context) { if isClosed(ce.done) { return } - + var entries []*disc.Entry + var err error ce.log.Debug("Discovering dmsg servers...") - entries, err := ce.discoverServers(cancellabelCtx) - if err != nil { - ce.log.WithError(err).Warn("Failed to discover dmsg servers.") - if err == context.Canceled || err == context.DeadlineExceeded { - return + if ctx.Value("dmsgServer") != nil { + entries, err = ce.discoverServers(cancellabelCtx, true) + if err != nil { + ce.log.WithError(err).Warn("Failed to discover dmsg servers.") + if err == context.Canceled || err == context.DeadlineExceeded { + return + } + ce.serveWait() + continue + } + + for ind, entry := range entries { + if entry.Static.Hex() == ctx.Value("dmsgServer").(string) { + entries = entries[ind : ind+1] + } + } + } else { + entries, err = ce.discoverServers(cancellabelCtx, false) + + if err != nil { + ce.log.WithError(err).Warn("Failed to discover dmsg servers.") + if err == context.Canceled || err == context.DeadlineExceeded { + return + } + ce.serveWait() + continue } - ce.serveWait() - continue } if len(entries) == 0 { ce.log.Warnf("No entries found. Retrying after %s...", ce.bo.String()) @@ -228,9 +248,13 @@ func (ce *Client) Ready() <-chan struct{} { return ce.ready } -func (ce *Client) discoverServers(ctx context.Context) (entries []*disc.Entry, err error) { +func (ce *Client) discoverServers(ctx context.Context, all bool) (entries []*disc.Entry, err error) { err = netutil.NewDefaultRetrier(ce.log).Do(ctx, func() error { - entries, err = ce.dc.AvailableServers(ctx) + if all { + entries, err = ce.dc.AllServers(ctx) + } else { + entries, err = ce.dc.AvailableServers(ctx) + } return err }) return entries, err diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsgget/dmsgget.go b/vendor/github.com/skycoin/dmsg/pkg/dmsgget/dmsgget.go index 9df685e53c..0415e19275 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsgget/dmsgget.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsgget/dmsgget.go @@ -105,7 +105,7 @@ func (dg *DmsgGet) Run(ctx context.Context, log *logging.Logger, skStr string, a } }() - dmsgC, closeDmsg, err := dg.startDmsg(ctx, log, pk, sk) + dmsgC, closeDmsg, err := dg.StartDmsg(ctx, log, pk, sk) if err != nil { return fmt.Errorf("failed to start dmsg: %w", err) } @@ -192,7 +192,8 @@ func parseOutputFile(name string, urlPath string) (*os.File, error) { return nil, os.ErrExist } -func (dg *DmsgGet) startDmsg(ctx context.Context, log *logging.Logger, pk cipher.PubKey, sk cipher.SecKey) (dmsgC *dmsg.Client, stop func(), err error) { +// StartDmsg create dsmg client instance +func (dg *DmsgGet) StartDmsg(ctx context.Context, log *logging.Logger, pk cipher.PubKey, sk cipher.SecKey) (dmsgC *dmsg.Client, stop func(), err error) { dmsgC = dmsg.NewClient(pk, sk, disc.NewHTTP(dg.dmsgF.Disc, &http.Client{}, log), &dmsg.Config{MinSessions: dg.dmsgF.Sessions}) go dmsgC.Serve(context.Background()) diff --git a/vendor/modules.txt b/vendor/modules.txt index 3bb3ef5d5a..a16ead66fc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -209,7 +209,7 @@ github.com/shirou/gopsutil/v3/process ## explicit; go 1.13 github.com/sirupsen/logrus github.com/sirupsen/logrus/hooks/syslog -# github.com/skycoin/dmsg v0.0.0-20221007110410-643ca4fc9f82 +# github.com/skycoin/dmsg v0.0.0-20221210172640-25f2ccd24123 ## explicit; go 1.16 github.com/skycoin/dmsg/internal/servermetrics github.com/skycoin/dmsg/pkg/direct