Add "nonIPQuery" to DNS outbound ("drop" by default)

And fixed a memory leak
And regenerated *.pb.go
This commit is contained in:
RPRX 2023-06-18 17:20:16 +00:00 committed by yuhan6665
parent 62e881b01a
commit 667279af57
5 changed files with 38 additions and 14 deletions

View file

@ -44,6 +44,7 @@ type Handler struct {
ownLinkVerifier ownLinkVerifier
server net.Destination
timeout time.Duration
nonIPQuery string
}
func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager policy.Manager) error {
@ -57,6 +58,7 @@ func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager polic
if config.Server != nil {
h.server = config.Server.AsDestination()
}
h.nonIPQuery = config.Non_IPQuery
return nil
}
@ -175,6 +177,9 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet.
isIPQuery, domain, id, qType := parseIPQuery(b.Bytes())
if isIPQuery {
go h.handleIPQuery(id, qType, domain, writer)
}
if isIPQuery || h.nonIPQuery == "drop" {
b.Release()
continue
}
}