Skip to content

Commit

Permalink
Merge pull request #1671 from mrpalide/fix/panic-on-late-dmsg-connect…
Browse files Browse the repository at this point in the history
…ion-stablished-on-rpc

Fix two panic issues on `skywire-cli` commands
  • Loading branch information
jdknives authored Nov 2, 2023
2 parents 7d0fd2e + a1b6446 commit f962b68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 13 additions & 8 deletions pkg/visor/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,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 @@ -1074,6 +1074,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 @@ -1106,12 +1109,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

0 comments on commit f962b68

Please sign in to comment.