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 two panic issues on skywire-cli commands #1671

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
21 changes: 13 additions & 8 deletions pkg/visor/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ func (v *Visor) Overview() (*Overview, error) {
var publicIP string
var isSymmetricNAT bool
if v == nil {
panic("v is nil")
return &Overview{}, ErrVisorNotAvailable
}
if v.tpM == nil {
panic("tpM is nil")
return &Overview{}, ErrTrpMangerNotAvailable
}
v.tpM.WalkTransports(func(tp *transport.ManagedTransport) bool {
tSummaries = append(tSummaries,
Expand Down Expand Up @@ -1032,6 +1032,9 @@ func (v *Visor) Ports() (map[string]PortDetail, error) {
// TransportTypes implements API.
func (v *Visor) TransportTypes() ([]string, error) {
var types []string
if v.tpM == nil {
return types, ErrTrpMangerNotAvailable
}
for _, netType := range v.tpM.Networks() {
types = append(types, string(netType))
}
Expand Down Expand Up @@ -1064,12 +1067,14 @@ func (v *Visor) Transports(types []string, pks []cipher.PubKey, logs bool) ([]*T
}
return true
}
v.tpM.WalkTransports(func(tp *transport.ManagedTransport) bool {
if typeIncluded(tp.Type()) && pkIncluded(v.tpM.Local(), tp.Remote()) {
result = append(result, newTransportSummary(v.tpM, tp, logs, v.router.SetupIsTrusted(tp.Remote())))
}
return true
})
if v.tpM != nil {
v.tpM.WalkTransports(func(tp *transport.ManagedTransport) bool {
if typeIncluded(tp.Type()) && pkIncluded(v.tpM.Local(), tp.Remote()) {
result = append(result, newTransportSummary(v.tpM, tp, logs, v.router.SetupIsTrusted(tp.Remote())))
}
return true
})
}

return result, nil
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/visor/visor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import (
)

var (
// ErrVisorNotAvailable represents error for unavailable visor
ErrVisorNotAvailable = errors.New("no visor available")
// ErrAppProcNotRunning represents lookup error for App related calls.
ErrAppProcNotRunning = errors.New("no process of given app is running")
// ErrProcNotAvailable represents error for unavailable process manager
Expand Down
Loading