chore: proxyDialer can limited support old dial function

This commit is contained in:
wwqgtxx
2023-04-11 12:51:24 +08:00
parent ab3fce29ab
commit 92cc268209
15 changed files with 78 additions and 42 deletions

View File

@ -2,6 +2,7 @@ package constant
import (
"context"
"errors"
"fmt"
"net"
"net/netip"
@ -44,6 +45,8 @@ const (
DefaultTLSTimeout = DefaultTCPTimeout
)
var ErrNotSupport = errors.New("no support")
type Connection interface {
Chains() Chain
AppendToChains(adapter ProxyAdapter)
@ -117,7 +120,7 @@ type ProxyAdapter interface {
// SupportUOT return UDP over TCP support
SupportUOT() bool
SupportWithDialer() bool
SupportWithDialer() NetWork
DialContextWithDialer(ctx context.Context, dialer Dialer, metadata *Metadata) (Conn, error)
ListenPacketWithDialer(ctx context.Context, dialer Dialer, metadata *Metadata) (PacketConn, error)

View File

@ -15,7 +15,10 @@ const (
TCP NetWork = iota
UDP
ALLNet
InvalidNet = 0xff
)
const (
HTTP Type = iota
HTTPS
SOCKS4
@ -33,12 +36,16 @@ const (
type NetWork int
func (n NetWork) String() string {
if n == TCP {
switch n {
case TCP:
return "tcp"
} else if n == UDP {
case UDP:
return "udp"
case ALLNet:
return "all"
default:
return "invalid"
}
return "all"
}
func (n NetWork) MarshalJSON() ([]byte, error) {