|
@@ -29,6 +29,10 @@ func NewRuleAction(ctx context.Context, logger logger.ContextLogger, action opti
|
|
|
case C.RuleActionTypeRoute:
|
|
|
return &RuleActionRoute{
|
|
|
Outbound: action.RouteOptions.Outbound,
|
|
|
+ RuleActionRouteOptions: RuleActionRouteOptions{
|
|
|
+ UDPDisableDomainUnmapping: action.RouteOptions.UDPDisableDomainUnmapping,
|
|
|
+ UDPConnect: action.RouteOptions.UDPConnect,
|
|
|
+ },
|
|
|
}, nil
|
|
|
case C.RuleActionTypeRouteOptions:
|
|
|
return &RuleActionRouteOptions{
|
|
@@ -85,10 +89,12 @@ func NewDNSRuleAction(logger logger.ContextLogger, action option.DNSRuleAction)
|
|
|
return nil
|
|
|
case C.RuleActionTypeRoute:
|
|
|
return &RuleActionDNSRoute{
|
|
|
- Server: action.RouteOptions.Server,
|
|
|
- DisableCache: action.RouteOptions.DisableCache,
|
|
|
- RewriteTTL: action.RouteOptions.RewriteTTL,
|
|
|
- ClientSubnet: netip.Prefix(common.PtrValueOrDefault(action.RouteOptions.ClientSubnet)),
|
|
|
+ Server: action.RouteOptions.Server,
|
|
|
+ RuleActionDNSRouteOptions: RuleActionDNSRouteOptions{
|
|
|
+ DisableCache: action.RouteOptions.DisableCache,
|
|
|
+ RewriteTTL: action.RouteOptions.RewriteTTL,
|
|
|
+ ClientSubnet: netip.Prefix(common.PtrValueOrDefault(action.RouteOptions.ClientSubnet)),
|
|
|
+ },
|
|
|
}
|
|
|
case C.RuleActionTypeRouteOptions:
|
|
|
return &RuleActionDNSRouteOptions{
|
|
@@ -109,6 +115,7 @@ func NewDNSRuleAction(logger logger.ContextLogger, action option.DNSRuleAction)
|
|
|
|
|
|
type RuleActionRoute struct {
|
|
|
Outbound string
|
|
|
+ RuleActionRouteOptions
|
|
|
}
|
|
|
|
|
|
func (r *RuleActionRoute) Type() string {
|
|
@@ -116,7 +123,15 @@ func (r *RuleActionRoute) Type() string {
|
|
|
}
|
|
|
|
|
|
func (r *RuleActionRoute) String() string {
|
|
|
- return F.ToString("route(", r.Outbound, ")")
|
|
|
+ var descriptions []string
|
|
|
+ descriptions = append(descriptions, r.Outbound)
|
|
|
+ if r.UDPDisableDomainUnmapping {
|
|
|
+ descriptions = append(descriptions, "udp-disable-domain-unmapping")
|
|
|
+ }
|
|
|
+ if r.UDPConnect {
|
|
|
+ descriptions = append(descriptions, "udp-connect")
|
|
|
+ }
|
|
|
+ return F.ToString("route(", strings.Join(descriptions, ","), ")")
|
|
|
}
|
|
|
|
|
|
type RuleActionRouteOptions struct {
|
|
@@ -140,10 +155,8 @@ func (r *RuleActionRouteOptions) String() string {
|
|
|
}
|
|
|
|
|
|
type RuleActionDNSRoute struct {
|
|
|
- Server string
|
|
|
- DisableCache bool
|
|
|
- RewriteTTL *uint32
|
|
|
- ClientSubnet netip.Prefix
|
|
|
+ Server string
|
|
|
+ RuleActionDNSRouteOptions
|
|
|
}
|
|
|
|
|
|
func (r *RuleActionDNSRoute) Type() string {
|
|
@@ -151,7 +164,18 @@ func (r *RuleActionDNSRoute) Type() string {
|
|
|
}
|
|
|
|
|
|
func (r *RuleActionDNSRoute) String() string {
|
|
|
- return F.ToString("route(", r.Server, ")")
|
|
|
+ var descriptions []string
|
|
|
+ descriptions = append(descriptions, r.Server)
|
|
|
+ if r.DisableCache {
|
|
|
+ descriptions = append(descriptions, "disable-cache")
|
|
|
+ }
|
|
|
+ if r.RewriteTTL != nil {
|
|
|
+ descriptions = append(descriptions, F.ToString("rewrite-ttl=", *r.RewriteTTL))
|
|
|
+ }
|
|
|
+ if r.ClientSubnet.IsValid() {
|
|
|
+ descriptions = append(descriptions, F.ToString("client-subnet=", r.ClientSubnet))
|
|
|
+ }
|
|
|
+ return F.ToString("route(", strings.Join(descriptions, ","), ")")
|
|
|
}
|
|
|
|
|
|
type RuleActionDNSRouteOptions struct {
|
|
@@ -170,10 +194,10 @@ func (r *RuleActionDNSRouteOptions) String() string {
|
|
|
descriptions = append(descriptions, "disable-cache")
|
|
|
}
|
|
|
if r.RewriteTTL != nil {
|
|
|
- descriptions = append(descriptions, F.ToString("rewrite-ttl(", *r.RewriteTTL, ")"))
|
|
|
+ descriptions = append(descriptions, F.ToString("rewrite-ttl=", *r.RewriteTTL))
|
|
|
}
|
|
|
if r.ClientSubnet.IsValid() {
|
|
|
- descriptions = append(descriptions, F.ToString("client-subnet(", r.ClientSubnet, ")"))
|
|
|
+ descriptions = append(descriptions, F.ToString("client-subnet=", r.ClientSubnet))
|
|
|
}
|
|
|
return F.ToString("route-options(", strings.Join(descriptions, ","), ")")
|
|
|
}
|