From 2bfc9fcb12e098d0077d949fbdc678505abf69de Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Tue, 22 Aug 2023 18:03:32 +0300 Subject: [PATCH] Pull request 1971: fix hosts windows Merge in DNS/adguard-home from fix-hosts-windows to master Squashed commit of the following: commit 8e080ade8980f73006eb33de930749b91d203915 Author: Eugene Burkov Date: Tue Aug 22 17:49:23 2023 +0300 aghnet: fix src path --- internal/aghnet/hostscontainer_test.go | 47 ++++++++++++++------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/internal/aghnet/hostscontainer_test.go b/internal/aghnet/hostscontainer_test.go index 6079ab72..ac30777f 100644 --- a/internal/aghnet/hostscontainer_test.go +++ b/internal/aghnet/hostscontainer_test.go @@ -3,6 +3,7 @@ package aghnet_test import ( "net/netip" "path" + "path/filepath" "sync/atomic" "testing" "testing/fstest" @@ -42,109 +43,111 @@ var ( addr13 = netip.MustParseAddr("::13") addr31 = netip.MustParseAddr("::31") + hostsSrc = "./" + filepath.Join("./testdata", "etc_hosts") + testHosts = map[netip.Addr][]*hostsfile.Record{ addr1000: {{ Addr: addr1000, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"hello", "hello.world"}, }, { Addr: addr1000, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"hello.world.again"}, }, { Addr: addr1000, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"hello.world"}, }}, addr1001: {{ Addr: addr1001, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"simplehost"}, }, { Addr: addr1001, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"simplehost"}, }}, addr1002: {{ Addr: addr1002, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"a.whole", "lot.of", "aliases", "for.testing"}, }}, addr1003: {{ Addr: addr1003, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"*"}, }}, addr1004: {{ Addr: addr1004, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"*.com"}, }}, addr1357: {{ Addr: addr1357, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"domain4", "domain4.alias"}, }}, addr7531: {{ Addr: addr7531, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"domain4.alias", "domain4"}, }}, addr4216: {{ Addr: addr4216, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"domain", "domain.alias"}, }}, addr0: {{ Addr: addr0, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"hello", "hello.world"}, }, { Addr: addr0, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"hello.world.again"}, }, { Addr: addr0, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"hello.world"}, }}, addr1: {{ Addr: addr1, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"simplehost"}, }, { Addr: addr1, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"simplehost"}, }}, addr2: {{ Addr: addr2, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"a.whole", "lot.of", "aliases", "for.testing"}, }}, addr3: {{ Addr: addr3, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"*"}, }}, addr4: {{ Addr: addr4, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"*.com"}, }}, addr42: {{ Addr: addr42, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"domain.alias", "domain"}, }}, addr13: {{ Addr: addr13, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"domain6", "domain6.alias"}, }}, addr31: {{ Addr: addr31, - Source: "./testdata/etc_hosts", + Source: hostsSrc, Names: []string{"domain6.alias", "domain6"}, }}, }