Chore: Clarify the definition of StreamConn and DialContext

This commit is contained in:
Dreamacro
2021-03-22 23:26:20 +08:00
parent 1355196b7c
commit 807d53c1e7
9 changed files with 79 additions and 46 deletions

View File

@ -69,8 +69,21 @@ type PacketConn interface {
type ProxyAdapter interface {
Name() string
Type() AdapterType
// StreamConn wraps a protocol around net.Conn with Metadata.
//
// Examples:
// conn, _ := net.Dial("tcp", "host:port")
// conn, _ = adapter.StreamConn(conn, metadata)
//
// It returns a C.Conn with protocol which start with
// a new session (if any)
StreamConn(c net.Conn, metadata *Metadata) (net.Conn, error)
// DialContext return a C.Conn with protocol which
// contains multiplexing-related reuse logic (if any)
DialContext(ctx context.Context, metadata *Metadata) (Conn, error)
DialUDP(metadata *Metadata) (PacketConn, error)
SupportUDP() bool
MarshalJSON() ([]byte, error)