mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-29 18:38:56 +03:00
7931e50673
Close #1191
Squashed commit of the following:
commit ba14b53f9e3d98ad8127aa3af1def0da4269e8c4
Merge: 362f4c44 6b614295
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Sep 2 14:03:19 2020 +0300
Merge remote-tracking branch 'origin/master' into 1191-ipset
commit 362f4c44915cb8946db2e80f9a3f5afd74fe5de1
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Sep 2 12:50:56 2020 +0300
minor
commit 28e12459166fe3d13fb0dbe59ac11b7d86adb9b4
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Sep 2 12:43:25 2020 +0300
minor
commit bdbd7324501f6111bea1e91eda7d730c7ea57b11
Author: Simon Zolin <s.zolin@adguard.com>
Date: Tue Sep 1 18:40:04 2020 +0300
move code, ipset-v6
commit 77f4d943e74b70b5bc5aea279875ab1e2fab2192
Author: Simon Zolin <s.zolin@adguard.com>
Date: Tue Sep 1 15:53:27 2020 +0300
comment
commit 16401325bbefeba08e447257b12a8424b78c9475
Author: Simon Zolin <s.zolin@adguard.com>
Date: Mon Aug 31 17:43:23 2020 +0300
minor
commit c8410e9a519b87911bc50f504e8b4aaf8dce6e02
Author: Simon Zolin <s.zolin@adguard.com>
Date: Mon Aug 31 15:30:52 2020 +0300
+ DNS: add "ipset" configuration setting
41 lines
1,020 B
Go
41 lines
1,020 B
Go
package dnsforward
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/AdguardTeam/dnsproxy/proxy"
|
|
"github.com/miekg/dns"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestIPSET(t *testing.T) {
|
|
s := Server{}
|
|
s.conf.IPSETList = append(s.conf.IPSETList, "HOST.com/name")
|
|
s.conf.IPSETList = append(s.conf.IPSETList, "host2.com,host3.com/name23")
|
|
s.conf.IPSETList = append(s.conf.IPSETList, "host4.com/name4,name41")
|
|
c := ipsetCtx{}
|
|
c.init(s.conf.IPSETList)
|
|
|
|
assert.Equal(t, "name", c.ipsetList["host.com"][0])
|
|
assert.Equal(t, "name23", c.ipsetList["host2.com"][0])
|
|
assert.Equal(t, "name23", c.ipsetList["host3.com"][0])
|
|
assert.Equal(t, "name4", c.ipsetList["host4.com"][0])
|
|
assert.Equal(t, "name41", c.ipsetList["host4.com"][1])
|
|
|
|
_, ok := c.ipsetList["host0.com"]
|
|
assert.False(t, ok)
|
|
|
|
ctx := &dnsContext{
|
|
srv: &s,
|
|
}
|
|
ctx.proxyCtx = &proxy.DNSContext{}
|
|
ctx.proxyCtx.Req = &dns.Msg{
|
|
Question: []dns.Question{
|
|
{
|
|
Name: "host.com.",
|
|
Qtype: dns.TypeA,
|
|
},
|
|
},
|
|
}
|
|
assert.Equal(t, resultDone, c.process(ctx))
|
|
}
|