cli: Fix net reachability
This commit is contained in:
parent
9db478fd2e
commit
127d6d0576
@ -4,11 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"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"
|
"github.com/filecoin-project/lotus/build"
|
||||||
)
|
)
|
||||||
@ -70,5 +68,5 @@ func (v Version) String() string {
|
|||||||
|
|
||||||
type NatInfo struct {
|
type NatInfo struct {
|
||||||
Reachability network.Reachability
|
Reachability network.Reachability
|
||||||
PublicAddr ma.Multiaddr
|
PublicAddr string
|
||||||
}
|
}
|
||||||
|
@ -222,8 +222,8 @@ var NetReachability = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("AutoNAT status: ", i.Reachability.String())
|
fmt.Println("AutoNAT status: ", i.Reachability.String())
|
||||||
if i.PublicAddr != nil {
|
if i.PublicAddr != "" {
|
||||||
fmt.Println("Public address: ", i.PublicAddr.String())
|
fmt.Println("Public address: ", i.PublicAddr)
|
||||||
}
|
}
|
||||||
return nil
|
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) {
|
func (a *CommonAPI) NetAutoNatStatus(ctx context.Context) (i api.NatInfo, err error) {
|
||||||
autonat := a.RawHost.(*basichost.BasicHost).AutoNat
|
autonat := a.RawHost.(*basichost.BasicHost).AutoNat
|
||||||
|
|
||||||
var maddr ma.Multiaddr
|
var maddr string
|
||||||
if autonat.Status() == network.ReachabilityPublic {
|
if autonat.Status() == network.ReachabilityPublic {
|
||||||
maddr, err = autonat.PublicAddr()
|
pa, err := autonat.PublicAddr()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.NatInfo{}, err
|
return api.NatInfo{}, err
|
||||||
}
|
}
|
||||||
|
maddr = pa.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
return api.NatInfo{
|
return api.NatInfo{
|
||||||
|
Loading…
Reference in New Issue
Block a user