-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
multiformats/go-multiaddr
#135Labels
kind/bugA bug in existing code (including security flaws)A bug in existing code (including security flaws)nat-traversal
Description
Given a server:
h, err := libp2p.New(ctx, libp2p.NoListenAddrs)
if err != nil {
panic(err)
}
addr := "/ip4/0.0.0.0/tcp/2001"
if err := h.Network().Listen(ma.StringCast(addr)); err != nil {
panic(err)
}
sub, err := h.EventBus().Subscribe(new(event.EvtPeerIdentificationCompleted))
if err != nil {
panic(err)
}
for {
select {
case ev := <-sub.Out():
p := ev.(event.EvtPeerIdentificationCompleted).Peer
fmt.Println("\n Connected to a new peer")
fmt.Println("Local addr is", h.Network().ConnsToPeer(p)[0].LocalMultiaddr())
fmt.Println("Remote Addr is", h.Network().ConnsToPeer(p)[0].RemoteMultiaddr())
}
}
}
and then the client code:
func main() {
ctx := context.Background()
h, err := libp2p.New(ctx, libp2p.NoListenAddrs)
if err != nil {
panic(err)
}
sub, err := h.EventBus().Subscribe(new(event.EvtPeerIdentificationCompleted))
if err != nil {
panic(err)
}
addr := ma.StringCast("/ip4/127.0.0.1/tcp/2001")
id, err := peer.Decode("QmejUXakpXeDLWjfFkjRGJVQv8RqVuFBCikPyeSUmzixWu")
if err != nil {
panic(err)
}
h .Connect(ctx, peer.AddrInfo{ID: id, Addrs: []ma.Multiaddr{addr}})
the LocalAddr for the connection on the server i.e. h.Network().ConnsToPeer(p)[0].LocalMultiaddr() shows up as:
Local addr is /ip4/0.0.0.0/tcp/2001
Shouldn't it be /ip4/127.0.0.1/tcp/2001 since the loopback interface would have accepted the connection here ?
Metadata
Metadata
Assignees
Labels
kind/bugA bug in existing code (including security flaws)A bug in existing code (including security flaws)nat-traversal