Merge remote-tracking branch 'origin/next' into ntwk-calibration
This commit is contained in:
commit
4989882402
@ -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
|
||||
},
|
||||
|
@ -59,7 +59,14 @@ var actorSetAddrsCmd = &cli.Command{
|
||||
return fmt.Errorf("failed to parse %q as a multiaddr: %w", a, err)
|
||||
}
|
||||
|
||||
addrs = append(addrs, maddr.Bytes())
|
||||
maddrNop2p, strip := ma.SplitFunc(maddr, func(c ma.Component) bool {
|
||||
return c.Protocol().Code == ma.P_P2P
|
||||
})
|
||||
|
||||
if strip != nil {
|
||||
fmt.Println("Stripping peerid ", strip, " from ", maddr)
|
||||
}
|
||||
addrs = append(addrs, maddrNop2p.Bytes())
|
||||
}
|
||||
|
||||
maddr, err := nodeAPI.ActorAddress(ctx)
|
||||
|
@ -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