Add multiplexer

This commit is contained in:
世界
2022-07-30 00:29:22 +08:00
parent 8e8b1b974e
commit 10531c9f9a
47 changed files with 1244 additions and 174 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/control"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
"github.com/database64128/tfo-go"
)
@@ -124,7 +125,7 @@ func (d *DefaultDialer) DialContext(ctx context.Context, network string, address
}
func (d *DefaultDialer) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
return d.ListenConfig.ListenPacket(ctx, C.NetworkUDP, "")
return d.ListenConfig.ListenPacket(ctx, N.NetworkUDP, "")
}
func (d *DefaultDialer) Upstream() any {

View File

@@ -5,7 +5,6 @@ import (
"net"
"github.com/sagernet/sing-box/adapter"
C "github.com/sagernet/sing-box/constant"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
)
@@ -23,7 +22,7 @@ func (d *RouterDialer) DialContext(ctx context.Context, network string, destinat
}
func (d *RouterDialer) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
return d.router.DefaultOutbound(C.NetworkUDP).ListenPacket(ctx, destination)
return d.router.DefaultOutbound(N.NetworkUDP).ListenPacket(ctx, destination)
}
func (d *RouterDialer) Upstream() any {

View File

@@ -112,7 +112,7 @@ func NewTLS(dialer N.Dialer, serverAddress string, options option.OutboundTLSOpt
}
func (d *TLSDialer) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
if network != C.NetworkTCP {
if network != N.NetworkTCP {
return nil, os.ErrInvalid
}
conn, err := d.dialer.DialContext(ctx, network, destination)