go-libp2p-daemon icon indicating copy to clipboard operation
go-libp2p-daemon copied to clipboard

go client bug: There are no all transport protocols in the process space

Open lnykww opened this issue 5 years ago • 4 comments

For example with CIRCUIT transport , the convertStreamInfo return error("no protocol with code 290"). Now I fix it by import circuit packge in client process sapce. how about if daemon process return the string of addr and protocol to client?

lnykww avatar Mar 07 '19 07:03 lnykww

ping @vyzo

lnykww avatar Mar 09 '19 04:03 lnykww

@bigs maintains the client.

vyzo avatar Mar 10 '19 09:03 vyzo

hmm can you give me steps to reproduce this or propose a patch? definitely down to fix this, just not fully sure i understand

bigs avatar Mar 10 '19 16:03 bigs

The protocol needs to be added to the multiaddr's protocol list by calling AddProtocol. for the circuit protocol, it was added during the init phase:

 var Protocol = ma.Protocol{
     Code:  P_CIRCUIT,
     Size:  0,
     Name:  "p2p-circuit",
     VCode: ma.CodeToVarint(P_CIRCUIT),
 }
func init() {
     ma.AddProtocol(Protocol)
 }

But in go client, there is no need to import the circuit package, so the circuit protocol would not to be added to the protocol list.

so when client call convertStreamInfo to parse multiaddr, there was no circuit protocol in the list:

func convertStreamInfo(info *pb.StreamInfo) (*StreamInfo, error) {
      ...
     addr, err := ma.NewMultiaddrBytes(info.Addr)
     ...
 }

lnykww avatar Mar 11 '19 02:03 lnykww