Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setup node PKs #283

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/skywire-cli/commands/visor/gen-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func defaultConfig() *visor.Config {
conf.Dmsg.Discovery = skyenv.TestDmsgDiscAddr
conf.Transport.Discovery = skyenv.TestTpDiscAddr
conf.Routing.RouteFinder = skyenv.TestRouteFinderAddr
conf.Routing.SetupNodes = []cipher.PubKey{skyenv.MustPK(skyenv.TestSetupPK)}
}

conf.Hypervisors = []visor.HypervisorConfig{}
Expand Down
23 changes: 12 additions & 11 deletions internal/skyenv/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,15 @@ const (
DefaultDmsgDiscAddr = "http://dmsg.discovery.skywire.skycoin.com"
DefaultRouteFinderAddr = "http://routefinder.skywire.skycoin.com"
DefaultUptimeTrackerAddr = "http://uptime-tracker.skywire.skycoin.com"
DefaultSetupPK = "026c5a07de617c5c488195b76e8671bf9e7ee654d0633933e202af9e111ffa358d"
DefaultSetupPK = "0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
)

// MustDefaultSetupPK returns DefaultSetupPK as cipher.PubKey. It panics if unmarshaling fails.
func MustDefaultSetupPK() cipher.PubKey {
var sPK cipher.PubKey
if err := sPK.UnmarshalText([]byte(DefaultSetupPK)); err != nil {
panic(err)
}

return sPK
}

// Constants for testing deployment.
const (
TestTpDiscAddr = "http://transport.discovery.skywire.cc"
TestDmsgDiscAddr = "http://dmsg.discovery.skywire.cc"
TestRouteFinderAddr = "http://routefinder.skywire.cc"
TestSetupPK = "026c5a07de617c5c488195b76e8671bf9e7ee654d0633933e202af9e111ffa358d"
)

// Dmsg port constants.
Expand Down Expand Up @@ -59,3 +50,13 @@ const (
SkysocksClientPort = uint16(13)
SkysocksClientAddr = ":1080"
)

// MustPK unmarshals string PK to cipher.PubKey. It panics if unmarshaling fails.
func MustPK(pk string) cipher.PubKey {
var sPK cipher.PubKey
if err := sPK.UnmarshalText([]byte(pk)); err != nil {
panic(err)
}

return sPK
}
6 changes: 3 additions & 3 deletions pkg/visor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,15 @@ func DefaultLogStoreConfig() *LogStoreConfig {

// RoutingConfig configures routing.
type RoutingConfig struct {
SetupNodes []cipher.PubKey `json:"setup_nodes"`
SetupNodes []cipher.PubKey `json:"setup_nodes,omitempty"`
RouteFinder string `json:"route_finder"`
RouteFinderTimeout Duration `json:"route_finder_timeout,omitempty"`
}

// DefaultRoutingConfig returns default routing config.
func DefaultRoutingConfig() *RoutingConfig {
return &RoutingConfig{
SetupNodes: []cipher.PubKey{skyenv.MustDefaultSetupPK()},
SetupNodes: []cipher.PubKey{skyenv.MustPK(skyenv.DefaultSetupPK)},
RouteFinder: skyenv.DefaultRouteFinderAddr,
RouteFinderTimeout: DefaultTimeout,
}
Expand Down Expand Up @@ -477,7 +477,7 @@ type AppConfig struct {
App string `json:"app"`
AutoStart bool `json:"auto_start"`
Port routing.Port `json:"port"`
Args []string `json:"args"`
Args []string `json:"args,omitempty"`
}

// InterfaceConfig defines listening interfaces for skywire visor.
Expand Down