Merge pull request #3130 from filecoin-project/fix/reachability-cli
cli: Fix net reachability
This commit is contained in:
commit
1bd90d0701
@ -4,11 +4,9 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
|
||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
)
|
||||
@ -70,5 +68,5 @@ func (v Version) String() string {
|
||||
|
||||
type NatInfo struct {
|
||||
Reachability network.Reachability
|
||||
PublicAddr ma.Multiaddr
|
||||
PublicAddr string
|
||||
}
|
||||
|
@ -222,8 +222,8 @@ var NetReachability = &cli.Command{
|
||||
}
|
||||
|
||||
fmt.Println("AutoNAT status: ", i.Reachability.String())
|
||||
if i.PublicAddr != nil {
|
||||
fmt.Println("Public address: ", i.PublicAddr.String())
|
||||
if i.PublicAddr != "" {
|
||||
fmt.Println("Public address: ", i.PublicAddr)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -118,12 +118,13 @@ func (a *CommonAPI) NetFindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo,
|
||||
func (a *CommonAPI) NetAutoNatStatus(ctx context.Context) (i api.NatInfo, err error) {
|
||||
autonat := a.RawHost.(*basichost.BasicHost).AutoNat
|
||||
|
||||
var maddr ma.Multiaddr
|
||||
var maddr string
|
||||
if autonat.Status() == network.ReachabilityPublic {
|
||||
maddr, err = autonat.PublicAddr()
|
||||
pa, err := autonat.PublicAddr()
|
||||
if err != nil {
|
||||
return api.NatInfo{}, err
|
||||
}
|
||||
maddr = pa.String()
|
||||
}
|
||||
|
||||
return api.NatInfo{
|
||||
|
Loading…
Reference in New Issue
Block a user