mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
dns, ipset, rule: change dns AnswerHandler to use netip instead of string
This commit is contained in:
1 parent
fdb32370e9
commit
7f925fb711
8 files changed
+53
-48
No files matched your search
+4
-5
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
// AnswerHandler function handles the dns TypeA or TypeAAAA answer.
|
||||
type AnswerHandler func(domain, ip string) error
|
||||
type AnswerHandler func(domain string, ip netip.Addr) error
|
||||
|
||||
// Config for dns.
|
||||
type Config struct {
|
||||
@@ -138,12 +138,11 @@ func (c *Client) extractAnswer(resp *Message) ([]string, int) {
|
||||
ttl := c.config.MinTTL
|
||||
for _, answer := range resp.Answers {
|
||||
if answer.TYPE == QTypeA || answer.TYPE == QTypeAAAA {
|
||||
if answer.IP.IsValid() {
|
||||
ip := answer.IP.String()
|
||||
if answer.IP.IsValid() && !answer.IP.IsUnspecified() {
|
||||
for _, h := range c.handlers {
|
||||
h(resp.Question.QNAME, ip)
|
||||
h(resp.Question.QNAME, answer.IP)
|
||||
}
|
||||
ips = append(ips, ip)
|
||||
ips = append(ips, answer.IP.String())
|
||||
}
|
||||
if answer.TTL != 0 {
|
||||
ttl = int(answer.TTL)
|
||||
|
||||
Reference in new issue
Block a user