implement match_only
This commit is contained in:
@@ -81,12 +81,13 @@ type InboundContext struct {
|
||||
FallbackNetworkType []C.InterfaceType
|
||||
FallbackDelay time.Duration
|
||||
|
||||
DestinationAddresses []netip.Addr
|
||||
SourceGeoIPCode string
|
||||
GeoIPCode string
|
||||
ProcessInfo *ConnectionOwner
|
||||
QueryType uint16
|
||||
FakeIP bool
|
||||
DestinationAddresses []netip.Addr
|
||||
IgnoreDestinationAddresses bool
|
||||
SourceGeoIPCode string
|
||||
GeoIPCode string
|
||||
ProcessInfo *ConnectionOwner
|
||||
QueryType uint16
|
||||
FakeIP bool
|
||||
|
||||
// rule cache
|
||||
|
||||
|
||||
@@ -312,6 +312,7 @@ type RouteActionResolve struct {
|
||||
DisableCache bool `json:"disable_cache,omitempty"`
|
||||
RewriteTTL *uint32 `json:"rewrite_ttl,omitempty"`
|
||||
ClientSubnet *badoption.Prefixable `json:"client_subnet,omitempty"`
|
||||
MatchOnly bool `json:"match_only,omitempty"`
|
||||
}
|
||||
|
||||
type DNSRouteActionPredefined struct {
|
||||
|
||||
@@ -71,7 +71,7 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
|
||||
|
||||
// Create a go-mysql server with our TLS config
|
||||
inbound.mysqlServer = server.NewServer(
|
||||
"8.0.12",
|
||||
"9.7.0",
|
||||
gmysql.DEFAULT_COLLATION_ID,
|
||||
gmysql.AUTH_NATIVE_PASSWORD,
|
||||
nil,
|
||||
|
||||
@@ -96,7 +96,7 @@ func (m *ConnectionManager) NewConnection(ctx context.Context, this N.Dialer, co
|
||||
remoteConn net.Conn
|
||||
err error
|
||||
)
|
||||
if len(metadata.DestinationAddresses) > 0 || metadata.Destination.IsIP() {
|
||||
if !metadata.IgnoreDestinationAddresses && (len(metadata.DestinationAddresses) > 0 || metadata.Destination.IsIP()) {
|
||||
remoteConn, err = dialer.DialSerialNetwork(ctx, this, N.NetworkTCP, metadata.Destination, metadata.DestinationAddresses, metadata.NetworkStrategy, metadata.NetworkType, metadata.FallbackNetworkType, metadata.FallbackDelay)
|
||||
} else {
|
||||
remoteConn, err = this.DialContext(ctx, N.NetworkTCP, metadata.Destination)
|
||||
|
||||
@@ -842,6 +842,7 @@ func (r *Router) actionResolve(ctx context.Context, metadata *adapter.InboundCon
|
||||
return err
|
||||
}
|
||||
metadata.DestinationAddresses = addresses
|
||||
metadata.IgnoreDestinationAddresses = action.MatchOnly
|
||||
r.logger.DebugContext(ctx, "resolved [", strings.Join(F.MapToString(metadata.DestinationAddresses), " "), "]")
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -111,6 +111,7 @@ func NewRuleAction(ctx context.Context, logger logger.ContextLogger, action opti
|
||||
Strategy: C.DomainStrategy(action.ResolveOptions.Strategy),
|
||||
DisableCache: action.ResolveOptions.DisableCache,
|
||||
RewriteTTL: action.ResolveOptions.RewriteTTL,
|
||||
MatchOnly: action.ResolveOptions.MatchOnly,
|
||||
ClientSubnet: action.ResolveOptions.ClientSubnet.Build(netip.Prefix{}),
|
||||
}, nil
|
||||
default:
|
||||
@@ -474,6 +475,7 @@ type RuleActionResolve struct {
|
||||
Server string
|
||||
Strategy C.DomainStrategy
|
||||
DisableCache bool
|
||||
MatchOnly bool
|
||||
RewriteTTL *uint32
|
||||
ClientSubnet netip.Prefix
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user