Chore: contexify ProxyAdapter ListenPacket
This commit is contained in:
@ -29,6 +29,7 @@ const (
|
||||
|
||||
const (
|
||||
DefaultTCPTimeout = 5 * time.Second
|
||||
DefaultUDPTimeout = DefaultTCPTimeout
|
||||
)
|
||||
|
||||
type Connection interface {
|
||||
@ -73,11 +74,14 @@ type PacketConn interface {
|
||||
type ProxyAdapter interface {
|
||||
Name() string
|
||||
Type() AdapterType
|
||||
Addr() string
|
||||
SupportUDP() bool
|
||||
MarshalJSON() ([]byte, error)
|
||||
|
||||
// StreamConn wraps a protocol around net.Conn with Metadata.
|
||||
//
|
||||
// Examples:
|
||||
// conn, _ := net.Dial("tcp", "host:port")
|
||||
// conn, _ := net.DialContext(context.Background(), "tcp", "host:port")
|
||||
// conn, _ = adapter.StreamConn(conn, metadata)
|
||||
//
|
||||
// It returns a C.Conn with protocol which start with
|
||||
@ -88,10 +92,8 @@ type ProxyAdapter interface {
|
||||
// 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)
|
||||
Addr() string
|
||||
ListenPacketContext(ctx context.Context, metadata *Metadata) (PacketConn, error)
|
||||
|
||||
// Unwrap extracts the proxy from a proxy-group. It returns nil when nothing to extract.
|
||||
Unwrap(metadata *Metadata) Proxy
|
||||
}
|
||||
@ -105,9 +107,14 @@ type Proxy interface {
|
||||
ProxyAdapter
|
||||
Alive() bool
|
||||
DelayHistory() []DelayHistory
|
||||
Dial(metadata *Metadata) (Conn, error)
|
||||
LastDelay() uint16
|
||||
URLTest(ctx context.Context, url string) (uint16, error)
|
||||
|
||||
// Deprecated: use DialContext instead.
|
||||
Dial(metadata *Metadata) (Conn, error)
|
||||
|
||||
// Deprecated: use DialPacketConn instead.
|
||||
DialUDP(metadata *Metadata) (PacketConn, error)
|
||||
}
|
||||
|
||||
// AdapterType is enum of adapter type
|
||||
|
@ -67,7 +67,7 @@ type ProxyProvider interface {
|
||||
Provider
|
||||
Proxies() []constant.Proxy
|
||||
// ProxiesWithTouch is used to inform the provider that the proxy is actually being used while getting the list of proxies.
|
||||
// Commonly used in Dial and DialUDP
|
||||
// Commonly used in DialContext and DialPacketConn
|
||||
ProxiesWithTouch() []constant.Proxy
|
||||
HealthCheck()
|
||||
}
|
||||
|
Reference in New Issue
Block a user