libp2p / go-libp2p-daemon

a libp2p-backed daemon wrapping the functionalities of go-libp2p for use in other languages
Other
90 stars 34 forks source link

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

Open lnykww opened 5 years ago

lnykww commented 5 years ago

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 commented 5 years ago

ping @vyzo

vyzo commented 5 years ago

@bigs maintains the client.

bigs commented 5 years ago

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

lnykww commented 5 years ago

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)
     ...
 }