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