dnsforward/ipset: rewrite ipset tests to check dnsmasq behavior
In the process, found a segfault from assuming the Res field of proxyCtx is non-nil. I added a defensive check as I'm not sure if it's guaranteed to be non-nil in regular execution in this context.
This commit is contained in:
@@ -122,15 +122,17 @@ func (c *ipsetCtx) processMembers(ctx *dnsContext, addMember func(string, string
|
||||
|
||||
log.Debug("IPSET: found ipsets %v for host %s", ipsetNames, host)
|
||||
|
||||
for _, it := range ctx.proxyCtx.Res.Answer {
|
||||
ip := c.getIP(it)
|
||||
if ip == nil {
|
||||
continue
|
||||
}
|
||||
if ctx.proxyCtx.Res != nil {
|
||||
for _, it := range ctx.proxyCtx.Res.Answer {
|
||||
ip := c.getIP(it)
|
||||
if ip == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
ipStr := ip.String()
|
||||
for _, name := range ipsetNames {
|
||||
addMember(host, name, ipStr)
|
||||
ipStr := ip.String()
|
||||
for _, name := range ipsetNames {
|
||||
addMember(host, name, ipStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user