Add resolver for inbound

This commit is contained in:
世界
2022-07-07 23:36:32 +08:00
parent f65f3f1ba0
commit b91ed698cd
22 changed files with 261 additions and 173 deletions

View File

@@ -2,8 +2,11 @@ package adapter
import (
"context"
"net/netip"
M "github.com/sagernet/sing/common/metadata"
C "github.com/sagernet/sing-box/constant"
)
type Inbound interface {
@@ -23,8 +26,10 @@ type InboundContext struct {
// cache
DomainStrategy C.DomainStrategy
SniffEnabled bool
SniffOverrideDestination bool
DestinationAddresses []netip.Addr
SourceGeoIPCode string
GeoIPCode string
@@ -50,5 +55,5 @@ func AppendContext(ctx context.Context) (context.Context, *InboundContext) {
return ctx, metadata
}
metadata = new(InboundContext)
return WithContext(ctx, metadata), nil
return WithContext(ctx, metadata), metadata
}

View File

@@ -4,7 +4,6 @@ import (
"context"
"net"
M "github.com/sagernet/sing/common/metadata"
N "github.com/sagernet/sing/common/network"
)
@@ -13,6 +12,6 @@ type Outbound interface {
Tag() string
Network() []string
N.Dialer
NewConnection(ctx context.Context, conn net.Conn, destination M.Socksaddr) error
NewPacketConnection(ctx context.Context, conn N.PacketConn, destination M.Socksaddr) error
NewConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
}