hashicorp / yamux

Golang connection multiplexing library
Mozilla Public License 2.0
2.19k stars 232 forks source link

Is Session.Accept Result Really Compatible With net.Conn? #114

Closed kudla closed 1 year ago

kudla commented 1 year ago

Hi A Session instance returns Stream one from Accept call as a net.Conn here

Yet net.Conn among the rest defines

    // LocalAddr returns the local network address, if known.
    LocalAddr() Addr

    // RemoteAddr returns the remote network address, if known.
    RemoteAddr() Addr

which Stream seems like doesn't implement.

So I'm not really sure how this is compiled at all (while it indeed is)?

But my main concern here how can the accepted connection be passed to other consumers which are really supposed to have a pure net.Conn?

Should I wrap with some stubs the connections myself? Or are there any intended solution for that?

Thx.

hadi77ir commented 1 year ago

Hi,

Stream implements net.Conn (and its LocalAddr and RemoteAddr methods, of course). There is no way for a type to partially implement an interface. Those methods are implemented in addr.go.

kudla commented 1 year ago

Ah, I see. Thank you 👍