From 1c2fcecd4bb67a4d8475e6609715181a1c914887 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:27:30 -0500 Subject: [PATCH] Fix wrong hardcoded default dmsg discovery (#271) * change hardcoded dmsg discovery to use skywire-utilities/pkg/skyenv.DmsgDiscAddr --- .../dmsg-example-http-server/dmsg-example-http-server.go | 3 ++- go.mod | 2 +- pkg/dmsg/const.go | 4 +++- pkg/dmsgcurl/flags.go | 3 ++- pkg/dmsgserver/config.go | 5 +++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/dmsgcurl/dmsg-example-http-server/dmsg-example-http-server.go b/examples/dmsgcurl/dmsg-example-http-server/dmsg-example-http-server.go index e6268274b..42a025c66 100644 --- a/examples/dmsgcurl/dmsg-example-http-server/dmsg-example-http-server.go +++ b/examples/dmsgcurl/dmsg-example-http-server/dmsg-example-http-server.go @@ -12,6 +12,7 @@ import ( "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/cmdutil" "github.com/skycoin/skywire-utilities/pkg/logging" + "github.com/skycoin/skywire-utilities/pkg/skyenv" "github.com/skycoin/dmsg/pkg/disc" dmsg "github.com/skycoin/dmsg/pkg/dmsg" @@ -19,7 +20,7 @@ import ( var ( dir = "." // local dir to serve via http - dmsgDisc = "http://dmsgd.skywire.skycoin.com" + dmsgDisc = skyenv.DmsgDiscAddr dmsgPort = uint(80) pk, sk = cipher.GenerateKeyPair() ) diff --git a/go.mod b/go.mod index 15c3bd76f..162bbbba7 100644 --- a/go.mod +++ b/go.mod @@ -72,4 +72,4 @@ require ( // Uncomment for tests with alternate branches of 'skywire-utilities' // replace github.com/skycoin/skywire-utilities => ../skywire-utilities -//replace github.com/skycoin/skywire-utilities => github.com/skycoin/skywire-utilities +// replace github.com/skycoin/skywire-utilities => github.com/skycoin/skywire-utilities diff --git a/pkg/dmsg/const.go b/pkg/dmsg/const.go index 731c2bc8d..2718c8c2a 100644 --- a/pkg/dmsg/const.go +++ b/pkg/dmsg/const.go @@ -3,11 +3,13 @@ package dmsg import ( "time" + + "github.com/skycoin/skywire-utilities/pkg/skyenv" ) // Constants. const ( - DefaultDiscAddr = "http://dmsgd.skywire.skycoin.com" + DefaultDiscAddr = skyenv.DmsgDiscAddr DefaultMinSessions = 1 diff --git a/pkg/dmsgcurl/flags.go b/pkg/dmsgcurl/flags.go index e763a0599..4f07c2282 100644 --- a/pkg/dmsgcurl/flags.go +++ b/pkg/dmsgcurl/flags.go @@ -5,6 +5,7 @@ import ( "flag" "github.com/skycoin/skywire-utilities/pkg/buildinfo" + "github.com/skycoin/skywire-utilities/pkg/skyenv" ) // ExecName contains the execution name. @@ -38,7 +39,7 @@ type dmsgFlags struct { func (f *dmsgFlags) Name() string { return "Dmsg" } func (f *dmsgFlags) Init(fs *flag.FlagSet) { - fs.StringVar(&f.Disc, "dmsg-disc", "http://dmsgd.skywire.skycoin.com", "dmsg discovery `URL`") + fs.StringVar(&f.Disc, "dmsg-disc", skyenv.DmsgDiscAddr, "dmsg discovery `URL`") fs.IntVar(&f.Sessions, "dmsg-sessions", 1, "connect to `NUMBER` of dmsg servers") } diff --git a/pkg/dmsgserver/config.go b/pkg/dmsgserver/config.go index 98b3f9890..27c3fb2e5 100644 --- a/pkg/dmsgserver/config.go +++ b/pkg/dmsgserver/config.go @@ -8,17 +8,18 @@ import ( "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/skyenv" ) const ( - defaultDiscoveryURL = "http://dmsgd.skywire.skycoin.com" + defaultDiscoveryURL = skyenv.DmsgDiscAddr defaultPublicAddress = "127.0.0.1:8081" defaultLocalAddress = ":8081" defaultHTTPAddress = ":8082" // DefaultConfigPath default path of config file DefaultConfigPath = "config.json" // DefaultDiscoverURLTest default URL for discovery in test env - DefaultDiscoverURLTest = "http://dmsgd.skywire.dev" + DefaultDiscoverURLTest = skyenv.TestDmsgDiscAddr ) // Config is structure of config file