docstring_tokens
stringlengths 0
76.5k
| code_tokens
stringlengths 75
1.81M
| label_window
sequencelengths 4
2.12k
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|---|
// Filtering. | <mask> d.checkMatchEmpty(t, "yandex.ru")
<mask> d.parentalServer = defaultParentalServer
<mask> }
<mask>
<mask> // FILTERING
<mask>
<mask> const nl = "\n"
<mask>
<mask> const (
<mask> blockingRules = `||example.org^` + nl
<mask> allowlistRules = `||example.org^` + nl + `@@||test.example.org` + nl
<mask> importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl
<mask> regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl
<mask> maskRules = `test*.example.org^` + nl + `exam*.com` + nl
<mask> dnstypeRules = `||example.org^$dnstype=AAAA` + nl + `@@||test.example.org^` + nl
<mask> )
<mask>
<mask> var tests = []struct {
<mask> testname string
<mask> rules string
<mask> hostname string
<mask> isFiltered bool
<mask> reason Reason
<mask> dnsType uint16
<mask> }{
<mask> {"sanity", "||doubleclick.net^", "www.doubleclick.net", true, FilteredBlockList, dns.TypeA},
<mask> {"sanity", "||doubleclick.net^", "nodoubleclick.net", false, NotFilteredNotFound, dns.TypeA},
<mask> {"sanity", "||doubleclick.net^", "doubleclick.net.ru", false, NotFilteredNotFound, dns.TypeA},
<mask> {"sanity", "||doubleclick.net^", "wmconvirus.narod.ru", false, NotFilteredNotFound, dns.TypeA},
<mask>
<mask> {"blocking", blockingRules, "example.org", true, FilteredBlockList, dns.TypeA},
<mask> {"blocking", blockingRules, "test.example.org", true, FilteredBlockList, dns.TypeA},
<mask> {"blocking", blockingRules, "test.test.example.org", true, FilteredBlockList, dns.TypeA},
<mask> {"blocking", blockingRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA},
<mask> {"blocking", blockingRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA},
<mask>
<mask> {"allowlist", allowlistRules, "example.org", true, FilteredBlockList, dns.TypeA},
<mask> {"allowlist", allowlistRules, "test.example.org", false, NotFilteredAllowList, dns.TypeA},
<mask> {"allowlist", allowlistRules, "test.test.example.org", false, NotFilteredAllowList, dns.TypeA},
<mask> {"allowlist", allowlistRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA},
<mask> {"allowlist", allowlistRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA},
<mask>
<mask> {"important", importantRules, "example.org", false, NotFilteredAllowList, dns.TypeA},
<mask> {"important", importantRules, "test.example.org", true, FilteredBlockList, dns.TypeA},
<mask> {"important", importantRules, "test.test.example.org", true, FilteredBlockList, dns.TypeA},
<mask> {"important", importantRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA},
<mask> {"important", importantRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA},
<mask>
<mask> {"regex", regexRules, "example.org", true, FilteredBlockList, dns.TypeA},
<mask> {"regex", regexRules, "test.example.org", false, NotFilteredAllowList, dns.TypeA},
<mask> {"regex", regexRules, "test.test.example.org", false, NotFilteredAllowList, dns.TypeA},
<mask> {"regex", regexRules, "testexample.org", true, FilteredBlockList, dns.TypeA},
<mask> {"regex", regexRules, "onemoreexample.org", true, FilteredBlockList, dns.TypeA},
<mask>
<mask> {"mask", maskRules, "test.example.org", true, FilteredBlockList, dns.TypeA},
<mask> {"mask", maskRules, "test2.example.org", true, FilteredBlockList, dns.TypeA},
<mask> {"mask", maskRules, "example.com", true, FilteredBlockList, dns.TypeA},
<mask> {"mask", maskRules, "exampleeee.com", true, FilteredBlockList, dns.TypeA},
<mask> {"mask", maskRules, "onemoreexamsite.com", true, FilteredBlockList, dns.TypeA},
<mask> {"mask", maskRules, "example.org", false, NotFilteredNotFound, dns.TypeA},
<mask> {"mask", maskRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA},
<mask> {"mask", maskRules, "example.co.uk", false, NotFilteredNotFound, dns.TypeA},
<mask>
<mask> {"dnstype", dnstypeRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA},
<mask> {"dnstype", dnstypeRules, "example.org", false, NotFilteredNotFound, dns.TypeA},
<mask> {"dnstype", dnstypeRules, "example.org", true, FilteredBlockList, dns.TypeAAAA},
<mask> {"dnstype", dnstypeRules, "test.example.org", false, NotFilteredAllowList, dns.TypeA},
<mask> {"dnstype", dnstypeRules, "test.example.org", false, NotFilteredAllowList, dns.TypeAAAA},
<mask> }
<mask>
<mask> func TestMatching(t *testing.T) {
<mask> for _, test := range tests {
<mask> t.Run(fmt.Sprintf("%s-%s", test.testname, test.hostname), func(t *testing.T) {
<mask> filters := []Filter{{
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove for _, test := range tests {
t.Run(fmt.Sprintf("%s-%s", test.testname, test.hostname), func(t *testing.T) {
filters := []Filter{{
ID: 0, Data: []byte(test.rules),
}}
d := NewForTest(nil, filters)
defer d.Close()
res, err := d.CheckHost(test.hostname, test.dnsType, &setts)
if err != nil {
t.Errorf("Error while matching host %s: %s", test.hostname, err)
}
if res.IsFiltered != test.isFiltered {
t.Errorf("Hostname %s has wrong result (%v must be %v)", test.hostname, res.IsFiltered, test.isFiltered)
}
if res.Reason != test.reason {
t.Errorf("Hostname %s has wrong reason (%v must be %v)", test.hostname, res.Reason.String(), test.reason.String())
}
</s> add const nl = "\n"
const (
blockingRules = `||example.org^` + nl
allowlistRules = `||example.org^` + nl + `@@||test.example.org` + nl
importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl
regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl
maskRules = `test*.example.org^` + nl + `exam*.com` + nl
dnstypeRules = `||example.org^$dnstype=AAAA` + nl + `@@||test.example.org^` + nl
)
testCases := []struct {
name string
rules string
host string
wantIsFiltered bool
wantReason Reason
wantDNSType uint16
}{{
name: "sanity",
rules: "||doubleclick.net^",
host: "www.doubleclick.net",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "sanity",
rules: "||doubleclick.net^",
host: "nodoubleclick.net",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "sanity",
rules: "||doubleclick.net^",
host: "doubleclick.net.ru",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "sanity",
rules: "||doubleclick.net^",
host: "wmconvirus.narod.ru",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "test.test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "test.test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "test.test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "test.test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "testexample.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "onemoreexample.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "test2.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "example.com",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "exampleeee.com",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "onemoreexamsite.com",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "example.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "example.co.uk",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "example.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeAAAA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeAAAA,
}}
for _, tc := range testCases {
t.Run(fmt.Sprintf("%s-%s", tc.name, tc.host), func(t *testing.T) {
filters := []Filter{{ID: 0, Data: []byte(tc.rules)}}
d := newForTest(nil, filters)
t.Cleanup(d.Close)
res, err := d.CheckHost(tc.host, tc.wantDNSType, &setts)
assert.Nilf(t, err, "Error while matching host %s: %s", tc.host, err)
assert.Equalf(t, tc.wantIsFiltered, res.IsFiltered, "Hostname %s has wrong result (%v must be %v)", tc.host, res.IsFiltered, tc.wantIsFiltered)
assert.Equalf(t, tc.wantReason, res.Reason, "Hostname %s has wrong reason (%v must be %v)", tc.host, res.Reason, tc.wantReason) </s> remove var r Result
filters := []Filter{{
ID: 0, Data: []byte("||example.org^\n"),
</s> add d := newForTest(
&Config{
ParentalEnabled: true,
SafeBrowsingEnabled: false,
},
[]Filter{{
ID: 0, Data: []byte("||example.org^\n"),
}},
)
t.Cleanup(d.Close)
d.parentalUpstream = &testSbUpstream{
hostname: "pornhub.com",
block: true,
}
d.safeBrowsingUpstream = &testSbUpstream{
hostname: "wmconvirus.narod.ru",
block: true,
}
type testCase struct {
name string
host string
before bool
wantReason Reason
}
testCases := []testCase{{
name: "filters",
host: "example.org",
before: true,
wantReason: FilteredBlockList,
}, {
name: "parental",
host: "pornhub.com",
before: true,
wantReason: FilteredParental,
}, {
name: "safebrowsing",
host: "wmconvirus.narod.ru",
before: false,
wantReason: FilteredSafeBrowsing,
}, {
name: "additional_rules",
host: "facebook.com",
before: false,
wantReason: FilteredBlockedService, </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
const nl = "\n"
const (
blockingRules = `||example.org^` + nl
allowlistRules = `||example.org^` + nl + `@@||test.example.org` + nl
importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl
regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl
maskRules = `test*.example.org^` + nl + `exam*.com` + nl
dnstypeRules = `||example.org^$dnstype=AAAA` + nl + `@@||test.example.org^` + nl
)
testCases := []struct {
name string
rules string
host string
wantIsFiltered bool
wantReason Reason
wantDNSType uint16
}{{
name: "sanity",
rules: "||doubleclick.net^",
host: "www.doubleclick.net",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "sanity",
rules: "||doubleclick.net^",
host: "nodoubleclick.net",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "sanity",
rules: "||doubleclick.net^",
host: "doubleclick.net.ru",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "sanity",
rules: "||doubleclick.net^",
host: "wmconvirus.narod.ru",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "test.test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "test.test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "test.test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "test.test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "testexample.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "onemoreexample.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "test2.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "example.com",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "exampleeee.com",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "onemoreexamsite.com",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "example.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "example.co.uk",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "example.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeAAAA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeAAAA,
}}
for _, tc := range testCases {
t.Run(fmt.Sprintf("%s-%s", tc.name, tc.host), func(t *testing.T) {
filters := []Filter{{ID: 0, Data: []byte(tc.rules)}}
d := newForTest(nil, filters)
t.Cleanup(d.Close)
res, err := d.CheckHost(tc.host, tc.wantDNSType, &setts)
assert.Nilf(t, err, "Error while matching host %s: %s", tc.host, err)
assert.Equalf(t, tc.wantIsFiltered, res.IsFiltered, "Hostname %s has wrong result (%v must be %v)", tc.host, res.IsFiltered, tc.wantIsFiltered)
assert.Equalf(t, tc.wantReason, res.Reason, "Hostname %s has wrong reason (%v must be %v)", tc.host, res.Reason, tc.wantReason) | <mask> {"dnstype", dnstypeRules, "test.example.org", false, NotFilteredAllowList, dns.TypeAAAA},
<mask> }
<mask>
<mask> func TestMatching(t *testing.T) {
<mask> for _, test := range tests {
<mask> t.Run(fmt.Sprintf("%s-%s", test.testname, test.hostname), func(t *testing.T) {
<mask> filters := []Filter{{
<mask> ID: 0, Data: []byte(test.rules),
<mask> }}
<mask> d := NewForTest(nil, filters)
<mask> defer d.Close()
<mask>
<mask> res, err := d.CheckHost(test.hostname, test.dnsType, &setts)
<mask> if err != nil {
<mask> t.Errorf("Error while matching host %s: %s", test.hostname, err)
<mask> }
<mask> if res.IsFiltered != test.isFiltered {
<mask> t.Errorf("Hostname %s has wrong result (%v must be %v)", test.hostname, res.IsFiltered, test.isFiltered)
<mask> }
<mask> if res.Reason != test.reason {
<mask> t.Errorf("Hostname %s has wrong reason (%v must be %v)", test.hostname, res.Reason.String(), test.reason.String())
<mask> }
<mask> })
<mask> }
<mask> }
<mask>
<mask> func TestWhitelist(t *testing.T) {
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if res.IsFiltered {
t.Errorf("Expected hostname %s to not match", hostname)
}
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Falsef(t, res.IsFiltered, "Expected hostname %s to not match", hostname) </s> remove hostname := "wmconvirus.narod.ru"
res, err := d.CheckHost(hostname, dns.TypeA, &setts)
if err != nil {
b.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
b.Errorf("Expected hostname %s to match", hostname)
}
</s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove hostname := "wmconvirus.narod.ru"
res, err := d.CheckHost(hostname, dns.TypeA, &setts)
if err != nil {
b.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
b.Errorf("Expected hostname %s to match", hostname)
}
</s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
t.Errorf("Expected hostname %s to match", hostname)
}
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
t.Errorf("Expected hostname %s to match", hostname)
}
if len(res.Rules) == 0 {
t.Errorf("Expected result to have rules")
return
}
r := res.Rules[0]
if r.IP == nil || r.IP.String() != ip {
t.Errorf("Expected ip %s to match, actual: %v", ip, r.IP)
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname)
if assert.NotEmpty(t, res.Rules, "Expected result to have rules") {
r := res.Rules[0]
assert.NotNilf(t, r.IP, "Expected ip %s to match, actual: %v", ip, r.IP)
assert.Equalf(t, ip, r.IP.String(), "Expected ip %s to match, actual: %v", ip, r.IP) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
d := newForTest(nil, filters) | <mask> `
<mask> whiteFilters := []Filter{{
<mask> ID: 0, Data: []byte(whiteRules),
<mask> }}
<mask> d := NewForTest(nil, filters)
<mask> d.SetFilters(filters, whiteFilters, false)
<mask> defer d.Close()
<mask>
<mask> // matched by white filter
<mask> res, err := d.CheckHost("host1", dns.TypeA, &setts)
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove defer d.Close()
</s> add t.Cleanup(d.Close) </s> remove // matched by white filter
</s> add // Matched by white filter. </s> remove d := NewForTest(nil, filters)
defer d.Close()
</s> add d := newForTest(nil, filters)
t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
defer d.Close()
// no client settings:
// blocked by filters
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredBlockList {
t.Fatalf("CheckHost FilteredBlockList")
}
</s> add </s> remove // not matched by white filter, but matched by block filter
</s> add // Not matched by white filter, but matched by block filter. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
t.Cleanup(d.Close) | <mask> ID: 0, Data: []byte(whiteRules),
<mask> }}
<mask> d := NewForTest(nil, filters)
<mask> d.SetFilters(filters, whiteFilters, false)
<mask> defer d.Close()
<mask>
<mask> // matched by white filter
<mask> res, err := d.CheckHost("host1", dns.TypeA, &setts)
<mask> assert.Nil(t, err)
<mask> assert.False(t, res.IsFiltered)
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := NewForTest(nil, filters)
</s> add d := newForTest(nil, filters) </s> remove // matched by white filter
</s> add // Matched by white filter. </s> remove // not matched by white filter, but matched by block filter
</s> add // Not matched by white filter, but matched by block filter. </s> remove d := NewForTest(nil, filters)
defer d.Close()
</s> add d := newForTest(nil, filters)
t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
defer d.Close()
// no client settings:
// blocked by filters
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredBlockList {
t.Fatalf("CheckHost FilteredBlockList")
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
// Matched by white filter. | <mask> d := NewForTest(nil, filters)
<mask> d.SetFilters(filters, whiteFilters, false)
<mask> defer d.Close()
<mask>
<mask> // matched by white filter
<mask> res, err := d.CheckHost("host1", dns.TypeA, &setts)
<mask> assert.Nil(t, err)
<mask> assert.False(t, res.IsFiltered)
<mask> assert.Equal(t, res.Reason, NotFilteredAllowList)
<mask> if assert.Len(t, res.Rules, 1) {
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove defer d.Close()
</s> add t.Cleanup(d.Close) </s> remove d := NewForTest(nil, filters)
</s> add d := newForTest(nil, filters) </s> remove // not matched by white filter, but matched by block filter
</s> add // Not matched by white filter, but matched by block filter. </s> remove // Check host for each domain
for _, host := range googleDomains {
res, err := d.CheckHost(host, dns.TypeA, &setts)
assert.Nil(t, err)
assert.True(t, res.IsFiltered)
if assert.Len(t, res.Rules, 1) {
assert.NotEqual(t, res.Rules[0].IP.String(), "0.0.0.0")
}
</s> add func TestCheckHostSafeSearchGoogle(t *testing.T) {
d := newForTest(&Config{SafeSearchEnabled: true}, nil)
t.Cleanup(d.Close)
d.resolver = &testResolver{}
// Check host for each domain.
for _, host := range []string{
"www.google.com",
"www.google.im",
"www.google.co.in",
"www.google.iq",
"www.google.is",
"www.google.it",
"www.google.je",
} {
t.Run(host, func(t *testing.T) {
res, err := d.CheckHost(host, dns.TypeA, &setts)
assert.Nil(t, err)
assert.True(t, res.IsFiltered)
assert.Len(t, res.Rules, 1)
}) </s> remove assert.Equal(t, res.Rules[0].IP.String(), "213.180.193.56")
</s> add assert.Equal(t, res.Rules[0].IP, net.IPv4(213, 180, 193, 56)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
// Not matched by white filter, but matched by block filter. | <mask> if assert.Len(t, res.Rules, 1) {
<mask> assert.Equal(t, "||host1^", res.Rules[0].Text)
<mask> }
<mask>
<mask> // not matched by white filter, but matched by block filter
<mask> res, err = d.CheckHost("host2", dns.TypeA, &setts)
<mask> assert.Nil(t, err)
<mask> assert.True(t, res.IsFiltered)
<mask> assert.Equal(t, res.Reason, FilteredBlockList)
<mask> if assert.Len(t, res.Rules, 1) {
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove // matched by white filter
</s> add // Matched by white filter. </s> remove loopback4 := net.IP{0, 0, 0, 1}
assert.Equal(t, res.Rules[0].IP, loopback4)
</s> add assert.Equal(t, res.Rules[0].IP, net.IP{0, 0, 0, 1}) </s> remove // 2 IPv4 (return only the first one)
</s> add // Two IPv4, the first one returned. </s> remove // ...but empty IPv4
</s> add // Empty IPv4. </s> remove // ...but empty IPv6
</s> add // Empty IPv6. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
// Client Settings. | <mask> assert.Equal(t, "||host2^", res.Rules[0].Text)
<mask> }
<mask> }
<mask>
<mask> // CLIENT SETTINGS
<mask>
<mask> func applyClientSettings(setts *RequestFilteringSettings) {
<mask> setts.FilteringEnabled = false
<mask> setts.ParentalEnabled = false
<mask> setts.SafeBrowsingEnabled = true
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove func NewForTest(c *Config, filters []Filter) *DNSFilter {
</s> add func newForTest(c *Config, filters []Filter) *DNSFilter { </s> remove // IPv6
</s> add // IPv6 match. </s> remove // not matched by white filter, but matched by block filter
</s> add // Not matched by white filter, but matched by block filter. </s> remove // 2 IPv4 (return only the first one)
</s> add // Two IPv4, the first one returned. </s> remove
// blocked by additional rules
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.True(t, r.IsFiltered)
assert.Equal(t, r.Reason, FilteredBlockedService)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
<mask> s.Rules = []*rules.NetworkRule{rule}
<mask> setts.ServicesRules = append(setts.ServicesRules, s)
<mask> }
<mask>
<mask> // Check behaviour without any per-client settings,
<mask> // then apply per-client settings and check behaviour once again
<mask> func TestClientSettings(t *testing.T) {
<mask> var r Result
<mask> filters := []Filter{{
<mask> ID: 0, Data: []byte("||example.org^\n"),
<mask> }}
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove var r Result
filters := []Filter{{
ID: 0, Data: []byte("||example.org^\n"),
</s> add d := newForTest(
&Config{
ParentalEnabled: true,
SafeBrowsingEnabled: false,
},
[]Filter{{
ID: 0, Data: []byte("||example.org^\n"),
}},
)
t.Cleanup(d.Close)
d.parentalUpstream = &testSbUpstream{
hostname: "pornhub.com",
block: true,
}
d.safeBrowsingUpstream = &testSbUpstream{
hostname: "wmconvirus.narod.ru",
block: true,
}
type testCase struct {
name string
host string
before bool
wantReason Reason
}
testCases := []testCase{{
name: "filters",
host: "example.org",
before: true,
wantReason: FilteredBlockList,
}, {
name: "parental",
host: "pornhub.com",
before: true,
wantReason: FilteredParental,
}, {
name: "safebrowsing",
host: "wmconvirus.narod.ru",
before: false,
wantReason: FilteredSafeBrowsing,
}, {
name: "additional_rules",
host: "facebook.com",
before: false,
wantReason: FilteredBlockedService, </s> remove // safesearch is disabled
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost safesearch")
</s> add // Check behaviour without any per-client settings, then apply per-client
// settings and check behaviour once again.
for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, tc.before)) </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
defer d.Close()
// no client settings:
// blocked by filters
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredBlockList {
t.Fatalf("CheckHost FilteredBlockList")
}
</s> add </s> remove d := NewForTest(nil, filters)
defer d.Close()
</s> add d := newForTest(nil, filters)
t.Cleanup(d.Close) </s> remove d := NewForTest(nil, filters)
</s> add d := newForTest(nil, filters) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
|
d := newForTest(
&Config{
ParentalEnabled: true,
SafeBrowsingEnabled: false,
},
[]Filter{{
ID: 0, Data: []byte("||example.org^\n"),
}},
)
t.Cleanup(d.Close)
d.parentalUpstream = &testSbUpstream{
hostname: "pornhub.com",
block: true,
}
d.safeBrowsingUpstream = &testSbUpstream{
hostname: "wmconvirus.narod.ru",
block: true,
}
type testCase struct {
name string
host string
before bool
wantReason Reason
}
testCases := []testCase{{
name: "filters",
host: "example.org",
before: true,
wantReason: FilteredBlockList,
}, {
name: "parental",
host: "pornhub.com",
before: true,
wantReason: FilteredParental,
}, {
name: "safebrowsing",
host: "wmconvirus.narod.ru",
before: false,
wantReason: FilteredSafeBrowsing,
}, {
name: "additional_rules",
host: "facebook.com",
before: false,
wantReason: FilteredBlockedService, | <mask>
<mask> // Check behaviour without any per-client settings,
<mask> // then apply per-client settings and check behaviour once again
<mask> func TestClientSettings(t *testing.T) {
<mask> var r Result
<mask> filters := []Filter{{
<mask> ID: 0, Data: []byte("||example.org^\n"),
<mask> }}
<mask> d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
<mask> defer d.Close()
<mask>
<mask> // no client settings:
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove // Check behaviour without any per-client settings,
// then apply per-client settings and check behaviour once again
</s> add </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
defer d.Close()
// no client settings:
// blocked by filters
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredBlockList {
t.Fatalf("CheckHost FilteredBlockList")
}
</s> add </s> remove // safesearch is disabled
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost safesearch")
</s> add // Check behaviour without any per-client settings, then apply per-client
// settings and check behaviour once again.
for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, tc.before)) </s> remove d := NewForTest(nil, filters)
</s> add d := newForTest(nil, filters) </s> remove d := NewForTest(nil, filters)
defer d.Close()
</s> add d := newForTest(nil, filters)
t.Cleanup(d.Close) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
<mask> var r Result
<mask> filters := []Filter{{
<mask> ID: 0, Data: []byte("||example.org^\n"),
<mask> }}
<mask> d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
<mask> defer d.Close()
<mask>
<mask> // no client settings:
<mask>
<mask> // blocked by filters
<mask> r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
<mask> if !r.IsFiltered || r.Reason != FilteredBlockList {
<mask> t.Fatalf("CheckHost FilteredBlockList")
<mask> }
<mask>
<mask> // blocked by parental
<mask> r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
<mask> if !r.IsFiltered || r.Reason != FilteredParental {
<mask> t.Fatalf("CheckHost FilteredParental")
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove // blocked by parental
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredParental {
t.Fatalf("CheckHost FilteredParental")
</s> add makeTester := func(tc testCase, before bool) func(t *testing.T) {
return func(t *testing.T) {
r, _ := d.CheckHost(tc.host, dns.TypeA, &setts)
if before {
assert.True(t, r.IsFiltered)
assert.Equal(t, tc.wantReason, r.Reason)
} else {
assert.False(t, r.IsFiltered)
}
} </s> remove // override filtering settings
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override parental settings (force disable parental)
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override safesearch settings (force enable safesearch)
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredSafeBrowsing {
t.Fatalf("CheckHost FilteredSafeBrowsing")
</s> add for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, !tc.before)) </s> remove
// blocked by additional rules
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.True(t, r.IsFiltered)
assert.Equal(t, r.Reason, FilteredBlockedService)
</s> add </s> remove // safesearch is disabled
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost safesearch")
</s> add // Check behaviour without any per-client settings, then apply per-client
// settings and check behaviour once again.
for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, tc.before)) </s> remove // not blocked
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.False(t, r.IsFiltered)
// override client settings:
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
|
makeTester := func(tc testCase, before bool) func(t *testing.T) {
return func(t *testing.T) {
r, _ := d.CheckHost(tc.host, dns.TypeA, &setts)
if before {
assert.True(t, r.IsFiltered)
assert.Equal(t, tc.wantReason, r.Reason)
} else {
assert.False(t, r.IsFiltered)
}
} | <mask> if !r.IsFiltered || r.Reason != FilteredBlockList {
<mask> t.Fatalf("CheckHost FilteredBlockList")
<mask> }
<mask>
<mask> // blocked by parental
<mask> r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
<mask> if !r.IsFiltered || r.Reason != FilteredParental {
<mask> t.Fatalf("CheckHost FilteredParental")
<mask> }
<mask>
<mask> // safesearch is disabled
<mask> r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
<mask> if r.IsFiltered {
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
defer d.Close()
// no client settings:
// blocked by filters
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredBlockList {
t.Fatalf("CheckHost FilteredBlockList")
}
</s> add </s> remove // safesearch is disabled
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost safesearch")
</s> add // Check behaviour without any per-client settings, then apply per-client
// settings and check behaviour once again.
for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, tc.before)) </s> remove // override filtering settings
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override parental settings (force disable parental)
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override safesearch settings (force enable safesearch)
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredSafeBrowsing {
t.Fatalf("CheckHost FilteredSafeBrowsing")
</s> add for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, !tc.before)) </s> remove
// blocked by additional rules
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.True(t, r.IsFiltered)
assert.Equal(t, r.Reason, FilteredBlockedService)
</s> add </s> remove // not blocked
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.False(t, r.IsFiltered)
// override client settings:
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
// Check behaviour without any per-client settings, then apply per-client
// settings and check behaviour once again.
for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, tc.before)) | <mask> if !r.IsFiltered || r.Reason != FilteredParental {
<mask> t.Fatalf("CheckHost FilteredParental")
<mask> }
<mask>
<mask> // safesearch is disabled
<mask> r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
<mask> if r.IsFiltered {
<mask> t.Fatalf("CheckHost safesearch")
<mask> }
<mask>
<mask> // not blocked
<mask> r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
<mask> assert.False(t, r.IsFiltered)
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove // blocked by parental
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredParental {
t.Fatalf("CheckHost FilteredParental")
</s> add makeTester := func(tc testCase, before bool) func(t *testing.T) {
return func(t *testing.T) {
r, _ := d.CheckHost(tc.host, dns.TypeA, &setts)
if before {
assert.True(t, r.IsFiltered)
assert.Equal(t, tc.wantReason, r.Reason)
} else {
assert.False(t, r.IsFiltered)
}
} </s> remove // not blocked
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.False(t, r.IsFiltered)
// override client settings:
</s> add </s> remove
// blocked by additional rules
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.True(t, r.IsFiltered)
assert.Equal(t, r.Reason, FilteredBlockedService)
</s> add </s> remove // override filtering settings
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override parental settings (force disable parental)
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override safesearch settings (force enable safesearch)
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredSafeBrowsing {
t.Fatalf("CheckHost FilteredSafeBrowsing")
</s> add for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, !tc.before)) </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
defer d.Close()
// no client settings:
// blocked by filters
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredBlockList {
t.Fatalf("CheckHost FilteredBlockList")
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
<mask> if r.IsFiltered {
<mask> t.Fatalf("CheckHost safesearch")
<mask> }
<mask>
<mask> // not blocked
<mask> r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
<mask> assert.False(t, r.IsFiltered)
<mask>
<mask> // override client settings:
<mask> applyClientSettings(&setts)
<mask>
<mask> // override filtering settings
<mask> r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
<mask> if r.IsFiltered {
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove // override filtering settings
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override parental settings (force disable parental)
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override safesearch settings (force enable safesearch)
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredSafeBrowsing {
t.Fatalf("CheckHost FilteredSafeBrowsing")
</s> add for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, !tc.before)) </s> remove // safesearch is disabled
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost safesearch")
</s> add // Check behaviour without any per-client settings, then apply per-client
// settings and check behaviour once again.
for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, tc.before)) </s> remove // blocked by parental
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredParental {
t.Fatalf("CheckHost FilteredParental")
</s> add makeTester := func(tc testCase, before bool) func(t *testing.T) {
return func(t *testing.T) {
r, _ := d.CheckHost(tc.host, dns.TypeA, &setts)
if before {
assert.True(t, r.IsFiltered)
assert.Equal(t, tc.wantReason, r.Reason)
} else {
assert.False(t, r.IsFiltered)
}
} </s> remove
// blocked by additional rules
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.True(t, r.IsFiltered)
assert.Equal(t, r.Reason, FilteredBlockedService)
</s> add </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
defer d.Close()
// no client settings:
// blocked by filters
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredBlockList {
t.Fatalf("CheckHost FilteredBlockList")
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
|
for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, !tc.before)) | <mask>
<mask> // override client settings:
<mask> applyClientSettings(&setts)
<mask>
<mask> // override filtering settings
<mask> r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
<mask> if r.IsFiltered {
<mask> t.Fatalf("CheckHost")
<mask> }
<mask>
<mask> // override parental settings (force disable parental)
<mask> r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
<mask> if r.IsFiltered {
<mask> t.Fatalf("CheckHost")
<mask> }
<mask>
<mask> // override safesearch settings (force enable safesearch)
<mask> r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
<mask> if !r.IsFiltered || r.Reason != FilteredSafeBrowsing {
<mask> t.Fatalf("CheckHost FilteredSafeBrowsing")
<mask> }
<mask>
<mask> // blocked by additional rules
<mask> r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
<mask> assert.True(t, r.IsFiltered)
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove // not blocked
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.False(t, r.IsFiltered)
// override client settings:
</s> add </s> remove
// blocked by additional rules
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.True(t, r.IsFiltered)
assert.Equal(t, r.Reason, FilteredBlockedService)
</s> add </s> remove // blocked by parental
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredParental {
t.Fatalf("CheckHost FilteredParental")
</s> add makeTester := func(tc testCase, before bool) func(t *testing.T) {
return func(t *testing.T) {
r, _ := d.CheckHost(tc.host, dns.TypeA, &setts)
if before {
assert.True(t, r.IsFiltered)
assert.Equal(t, tc.wantReason, r.Reason)
} else {
assert.False(t, r.IsFiltered)
}
} </s> remove // safesearch is disabled
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost safesearch")
</s> add // Check behaviour without any per-client settings, then apply per-client
// settings and check behaviour once again.
for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, tc.before)) </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
defer d.Close()
// no client settings:
// blocked by filters
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredBlockList {
t.Fatalf("CheckHost FilteredBlockList")
}
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
<mask> r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
<mask> if !r.IsFiltered || r.Reason != FilteredSafeBrowsing {
<mask> t.Fatalf("CheckHost FilteredSafeBrowsing")
<mask> }
<mask>
<mask> // blocked by additional rules
<mask> r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
<mask> assert.True(t, r.IsFiltered)
<mask> assert.Equal(t, r.Reason, FilteredBlockedService)
<mask> }
<mask>
<mask> // BENCHMARKS
<mask>
<mask> func BenchmarkSafeBrowsing(b *testing.B) {
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove // override filtering settings
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override parental settings (force disable parental)
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost")
}
// override safesearch settings (force enable safesearch)
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredSafeBrowsing {
t.Fatalf("CheckHost FilteredSafeBrowsing")
</s> add for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, !tc.before)) </s> remove // blocked by parental
r, _ = d.CheckHost("pornhub.com", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredParental {
t.Fatalf("CheckHost FilteredParental")
</s> add makeTester := func(tc testCase, before bool) func(t *testing.T) {
return func(t *testing.T) {
r, _ := d.CheckHost(tc.host, dns.TypeA, &setts)
if before {
assert.True(t, r.IsFiltered)
assert.Equal(t, tc.wantReason, r.Reason)
} else {
assert.False(t, r.IsFiltered)
}
} </s> remove // safesearch is disabled
r, _ = d.CheckHost("wmconvirus.narod.ru", dns.TypeA, &setts)
if r.IsFiltered {
t.Fatalf("CheckHost safesearch")
</s> add // Check behaviour without any per-client settings, then apply per-client
// settings and check behaviour once again.
for _, tc := range testCases {
t.Run(tc.name, makeTester(tc, tc.before)) </s> remove d := NewForTest(&Config{ParentalEnabled: true, SafeBrowsingEnabled: false}, filters)
defer d.Close()
// no client settings:
// blocked by filters
r, _ = d.CheckHost("example.org", dns.TypeA, &setts)
if !r.IsFiltered || r.Reason != FilteredBlockList {
t.Fatalf("CheckHost FilteredBlockList")
}
</s> add </s> remove // not blocked
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.False(t, r.IsFiltered)
// override client settings:
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
|
// Benchmarks. | <mask> assert.True(t, r.IsFiltered)
<mask> assert.Equal(t, r.Reason, FilteredBlockedService)
<mask> }
<mask>
<mask> // BENCHMARKS
<mask>
<mask> func BenchmarkSafeBrowsing(b *testing.B) {
<mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
<mask> defer d.Close()
<mask> for n := 0; n < b.N; n++ {
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) </s> remove hostname := "wmconvirus.narod.ru"
res, err := d.CheckHost(hostname, dns.TypeA, &setts)
if err != nil {
b.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
b.Errorf("Expected hostname %s to match", hostname)
}
</s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove if !ok {
b.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove
// blocked by additional rules
r, _ = d.CheckHost("facebook.com", dns.TypeA, &setts)
assert.True(t, r.IsFiltered)
assert.Equal(t, r.Reason, FilteredBlockedService)
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} | <mask>
<mask> // BENCHMARKS
<mask>
<mask> func BenchmarkSafeBrowsing(b *testing.B) {
<mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
<mask> defer d.Close()
<mask> for n := 0; n < b.N; n++ {
<mask> hostname := "wmconvirus.narod.ru"
<mask> res, err := d.CheckHost(hostname, dns.TypeA, &setts)
<mask> if err != nil {
<mask> b.Errorf("Error while matching host %s: %s", hostname, err)
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove hostname := "wmconvirus.narod.ru"
res, err := d.CheckHost(hostname, dns.TypeA, &setts)
if err != nil {
b.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
b.Errorf("Expected hostname %s to match", hostname)
}
</s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove // BENCHMARKS
</s> add // Benchmarks. </s> remove hostname := "wmconvirus.narod.ru"
res, err := d.CheckHost(hostname, dns.TypeA, &setts)
if err != nil {
b.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
b.Errorf("Expected hostname %s to match", hostname)
}
</s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if res.IsFiltered {
t.Errorf("Expected hostname %s to not match", hostname)
}
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Falsef(t, res.IsFiltered, "Expected hostname %s to not match", hostname) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) | <mask> func BenchmarkSafeBrowsing(b *testing.B) {
<mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
<mask> defer d.Close()
<mask> for n := 0; n < b.N; n++ {
<mask> hostname := "wmconvirus.narod.ru"
<mask> res, err := d.CheckHost(hostname, dns.TypeA, &setts)
<mask> if err != nil {
<mask> b.Errorf("Error while matching host %s: %s", hostname, err)
<mask> }
<mask> if !res.IsFiltered {
<mask> b.Errorf("Expected hostname %s to match", hostname)
<mask> }
<mask> }
<mask> }
<mask>
<mask> func BenchmarkSafeBrowsingParallel(b *testing.B) {
<mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} </s> remove hostname := "wmconvirus.narod.ru"
res, err := d.CheckHost(hostname, dns.TypeA, &setts)
if err != nil {
b.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
b.Errorf("Expected hostname %s to match", hostname)
}
</s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
t.Errorf("Expected hostname %s to match", hostname)
}
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if res.IsFiltered {
t.Errorf("Expected hostname %s to not match", hostname)
}
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Falsef(t, res.IsFiltered, "Expected hostname %s to not match", hostname) </s> remove // BENCHMARKS
</s> add // Benchmarks. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} | <mask> }
<mask> }
<mask>
<mask> func BenchmarkSafeBrowsingParallel(b *testing.B) {
<mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
<mask> defer d.Close()
<mask> b.RunParallel(func(pb *testing.PB) {
<mask> for pb.Next() {
<mask> hostname := "wmconvirus.narod.ru"
<mask> res, err := d.CheckHost(hostname, dns.TypeA, &setts)
<mask> if err != nil {
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove hostname := "wmconvirus.narod.ru"
res, err := d.CheckHost(hostname, dns.TypeA, &setts)
if err != nil {
b.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
b.Errorf("Expected hostname %s to match", hostname)
}
</s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove hostname := "wmconvirus.narod.ru"
res, err := d.CheckHost(hostname, dns.TypeA, &setts)
if err != nil {
b.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
b.Errorf("Expected hostname %s to match", hostname)
}
</s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if res.IsFiltered {
t.Errorf("Expected hostname %s to not match", hostname)
}
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Falsef(t, res.IsFiltered, "Expected hostname %s to not match", hostname) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) | <mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
<mask> defer d.Close()
<mask> b.RunParallel(func(pb *testing.PB) {
<mask> for pb.Next() {
<mask> hostname := "wmconvirus.narod.ru"
<mask> res, err := d.CheckHost(hostname, dns.TypeA, &setts)
<mask> if err != nil {
<mask> b.Errorf("Error while matching host %s: %s", hostname, err)
<mask> }
<mask> if !res.IsFiltered {
<mask> b.Errorf("Expected hostname %s to match", hostname)
<mask> }
<mask> }
<mask> })
<mask> }
<mask>
<mask> func BenchmarkSafeSearch(b *testing.B) {
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove hostname := "wmconvirus.narod.ru"
res, err := d.CheckHost(hostname, dns.TypeA, &setts)
if err != nil {
b.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
b.Errorf("Expected hostname %s to match", hostname)
}
</s> add res, err := d.CheckHost(blocked, dns.TypeA, &setts)
assert.Nilf(b, err, "Error while matching host %s: %s", blocked, err)
assert.True(b, res.IsFiltered, "Expected hostname %s to match", blocked) </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
t.Errorf("Expected hostname %s to match", hostname)
}
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if res.IsFiltered {
t.Errorf("Expected hostname %s to not match", hostname)
}
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Falsef(t, res.IsFiltered, "Expected hostname %s to not match", hostname) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) | <mask> })
<mask> }
<mask>
<mask> func BenchmarkSafeSearch(b *testing.B) {
<mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
<mask> defer d.Close()
<mask> for n := 0; n < b.N; n++ {
<mask> val, ok := d.SafeSearchDomain("www.google.com")
<mask> if !ok {
<mask> b.Errorf("Expected safesearch to find result for www.google.com")
<mask> }
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove if !ok {
b.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) </s> remove if !ok {
b.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove if !ok {
t.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
t.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(t, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(t, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
t.Cleanup(d.Close) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
assert.True(b, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") | <mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
<mask> defer d.Close()
<mask> for n := 0; n < b.N; n++ {
<mask> val, ok := d.SafeSearchDomain("www.google.com")
<mask> if !ok {
<mask> b.Errorf("Expected safesearch to find result for www.google.com")
<mask> }
<mask> if val != "forcesafesearch.google.com" {
<mask> b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
<mask> }
<mask> }
<mask> }
<mask>
<mask> func BenchmarkSafeSearchParallel(b *testing.B) {
<mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) </s> remove if !ok {
b.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove if !ok {
t.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
t.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(t, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(t, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
t.Cleanup(d.Close) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) | <mask> }
<mask> }
<mask>
<mask> func BenchmarkSafeSearchParallel(b *testing.B) {
<mask> d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
<mask> defer d.Close()
<mask> b.RunParallel(func(pb *testing.PB) {
<mask> for pb.Next() {
<mask> val, ok := d.SafeSearchDomain("www.google.com")
<mask> if !ok {
<mask> b.Errorf("Expected safesearch to find result for www.google.com")
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove if !ok {
b.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove if !ok {
b.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) </s> remove if !ok {
t.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
t.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(t, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(t, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
t.Cleanup(d.Close) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
assert.True(b, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") | <mask> defer d.Close()
<mask> b.RunParallel(func(pb *testing.PB) {
<mask> for pb.Next() {
<mask> val, ok := d.SafeSearchDomain("www.google.com")
<mask> if !ok {
<mask> b.Errorf("Expected safesearch to find result for www.google.com")
<mask> }
<mask> if val != "forcesafesearch.google.com" {
<mask> b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
<mask> }
<mask> }
<mask> })
<mask> }
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove if !ok {
b.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
b.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(b, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(b, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove if !ok {
t.Errorf("Expected safesearch to find result for www.google.com")
}
if val != "forcesafesearch.google.com" {
t.Errorf("Expected safesearch for google.com to be forcesafesearch.google.com")
}
</s> add assert.True(t, ok, "Expected safesearch to find result for www.google.com")
assert.Equal(t, "forcesafesearch.google.com", val, "Expected safesearch for google.com to be forcesafesearch.google.com") </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
b.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeSearchEnabled: true}, nil)
t.Cleanup(d.Close) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsfilter_test.go |
f := newForTest(nil, []Filter{{ID: 0, Data: []byte(text)}}) | <mask> |disable-all^$dnsrewrite=127.0.0.2
<mask> @@||disable-all^$dnsrewrite
<mask> `
<mask>
<mask> f := NewForTest(nil, []Filter{{ID: 0, Data: []byte(text)}})
<mask> setts := &RequestFilteringSettings{
<mask> FilteringEnabled: true,
<mask> }
<mask>
<mask> ipv4p1 := net.IPv4(127, 0, 0, 1)
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := NewForTest(nil, filters)
</s> add d := newForTest(nil, filters) </s> remove // ...and 1 IPv6 address
</s> add // One IPv6 address. </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
assert.Equal(t, res.Rules[0].IP, loopback6)
</s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback) </s> remove d := NewForTest(nil, filters)
defer d.Close()
</s> add d := newForTest(nil, filters)
t.Cleanup(d.Close) </s> remove defer d.Close()
</s> add t.Cleanup(d.Close) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/dnsrewrite_test.go |
d := newForTest(nil, nil)
t.Cleanup(d.Close) | <mask> "github.com/stretchr/testify/assert"
<mask> )
<mask>
<mask> func TestRewrites(t *testing.T) {
<mask> d := DNSFilter{}
<mask> // CNAME, A, AAAA
<mask> d.Rewrites = []RewriteEntry{
<mask> {"somecname", "somehost.com", 0, nil},
<mask> {"somehost.com", "0.0.0.0", 0, nil},
<mask>
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove // ...and 1 IPv6 address
</s> add // One IPv6 address. | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/rewrites_test.go |
d := newForTest(nil, nil)
t.Cleanup(d.Close) | <mask> assert.True(t, r.IPList[0].Equal(net.IP{1, 2, 3, 4}))
<mask> }
<mask>
<mask> func TestRewritesLevels(t *testing.T) {
<mask> d := DNSFilter{}
<mask> // exact host, wildcard L2, wildcard L3
<mask> d.Rewrites = []RewriteEntry{
<mask> {"host.com", "1.1.1.1", 0, nil},
<mask> {"*.host.com", "2.2.2.2", 0, nil},
<mask> {"*.sub.host.com", "3.3.3.3", 0, nil},
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
assert.Equal(t, res.Rules[0].IP, loopback6)
</s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/rewrites_test.go |
d := newForTest(nil, nil)
t.Cleanup(d.Close) | <mask> assert.True(t, net.IP{3, 3, 3, 3}.Equal(r.IPList[0]))
<mask> }
<mask>
<mask> func TestRewritesExceptionCNAME(t *testing.T) {
<mask> d := DNSFilter{}
<mask> // wildcard; exception for a sub-domain
<mask> d.Rewrites = []RewriteEntry{
<mask> {"*.host.com", "2.2.2.2", 0, nil},
<mask> {"sub.host.com", "sub.host.com", 0, nil},
<mask> }
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
assert.Equal(t, res.Rules[0].IP, loopback6)
</s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/rewrites_test.go |
d := newForTest(nil, nil)
t.Cleanup(d.Close) | <mask> assert.Equal(t, NotFilteredNotFound, r.Reason)
<mask> }
<mask>
<mask> func TestRewritesExceptionWC(t *testing.T) {
<mask> d := DNSFilter{}
<mask> // wildcard; exception for a sub-wildcard
<mask> d.Rewrites = []RewriteEntry{
<mask> {"*.host.com", "2.2.2.2", 0, nil},
<mask> {"*.sub.host.com", "*.sub.host.com", 0, nil},
<mask> }
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
assert.Equal(t, res.Rules[0].IP, loopback6)
</s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/rewrites_test.go |
d := newForTest(nil, nil)
t.Cleanup(d.Close) | <mask> assert.Equal(t, NotFilteredNotFound, r.Reason)
<mask> }
<mask>
<mask> func TestRewritesExceptionIP(t *testing.T) {
<mask> d := DNSFilter{}
<mask> // exception for AAAA record
<mask> d.Rewrites = []RewriteEntry{
<mask> {"host.com", "1.2.3.4", 0, nil},
<mask> {"host.com", "AAAA", 0, nil},
<mask> {"host2.com", "::1", 0, nil},
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) </s> remove loopback6 := net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
assert.Equal(t, res.Rules[0].IP, loopback6)
</s> add assert.Equal(t, res.Rules[0].IP, net.IPv6loopback) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/rewrites_test.go |
"sync" | <mask> import (
<mask> "crypto/sha256"
<mask> "encoding/hex"
<mask> "strings"
<mask> "testing"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr"
<mask> "github.com/AdguardTeam/golibs/cache"
<mask> "github.com/miekg/dns"
<mask> "github.com/stretchr/testify/assert"
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := DNSFilter{}
</s> add d := newForTest(nil, nil)
t.Cleanup(d.Close) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safebrowsing_test.go |
d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close) | <mask> return ""
<mask> }
<mask>
<mask> func TestSBPC_checkErrorUpstream(t *testing.T) {
<mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
<mask> defer d.Close()
<mask>
<mask> ups := &testErrUpstream{}
<mask>
<mask> d.safeBrowsingUpstream = ups
<mask> d.parentalUpstream = ups
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close)
matching := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: matching,
block: true,
}
</s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safebrowsing_test.go |
counterLock sync.RWMutex | <mask> type testSbUpstream struct {
<mask> hostname string
<mask> block bool
<mask> requestsCount int
<mask> }
<mask>
<mask> // Exchange returns a message depending on the upstream settings (hostname, block)
<mask> func (u *testSbUpstream) Exchange(r *dns.Msg) (*dns.Msg, error) {
<mask> u.counterLock.Lock()
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove var r Result
filters := []Filter{{
ID: 0, Data: []byte("||example.org^\n"),
</s> add d := newForTest(
&Config{
ParentalEnabled: true,
SafeBrowsingEnabled: false,
},
[]Filter{{
ID: 0, Data: []byte("||example.org^\n"),
}},
)
t.Cleanup(d.Close)
d.parentalUpstream = &testSbUpstream{
hostname: "pornhub.com",
block: true,
}
d.safeBrowsingUpstream = &testSbUpstream{
hostname: "wmconvirus.narod.ru",
block: true,
}
type testCase struct {
name string
host string
before bool
wantReason Reason
}
testCases := []testCase{{
name: "filters",
host: "example.org",
before: true,
wantReason: FilteredBlockList,
}, {
name: "parental",
host: "pornhub.com",
before: true,
wantReason: FilteredParental,
}, {
name: "safebrowsing",
host: "wmconvirus.narod.ru",
before: false,
wantReason: FilteredSafeBrowsing,
}, {
name: "additional_rules",
host: "facebook.com",
before: false,
wantReason: FilteredBlockedService, | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safebrowsing_test.go |
u.counterLock.Lock() | <mask>
<mask> // Exchange returns a message depending on the upstream settings (hostname, block)
<mask> func (u *testSbUpstream) Exchange(r *dns.Msg) (*dns.Msg, error) {
<mask> u.requestsCount++
<mask> u.counterLock.Unlock()
<mask>
<mask> hash := sha256.Sum256([]byte(u.hostname))
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove func TestCheckHostSafeSearchGoogle(t *testing.T) {
d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
// Slice of google domains
googleDomains := []string{"www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je"}
</s> add // testResolver is a Resolver for tests.
type testResolver struct{}
// LookupIP implements Resolver interface for *testResolver.
func (r *testResolver) LookupIPAddr(_ context.Context, host string) (ips []net.IPAddr, err error) {
hash := sha256.Sum256([]byte(host))
addrs := []net.IPAddr{{
IP: net.IP(hash[:4]),
Zone: "somezone",
}, {
IP: net.IP(hash[4:20]),
Zone: "somezone",
}}
return addrs, nil
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safebrowsing_test.go |
u.counterLock.Unlock() | <mask> // Exchange returns a message depending on the upstream settings (hostname, block)
<mask> func (u *testSbUpstream) Exchange(r *dns.Msg) (*dns.Msg, error) {
<mask> u.counterLock.Lock()
<mask> u.requestsCount++
<mask>
<mask> hash := sha256.Sum256([]byte(u.hostname))
<mask> prefix := hash[0:2]
<mask> hashToReturn := hex.EncodeToString(prefix) + strings.Repeat("ab", 28)
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove func TestCheckHostSafeSearchGoogle(t *testing.T) {
d := NewForTest(&Config{SafeSearchEnabled: true}, nil)
defer d.Close()
// Slice of google domains
googleDomains := []string{"www.google.com", "www.google.im", "www.google.co.in", "www.google.iq", "www.google.is", "www.google.it", "www.google.je"}
</s> add // testResolver is a Resolver for tests.
type testResolver struct{}
// LookupIP implements Resolver interface for *testResolver.
func (r *testResolver) LookupIPAddr(_ context.Context, host string) (ips []net.IPAddr, err error) {
hash := sha256.Sum256([]byte(host))
addrs := []net.IPAddr{{
IP: net.IP(hash[:4]),
Zone: "somezone",
}, {
IP: net.IP(hash[4:20]),
Zone: "somezone",
}}
return addrs, nil
} </s> remove // 2 IPv4 (return only the first one)
</s> add // Two IPv4, the first one returned. | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safebrowsing_test.go |
d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close) | <mask> return ""
<mask> }
<mask>
<mask> func TestSBPC_sbValidResponse(t *testing.T) {
<mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
<mask> defer d.Close()
<mask>
<mask> ups := &testSbUpstream{}
<mask> d.safeBrowsingUpstream = ups
<mask> d.parentalUpstream = ups
<mask>
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close)
matching := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: matching,
block: true,
}
</s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safebrowsing_test.go |
d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close) | <mask> assert.Equal(t, 1, ups.requestsCount)
<mask> }
<mask>
<mask> func TestSBPC_pcBlockedResponse(t *testing.T) {
<mask> d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
<mask> defer d.Close()
<mask>
<mask> ups := &testSbUpstream{}
<mask> d.safeBrowsingUpstream = ups
<mask> d.parentalUpstream = ups
<mask>
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close) </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
t.Cleanup(d.Close)
matching := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: matching,
block: true,
}
</s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} </s> remove d := NewForTest(&Config{SafeBrowsingEnabled: true}, nil)
defer d.Close()
</s> add d := newForTest(&Config{SafeBrowsingEnabled: true}, nil)
b.Cleanup(d.Close)
blocked := "wmconvirus.narod.ru"
d.safeBrowsingUpstream = &testSbUpstream{
hostname: blocked,
block: true,
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safebrowsing_test.go |
"context" | <mask> package dnsfilter
<mask>
<mask> import (
<mask> "bytes"
<mask> "encoding/binary"
<mask> "encoding/gob"
<mask> "encoding/json"
<mask> "fmt"
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove // FILTERING
const nl = "\n"
const (
blockingRules = `||example.org^` + nl
allowlistRules = `||example.org^` + nl + `@@||test.example.org` + nl
importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl
regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl
maskRules = `test*.example.org^` + nl + `exam*.com` + nl
dnstypeRules = `||example.org^$dnstype=AAAA` + nl + `@@||test.example.org^` + nl
)
var tests = []struct {
testname string
rules string
hostname string
isFiltered bool
reason Reason
dnsType uint16
}{
{"sanity", "||doubleclick.net^", "www.doubleclick.net", true, FilteredBlockList, dns.TypeA},
{"sanity", "||doubleclick.net^", "nodoubleclick.net", false, NotFilteredNotFound, dns.TypeA},
{"sanity", "||doubleclick.net^", "doubleclick.net.ru", false, NotFilteredNotFound, dns.TypeA},
{"sanity", "||doubleclick.net^", "wmconvirus.narod.ru", false, NotFilteredNotFound, dns.TypeA},
{"blocking", blockingRules, "example.org", true, FilteredBlockList, dns.TypeA},
{"blocking", blockingRules, "test.example.org", true, FilteredBlockList, dns.TypeA},
{"blocking", blockingRules, "test.test.example.org", true, FilteredBlockList, dns.TypeA},
{"blocking", blockingRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA},
{"blocking", blockingRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA},
{"allowlist", allowlistRules, "example.org", true, FilteredBlockList, dns.TypeA},
{"allowlist", allowlistRules, "test.example.org", false, NotFilteredAllowList, dns.TypeA},
{"allowlist", allowlistRules, "test.test.example.org", false, NotFilteredAllowList, dns.TypeA},
{"allowlist", allowlistRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA},
{"allowlist", allowlistRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA},
{"important", importantRules, "example.org", false, NotFilteredAllowList, dns.TypeA},
{"important", importantRules, "test.example.org", true, FilteredBlockList, dns.TypeA},
{"important", importantRules, "test.test.example.org", true, FilteredBlockList, dns.TypeA},
{"important", importantRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA},
{"important", importantRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA},
{"regex", regexRules, "example.org", true, FilteredBlockList, dns.TypeA},
{"regex", regexRules, "test.example.org", false, NotFilteredAllowList, dns.TypeA},
{"regex", regexRules, "test.test.example.org", false, NotFilteredAllowList, dns.TypeA},
{"regex", regexRules, "testexample.org", true, FilteredBlockList, dns.TypeA},
{"regex", regexRules, "onemoreexample.org", true, FilteredBlockList, dns.TypeA},
{"mask", maskRules, "test.example.org", true, FilteredBlockList, dns.TypeA},
{"mask", maskRules, "test2.example.org", true, FilteredBlockList, dns.TypeA},
{"mask", maskRules, "example.com", true, FilteredBlockList, dns.TypeA},
{"mask", maskRules, "exampleeee.com", true, FilteredBlockList, dns.TypeA},
{"mask", maskRules, "onemoreexamsite.com", true, FilteredBlockList, dns.TypeA},
{"mask", maskRules, "example.org", false, NotFilteredNotFound, dns.TypeA},
{"mask", maskRules, "testexample.org", false, NotFilteredNotFound, dns.TypeA},
{"mask", maskRules, "example.co.uk", false, NotFilteredNotFound, dns.TypeA},
{"dnstype", dnstypeRules, "onemoreexample.org", false, NotFilteredNotFound, dns.TypeA},
{"dnstype", dnstypeRules, "example.org", false, NotFilteredNotFound, dns.TypeA},
{"dnstype", dnstypeRules, "example.org", true, FilteredBlockList, dns.TypeAAAA},
{"dnstype", dnstypeRules, "test.example.org", false, NotFilteredAllowList, dns.TypeA},
{"dnstype", dnstypeRules, "test.example.org", false, NotFilteredAllowList, dns.TypeAAAA},
}
</s> add // Filtering. </s> remove for _, test := range tests {
t.Run(fmt.Sprintf("%s-%s", test.testname, test.hostname), func(t *testing.T) {
filters := []Filter{{
ID: 0, Data: []byte(test.rules),
}}
d := NewForTest(nil, filters)
defer d.Close()
res, err := d.CheckHost(test.hostname, test.dnsType, &setts)
if err != nil {
t.Errorf("Error while matching host %s: %s", test.hostname, err)
}
if res.IsFiltered != test.isFiltered {
t.Errorf("Hostname %s has wrong result (%v must be %v)", test.hostname, res.IsFiltered, test.isFiltered)
}
if res.Reason != test.reason {
t.Errorf("Hostname %s has wrong reason (%v must be %v)", test.hostname, res.Reason.String(), test.reason.String())
}
</s> add const nl = "\n"
const (
blockingRules = `||example.org^` + nl
allowlistRules = `||example.org^` + nl + `@@||test.example.org` + nl
importantRules = `@@||example.org^` + nl + `||test.example.org^$important` + nl
regexRules = `/example\.org/` + nl + `@@||test.example.org^` + nl
maskRules = `test*.example.org^` + nl + `exam*.com` + nl
dnstypeRules = `||example.org^$dnstype=AAAA` + nl + `@@||test.example.org^` + nl
)
testCases := []struct {
name string
rules string
host string
wantIsFiltered bool
wantReason Reason
wantDNSType uint16
}{{
name: "sanity",
rules: "||doubleclick.net^",
host: "www.doubleclick.net",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "sanity",
rules: "||doubleclick.net^",
host: "nodoubleclick.net",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "sanity",
rules: "||doubleclick.net^",
host: "doubleclick.net.ru",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "sanity",
rules: "||doubleclick.net^",
host: "wmconvirus.narod.ru",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "test.test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "blocking",
rules: blockingRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "test.test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "allowlist",
rules: allowlistRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "test.test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "important",
rules: importantRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "test.test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "testexample.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "regex",
rules: regexRules,
host: "onemoreexample.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "test.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "test2.example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "example.com",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "exampleeee.com",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "onemoreexamsite.com",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "example.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "testexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "mask",
rules: maskRules,
host: "example.co.uk",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "onemoreexample.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "example.org",
wantIsFiltered: false,
wantReason: NotFilteredNotFound,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "example.org",
wantIsFiltered: true,
wantReason: FilteredBlockList,
wantDNSType: dns.TypeAAAA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeA,
}, {
name: "dnstype",
rules: dnstypeRules,
host: "test.example.org",
wantIsFiltered: false,
wantReason: NotFilteredAllowList,
wantDNSType: dns.TypeAAAA,
}}
for _, tc := range testCases {
t.Run(fmt.Sprintf("%s-%s", tc.name, tc.host), func(t *testing.T) {
filters := []Filter{{ID: 0, Data: []byte(tc.rules)}}
d := newForTest(nil, filters)
t.Cleanup(d.Close)
res, err := d.CheckHost(tc.host, tc.wantDNSType, &setts)
assert.Nilf(t, err, "Error while matching host %s: %s", tc.host, err)
assert.Equalf(t, tc.wantIsFiltered, res.IsFiltered, "Hostname %s has wrong result (%v must be %v)", tc.host, res.IsFiltered, tc.wantIsFiltered)
assert.Equalf(t, tc.wantReason, res.Reason, "Hostname %s has wrong reason (%v must be %v)", tc.host, res.Reason, tc.wantReason) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safesearch.go |
ipAddrs, err := d.resolver.LookupIPAddr(context.Background(), safeHost) | <mask>
<mask> return res, nil
<mask> }
<mask>
<mask> // TODO this address should be resolved with upstream that was configured in dnsforward
<mask> ips, err := net.LookupIP(safeHost)
<mask> if err != nil {
<mask> log.Tracef("SafeSearchDomain for %s was found but failed to lookup for %s cause %s", host, safeHost, err)
<mask> return Result{}, err
<mask> }
<mask>
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove for _, ip := range ips {
if ipv4 := ip.To4(); ipv4 != nil {
</s> add for _, ipAddr := range ipAddrs {
if ipv4 := ipAddr.IP.To4(); ipv4 != nil { </s> remove if err != nil {
t.Fatalf("CheckHost for safesearh domain %s failed cause %s", domain, err)
}
</s> add assert.Nilf(t, err, "CheckHost for safesearh domain %s failed cause %s", domain, err) </s> remove // For yandex we already know valid ip.
</s> add // For yandex we already know valid IP. </s> remove ips, err := net.LookupIP(safeDomain)
</s> add ipAddrs, err := resolver.LookupIPAddr(context.Background(), safeDomain) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safesearch.go |
for _, ipAddr := range ipAddrs {
if ipv4 := ipAddr.IP.To4(); ipv4 != nil { | <mask> log.Tracef("SafeSearchDomain for %s was found but failed to lookup for %s cause %s", host, safeHost, err)
<mask> return Result{}, err
<mask> }
<mask>
<mask> for _, ip := range ips {
<mask> if ipv4 := ip.To4(); ipv4 != nil {
<mask> res.Rules[0].IP = ipv4
<mask>
<mask> l := d.setCacheResult(gctx.safeSearchCache, host, res)
<mask> log.Debug("SafeSearch: stored in cache: %s (%d bytes)", host, l)
<mask>
</s> Pull request: 2574 external tests vol.1
Merge in DNS/adguard-home from 2574-external-tests to master
Updates #2574.
Squashed commit of the following:
commit cb7017aa7fc1c81c014c1fa7e0972b06748aff29
Merge: 2a073431 eeeb0383
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:43:41 2021 +0300
Merge branch 'master' into 2574-external-tests
commit 2a0734311c5a6ddd2d9c3f56a4494a20b4197955
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 15:16:40 2021 +0300
dnsfilter: imp docs
commit 49aff871282e2739d27fcbceefdf1bd005c21174
Author: Eugene Burkov <[email protected]>
Date: Fri Jan 29 14:10:56 2021 +0300
dnsfilter: imp docs
commit 11be89a5378c0e451f1b88dc48a2e8827ba38358
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 21:20:55 2021 +0300
dnsfilter: fix go version trouble
commit 1ba4afd95bd739c18818ab0bea0ae70d59b880dc
Author: Eugene Burkov <[email protected]>
Date: Thu Jan 28 17:42:29 2021 +0300
dnsfilter: imp tests </s> remove // TODO this address should be resolved with upstream that was configured in dnsforward
ips, err := net.LookupIP(safeHost)
</s> add ipAddrs, err := d.resolver.LookupIPAddr(context.Background(), safeHost) </s> remove ip := ips[0]
for _, i := range ips {
if i.To4() != nil {
ip = i
</s> add ip := ipAddrs[0].IP
for _, ipAddr := range ipAddrs {
if ipAddr.IP.To4() != nil {
ip = ipAddr.IP </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
t.Errorf("Expected hostname %s to match", hostname)
}
if len(res.Rules) == 0 {
t.Errorf("Expected result to have rules")
return
}
r := res.Rules[0]
if r.IP == nil || r.IP.String() != ip {
t.Errorf("Expected ip %s to match, actual: %v", ip, r.IP)
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname)
if assert.NotEmpty(t, res.Rules, "Expected result to have rules") {
r := res.Rules[0]
assert.NotNilf(t, r.IP, "Expected ip %s to match, actual: %v", ip, r.IP)
assert.Equalf(t, ip, r.IP.String(), "Expected ip %s to match, actual: %v", ip, r.IP) </s> remove if err != nil {
t.Fatalf("CheckHost for safesearh domain %s failed cause %s", domain, err)
}
</s> add assert.Nilf(t, err, "CheckHost for safesearh domain %s failed cause %s", domain, err) </s> remove if err != nil {
t.Errorf("Error while matching host %s: %s", hostname, err)
}
if !res.IsFiltered {
t.Errorf("Expected hostname %s to match", hostname)
}
</s> add assert.Nilf(t, err, "Error while matching host %s: %s", hostname, err)
assert.Truef(t, res.IsFiltered, "Expected hostname %s to match", hostname) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d0a419bd34dd8fe612f790ace698aebd930bfcc | internal/dnsfilter/safesearch.go |
// Init checks the configuration and initializes the server
func (s *Server) Init(config ServerConfig) error {
err := s.setConfig(config)
if err != nil {
return err | <mask> }
<mask> log.Info("Available network interfaces: %s", buf.String())
<mask> }
<mask>
<mask> // Start will listen on port 67 and serve DHCP requests.
<mask> // Even though config can be nil, it is not optional (at least for now), since there are no default values (yet).
<mask> func (s *Server) Start(config *ServerConfig) error {
<mask> if config != nil {
<mask> s.ServerConfig = *config
<mask> }
<mask>
<mask> iface, err := net.InterfaceByName(s.InterfaceName)
<mask> if err != nil {
<mask> s.closeConn() // in case it was already started
</s> * dhcpd: move code from Start() to Init() </s> remove s.dbLoad()
</s> add iface, err := net.InterfaceByName(s.InterfaceName)
if err != nil {
return wrapErrPrint(err, "Couldn't find interface by name %s", s.InterfaceName)
} </s> remove s.closeConn() // in case it was already started
</s> add </s> remove // s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
s.dbLoad()
return nil
}
func (s *Server) setConfig(config ServerConfig) error {
s.ServerConfig = config | <mask> if err != nil {
<mask> return err
<mask> }
<mask>
<mask> iface, err := net.InterfaceByName(s.InterfaceName)
<mask> if err != nil {
<mask> printInterfaces()
<mask> return wrapErrPrint(err, "Couldn't find interface by name %s", s.InterfaceName)
<mask> }
</s> * dhcpd: move code from Start() to Init() </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.dbLoad()
</s> add iface, err := net.InterfaceByName(s.InterfaceName)
if err != nil {
return wrapErrPrint(err, "Couldn't find interface by name %s", s.InterfaceName)
} </s> remove s.closeConn() // in case it was already started
</s> add </s> remove
s.closeConn() // in case it was already started
</s> add </s> remove // s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
<mask> }
<mask>
<mask> iface, err := net.InterfaceByName(s.InterfaceName)
<mask> if err != nil {
<mask> s.closeConn() // in case it was already started
<mask> printInterfaces()
<mask> return wrapErrPrint(err, "Couldn't find interface by name %s", s.InterfaceName)
<mask> }
<mask>
<mask> // get ipv4 address of an interface
</s> * dhcpd: move code from Start() to Init() </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.dbLoad()
</s> add iface, err := net.InterfaceByName(s.InterfaceName)
if err != nil {
return wrapErrPrint(err, "Couldn't find interface by name %s", s.InterfaceName)
} </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
|
<mask>
<mask> // get ipv4 address of an interface
<mask> s.ipnet = getIfaceIPv4(iface)
<mask> if s.ipnet == nil {
<mask> s.closeConn() // in case it was already started
<mask> return wrapErrPrint(err, "Couldn't find IPv4 address of interface %s %+v", s.InterfaceName, iface)
<mask> }
<mask>
<mask> if s.LeaseDuration == 0 {
<mask> s.leaseTime = time.Hour * 2
</s> * dhcpd: move code from Start() to Init() </s> remove s.closeConn() // in case it was already started
</s> add </s> remove // s.closeConn() // in case it was already started
</s> add </s> remove
s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
|
<mask> }
<mask>
<mask> s.leaseStart, err = parseIPv4(s.RangeStart)
<mask> if err != nil {
<mask>
<mask> s.closeConn() // in case it was already started
<mask> return wrapErrPrint(err, "Failed to parse range start address %s", s.RangeStart)
<mask> }
<mask>
<mask> s.leaseStop, err = parseIPv4(s.RangeEnd)
<mask> if err != nil {
</s> * dhcpd: move code from Start() to Init() </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.dbLoad()
</s> add iface, err := net.InterfaceByName(s.InterfaceName)
if err != nil {
return wrapErrPrint(err, "Couldn't find interface by name %s", s.InterfaceName)
} </s> remove s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
|
<mask> }
<mask>
<mask> s.leaseStop, err = parseIPv4(s.RangeEnd)
<mask> if err != nil {
<mask> s.closeConn() // in case it was already started
<mask> return wrapErrPrint(err, "Failed to parse range end address %s", s.RangeEnd)
<mask> }
<mask>
<mask> subnet, err := parseIPv4(s.SubnetMask)
<mask> if err != nil {
</s> * dhcpd: move code from Start() to Init() </s> remove
s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove // s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
|
<mask> }
<mask>
<mask> subnet, err := parseIPv4(s.SubnetMask)
<mask> if err != nil {
<mask> s.closeConn() // in case it was already started
<mask> return wrapErrPrint(err, "Failed to parse subnet mask %s", s.SubnetMask)
<mask> }
<mask>
<mask> // if !bytes.Equal(subnet, s.ipnet.Mask) {
<mask> // s.closeConn() // in case it was already started
</s> * dhcpd: move code from Start() to Init() </s> remove // s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove
s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
|
<mask> return wrapErrPrint(err, "Failed to parse subnet mask %s", s.SubnetMask)
<mask> }
<mask>
<mask> // if !bytes.Equal(subnet, s.ipnet.Mask) {
<mask> // s.closeConn() // in case it was already started
<mask> // return wrapErrPrint(err, "specified subnet mask %s does not meatch interface %s subnet mask %s", s.SubnetMask, s.InterfaceName, s.ipnet.Mask)
<mask> // }
<mask>
<mask> router, err := parseIPv4(s.GatewayIP)
<mask> if err != nil {
</s> * dhcpd: move code from Start() to Init() </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove
s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
|
<mask> // }
<mask>
<mask> router, err := parseIPv4(s.GatewayIP)
<mask> if err != nil {
<mask> s.closeConn() // in case it was already started
<mask> return wrapErrPrint(err, "Failed to parse gateway IP %s", s.GatewayIP)
<mask> }
<mask>
<mask> s.leaseOptions = dhcp4.Options{
<mask> dhcp4.OptionSubnetMask: subnet,
</s> * dhcpd: move code from Start() to Init() </s> remove // s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add </s> remove
s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
|
return nil
}
// Start will listen on port 67 and serve DHCP requests.
func (s *Server) Start() error {
| <mask> }
<mask>
<mask> // TODO: don't close if interface and addresses are the same
<mask> if s.conn != nil {
<mask> s.closeConn()
<mask> }
<mask>
<mask> iface, err := net.InterfaceByName(s.InterfaceName)
</s> * dhcpd: move code from Start() to Init() </s> remove // Start will listen on port 67 and serve DHCP requests.
// Even though config can be nil, it is not optional (at least for now), since there are no default values (yet).
func (s *Server) Start(config *ServerConfig) error {
if config != nil {
s.ServerConfig = *config
</s> add // Init checks the configuration and initializes the server
func (s *Server) Init(config ServerConfig) error {
err := s.setConfig(config)
if err != nil {
return err </s> remove s.dbLoad()
</s> add iface, err := net.InterfaceByName(s.InterfaceName)
if err != nil {
return wrapErrPrint(err, "Couldn't find interface by name %s", s.InterfaceName)
} </s> remove s.closeConn() // in case it was already started
</s> add </s> remove s.closeConn() // in case it was already started
</s> add | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
iface, err := net.InterfaceByName(s.InterfaceName)
if err != nil {
return wrapErrPrint(err, "Couldn't find interface by name %s", s.InterfaceName)
} | <mask> if s.conn != nil {
<mask> s.closeConn()
<mask> }
<mask>
<mask> s.dbLoad()
<mask>
<mask> c, err := newFilterConn(*iface, ":67") // it has to be bound to 0.0.0.0:67, otherwise it won't see DHCP discover/request packets
<mask> if err != nil {
<mask> return wrapErrPrint(err, "Couldn't start listening socket on 0.0.0.0:67")
<mask> }
</s> * dhcpd: move code from Start() to Init() </s> remove
s.closeConn() // in case it was already started
</s> add </s> remove // Start will listen on port 67 and serve DHCP requests.
// Even though config can be nil, it is not optional (at least for now), since there are no default values (yet).
func (s *Server) Start(config *ServerConfig) error {
if config != nil {
s.ServerConfig = *config
</s> add // Init checks the configuration and initializes the server
func (s *Server) Init(config ServerConfig) error {
err := s.setConfig(config)
if err != nil {
return err </s> remove s.closeConn() // in case it was already started
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d405c0af84d87e3d24b608eb3f7690078ee52ca | dhcpd/dhcpd.go |
if question == nil {
return
}
q, err = question.Pack()
if err != nil {
log.Printf("failed to pack question for querylog: %s", err)
return | <mask> var a []byte
<mask> var err error
<mask> ip := getIPString(addr)
<mask>
<mask> if question != nil {
<mask> q, err = question.Pack()
<mask> if err != nil {
<mask> log.Printf("failed to pack question for querylog: %s", err)
<mask> return
<mask> }
<mask> }
<mask>
<mask> if answer != nil {
<mask> a, err = answer.Pack()
<mask> if err != nil {
</s> * querylog: don't return entries without Question data </s> remove if len(entry.Question) > 0 {
q = new(dns.Msg)
if err := q.Unpack(entry.Question); err != nil {
// ignore, log and move on
log.Printf("Failed to unpack dns message question: %s", err)
q = nil
}
</s> add if len(entry.Question) == 0 {
continue
}
q = new(dns.Msg)
if err := q.Unpack(entry.Question); err != nil {
log.Tracef("q.Unpack(): %s", err)
continue </s> remove // ignore, log and move on
log.Printf("Failed to unpack dns message question: %s", err)
</s> add log.Debug("Failed to unpack dns message answer: %s", err) </s> remove if q != nil {
jsonEntry["question"] = map[string]interface{}{
"host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
"type": dns.Type(q.Question[0].Qtype).String(),
"class": dns.Class(q.Question[0].Qclass).String(),
}
</s> add jsonEntry["question"] = map[string]interface{}{
"host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
"type": dns.Type(q.Question[0].Qtype).String(),
"class": dns.Class(q.Question[0].Qclass).String(), | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d4e95b36d02e8aadfe6cbdd87d357efba6f02e8 | querylog/qlog.go |
if len(entry.Question) == 0 {
continue
}
q = new(dns.Msg)
if err := q.Unpack(entry.Question); err != nil {
log.Tracef("q.Unpack(): %s", err)
continue | <mask> entry := entries[i]
<mask> var q *dns.Msg
<mask> var a *dns.Msg
<mask>
<mask> if len(entry.Question) > 0 {
<mask> q = new(dns.Msg)
<mask> if err := q.Unpack(entry.Question); err != nil {
<mask> // ignore, log and move on
<mask> log.Printf("Failed to unpack dns message question: %s", err)
<mask> q = nil
<mask> }
<mask> }
<mask> if len(entry.Answer) > 0 {
<mask> a = new(dns.Msg)
<mask> if err := a.Unpack(entry.Answer); err != nil {
<mask> // ignore, log and move on
</s> * querylog: don't return entries without Question data </s> remove // ignore, log and move on
log.Printf("Failed to unpack dns message question: %s", err)
</s> add log.Debug("Failed to unpack dns message answer: %s", err) </s> remove if question != nil {
q, err = question.Pack()
if err != nil {
log.Printf("failed to pack question for querylog: %s", err)
return
}
</s> add if question == nil {
return
}
q, err = question.Pack()
if err != nil {
log.Printf("failed to pack question for querylog: %s", err)
return </s> remove if q != nil {
jsonEntry["question"] = map[string]interface{}{
"host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
"type": dns.Type(q.Question[0].Qtype).String(),
"class": dns.Class(q.Question[0].Qclass).String(),
}
</s> add jsonEntry["question"] = map[string]interface{}{
"host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
"type": dns.Type(q.Question[0].Qtype).String(),
"class": dns.Class(q.Question[0].Qclass).String(), | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d4e95b36d02e8aadfe6cbdd87d357efba6f02e8 | querylog/qlog.go |
if len(q.Question) != 1 {
log.Tracef("len(q.Question) != 1")
continue
}
| <mask> if err := q.Unpack(entry.Question); err != nil {
<mask> log.Tracef("q.Unpack(): %s", err)
<mask> continue
<mask> }
<mask> if len(entry.Answer) > 0 {
<mask> a = new(dns.Msg)
<mask> if err := a.Unpack(entry.Answer); err != nil {
<mask> log.Debug("Failed to unpack dns message answer: %s", err)
</s> * querylog: don't return entries without Question data </s> remove if len(entry.Question) > 0 {
q = new(dns.Msg)
if err := q.Unpack(entry.Question); err != nil {
// ignore, log and move on
log.Printf("Failed to unpack dns message question: %s", err)
q = nil
}
</s> add if len(entry.Question) == 0 {
continue
}
q = new(dns.Msg)
if err := q.Unpack(entry.Question); err != nil {
log.Tracef("q.Unpack(): %s", err)
continue </s> remove // ignore, log and move on
log.Printf("Failed to unpack dns message question: %s", err)
</s> add log.Debug("Failed to unpack dns message answer: %s", err) </s> remove if question != nil {
q, err = question.Pack()
if err != nil {
log.Printf("failed to pack question for querylog: %s", err)
return
}
</s> add if question == nil {
return
}
q, err = question.Pack()
if err != nil {
log.Printf("failed to pack question for querylog: %s", err)
return </s> remove if q != nil {
jsonEntry["question"] = map[string]interface{}{
"host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
"type": dns.Type(q.Question[0].Qtype).String(),
"class": dns.Class(q.Question[0].Qclass).String(),
}
</s> add jsonEntry["question"] = map[string]interface{}{
"host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
"type": dns.Type(q.Question[0].Qtype).String(),
"class": dns.Class(q.Question[0].Qclass).String(), | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d4e95b36d02e8aadfe6cbdd87d357efba6f02e8 | querylog/qlog.go |
log.Debug("Failed to unpack dns message answer: %s", err) | <mask> }
<mask> if len(entry.Answer) > 0 {
<mask> a = new(dns.Msg)
<mask> if err := a.Unpack(entry.Answer); err != nil {
<mask> // ignore, log and move on
<mask> log.Printf("Failed to unpack dns message question: %s", err)
<mask> a = nil
<mask> }
<mask> }
<mask>
<mask> jsonEntry := map[string]interface{}{
</s> * querylog: don't return entries without Question data </s> remove if len(entry.Question) > 0 {
q = new(dns.Msg)
if err := q.Unpack(entry.Question); err != nil {
// ignore, log and move on
log.Printf("Failed to unpack dns message question: %s", err)
q = nil
}
</s> add if len(entry.Question) == 0 {
continue
}
q = new(dns.Msg)
if err := q.Unpack(entry.Question); err != nil {
log.Tracef("q.Unpack(): %s", err)
continue </s> remove if question != nil {
q, err = question.Pack()
if err != nil {
log.Printf("failed to pack question for querylog: %s", err)
return
}
</s> add if question == nil {
return
}
q, err = question.Pack()
if err != nil {
log.Printf("failed to pack question for querylog: %s", err)
return </s> remove if q != nil {
jsonEntry["question"] = map[string]interface{}{
"host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
"type": dns.Type(q.Question[0].Qtype).String(),
"class": dns.Class(q.Question[0].Qclass).String(),
}
</s> add jsonEntry["question"] = map[string]interface{}{
"host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
"type": dns.Type(q.Question[0].Qtype).String(),
"class": dns.Class(q.Question[0].Qclass).String(), | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d4e95b36d02e8aadfe6cbdd87d357efba6f02e8 | querylog/qlog.go |
jsonEntry["question"] = map[string]interface{}{
"host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
"type": dns.Type(q.Question[0].Qtype).String(),
"class": dns.Class(q.Question[0].Qclass).String(), | <mask> "elapsedMs": strconv.FormatFloat(entry.Elapsed.Seconds()*1000, 'f', -1, 64),
<mask> "time": entry.Time.Format(time.RFC3339Nano),
<mask> "client": entry.IP,
<mask> }
<mask> if q != nil {
<mask> jsonEntry["question"] = map[string]interface{}{
<mask> "host": strings.ToLower(strings.TrimSuffix(q.Question[0].Name, ".")),
<mask> "type": dns.Type(q.Question[0].Qtype).String(),
<mask> "class": dns.Class(q.Question[0].Qclass).String(),
<mask> }
<mask> }
<mask>
<mask> if a != nil {
<mask> jsonEntry["status"] = dns.RcodeToString[a.Rcode]
<mask> }
</s> * querylog: don't return entries without Question data </s> remove if len(entry.Question) > 0 {
q = new(dns.Msg)
if err := q.Unpack(entry.Question); err != nil {
// ignore, log and move on
log.Printf("Failed to unpack dns message question: %s", err)
q = nil
}
</s> add if len(entry.Question) == 0 {
continue
}
q = new(dns.Msg)
if err := q.Unpack(entry.Question); err != nil {
log.Tracef("q.Unpack(): %s", err)
continue </s> remove // ignore, log and move on
log.Printf("Failed to unpack dns message question: %s", err)
</s> add log.Debug("Failed to unpack dns message answer: %s", err) </s> remove if question != nil {
q, err = question.Pack()
if err != nil {
log.Printf("failed to pack question for querylog: %s", err)
return
}
</s> add if question == nil {
return
}
q, err = question.Pack()
if err != nil {
log.Printf("failed to pack question for querylog: %s", err)
return | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d4e95b36d02e8aadfe6cbdd87d357efba6f02e8 | querylog/qlog.go |
"net" | <mask> import (
<mask> "encoding/json"
<mask> "fmt"
<mask> "io/ioutil"
<mask> "net/http"
<mask> "net/url"
<mask> "os"
<mask> "strings"
<mask> "time"
</s> + GET /filtering/check_host: Check if host name is filtered </s> remove version: '0.99.3'
</s> add version: '0.101' </s> remove httpRegister(http.MethodGet, "/control/filtering/status", handleFilteringStatus)
httpRegister(http.MethodPost, "/control/filtering/config", handleFilteringConfig)
httpRegister(http.MethodPost, "/control/filtering/add_url", handleFilteringAddURL)
httpRegister(http.MethodPost, "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister(http.MethodPost, "/control/filtering/set_url", handleFilteringSetURL)
httpRegister(http.MethodPost, "/control/filtering/refresh", handleFilteringRefresh)
httpRegister(http.MethodPost, "/control/filtering/set_rules", handleFilteringSetRules)
</s> add httpRegister("GET", "/control/filtering/status", handleFilteringStatus)
httpRegister("POST", "/control/filtering/config", handleFilteringConfig)
httpRegister("POST", "/control/filtering/add_url", handleFilteringAddURL)
httpRegister("POST", "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister("POST", "/control/filtering/set_url", handleFilteringSetURL)
httpRegister("POST", "/control/filtering/refresh", handleFilteringRefresh)
httpRegister("POST", "/control/filtering/set_rules", handleFilteringSetRules)
httpRegister("GET", "/control/filtering/check_host", handleCheckHost) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d7c01d50f8efdc55203178cafe091ee07780445 | home/control_filtering.go |
"github.com/miekg/dns" | <mask> "strings"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // IsValidURL - return TRUE if URL is valid
<mask> func IsValidURL(rawurl string) bool {
<mask> url, err := url.ParseRequestURI(rawurl)
</s> + GET /filtering/check_host: Check if host name is filtered </s> remove httpRegister(http.MethodGet, "/control/filtering/status", handleFilteringStatus)
httpRegister(http.MethodPost, "/control/filtering/config", handleFilteringConfig)
httpRegister(http.MethodPost, "/control/filtering/add_url", handleFilteringAddURL)
httpRegister(http.MethodPost, "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister(http.MethodPost, "/control/filtering/set_url", handleFilteringSetURL)
httpRegister(http.MethodPost, "/control/filtering/refresh", handleFilteringRefresh)
httpRegister(http.MethodPost, "/control/filtering/set_rules", handleFilteringSetRules)
</s> add httpRegister("GET", "/control/filtering/status", handleFilteringStatus)
httpRegister("POST", "/control/filtering/config", handleFilteringConfig)
httpRegister("POST", "/control/filtering/add_url", handleFilteringAddURL)
httpRegister("POST", "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister("POST", "/control/filtering/set_url", handleFilteringSetURL)
httpRegister("POST", "/control/filtering/refresh", handleFilteringRefresh)
httpRegister("POST", "/control/filtering/set_rules", handleFilteringSetRules)
httpRegister("GET", "/control/filtering/check_host", handleCheckHost) </s> remove version: '0.99.3'
</s> add version: '0.101' | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d7c01d50f8efdc55203178cafe091ee07780445 | home/control_filtering.go |
httpRegister("GET", "/control/filtering/status", handleFilteringStatus)
httpRegister("POST", "/control/filtering/config", handleFilteringConfig)
httpRegister("POST", "/control/filtering/add_url", handleFilteringAddURL)
httpRegister("POST", "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister("POST", "/control/filtering/set_url", handleFilteringSetURL)
httpRegister("POST", "/control/filtering/refresh", handleFilteringRefresh)
httpRegister("POST", "/control/filtering/set_rules", handleFilteringSetRules)
httpRegister("GET", "/control/filtering/check_host", handleCheckHost) | <mask> }
<mask>
<mask> // RegisterFilteringHandlers - register handlers
<mask> func RegisterFilteringHandlers() {
<mask> httpRegister(http.MethodGet, "/control/filtering/status", handleFilteringStatus)
<mask> httpRegister(http.MethodPost, "/control/filtering/config", handleFilteringConfig)
<mask> httpRegister(http.MethodPost, "/control/filtering/add_url", handleFilteringAddURL)
<mask> httpRegister(http.MethodPost, "/control/filtering/remove_url", handleFilteringRemoveURL)
<mask> httpRegister(http.MethodPost, "/control/filtering/set_url", handleFilteringSetURL)
<mask> httpRegister(http.MethodPost, "/control/filtering/refresh", handleFilteringRefresh)
<mask> httpRegister(http.MethodPost, "/control/filtering/set_rules", handleFilteringSetRules)
<mask> }
<mask>
<mask> func checkFiltersUpdateIntervalHours(i uint32) bool {
<mask> return i == 0 || i == 1 || i == 12 || i == 1*24 || i == 3*24 || i == 7*24
<mask> }
</s> + GET /filtering/check_host: Check if host name is filtered </s> remove version: '0.99.3'
</s> add version: '0.101' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d7c01d50f8efdc55203178cafe091ee07780445 | home/control_filtering.go |
version: '0.101' | <mask> swagger: '2.0'
<mask> info:
<mask> title: 'AdGuard Home'
<mask> description: 'AdGuard Home REST API. Admin web interface is built on top of this REST API.'
<mask> version: '0.99.3'
<mask> schemes:
<mask> - http
<mask> basePath: /control
<mask> produces:
<mask> - application/json
</s> + GET /filtering/check_host: Check if host name is filtered </s> remove httpRegister(http.MethodGet, "/control/filtering/status", handleFilteringStatus)
httpRegister(http.MethodPost, "/control/filtering/config", handleFilteringConfig)
httpRegister(http.MethodPost, "/control/filtering/add_url", handleFilteringAddURL)
httpRegister(http.MethodPost, "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister(http.MethodPost, "/control/filtering/set_url", handleFilteringSetURL)
httpRegister(http.MethodPost, "/control/filtering/refresh", handleFilteringRefresh)
httpRegister(http.MethodPost, "/control/filtering/set_rules", handleFilteringSetRules)
</s> add httpRegister("GET", "/control/filtering/status", handleFilteringStatus)
httpRegister("POST", "/control/filtering/config", handleFilteringConfig)
httpRegister("POST", "/control/filtering/add_url", handleFilteringAddURL)
httpRegister("POST", "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister("POST", "/control/filtering/set_url", handleFilteringSetURL)
httpRegister("POST", "/control/filtering/refresh", handleFilteringRefresh)
httpRegister("POST", "/control/filtering/set_rules", handleFilteringSetRules)
httpRegister("GET", "/control/filtering/check_host", handleCheckHost) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d7c01d50f8efdc55203178cafe091ee07780445 | openapi/openapi.yaml |
/filtering/check_host:
get:
tags:
- filtering
operationId: filteringCheckHost
summary: 'Check if host name is filtered'
parameters:
- name: name
in: query
type: string
responses:
200:
description: OK
schema:
$ref: "#/definitions/FilterCheckHostResponse"
| <mask> description: OK
<mask>
<mask> # --------------------------------------------------
<mask> # Safebrowsing methods
<mask> # --------------------------------------------------
<mask>
<mask> /safebrowsing/enable:
</s> + GET /filtering/check_host: Check if host name is filtered </s> remove version: '0.99.3'
</s> add version: '0.101' </s> remove httpRegister(http.MethodGet, "/control/filtering/status", handleFilteringStatus)
httpRegister(http.MethodPost, "/control/filtering/config", handleFilteringConfig)
httpRegister(http.MethodPost, "/control/filtering/add_url", handleFilteringAddURL)
httpRegister(http.MethodPost, "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister(http.MethodPost, "/control/filtering/set_url", handleFilteringSetURL)
httpRegister(http.MethodPost, "/control/filtering/refresh", handleFilteringRefresh)
httpRegister(http.MethodPost, "/control/filtering/set_rules", handleFilteringSetRules)
</s> add httpRegister("GET", "/control/filtering/status", handleFilteringStatus)
httpRegister("POST", "/control/filtering/config", handleFilteringConfig)
httpRegister("POST", "/control/filtering/add_url", handleFilteringAddURL)
httpRegister("POST", "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister("POST", "/control/filtering/set_url", handleFilteringSetURL)
httpRegister("POST", "/control/filtering/refresh", handleFilteringRefresh)
httpRegister("POST", "/control/filtering/set_rules", handleFilteringSetRules)
httpRegister("GET", "/control/filtering/check_host", handleCheckHost) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d7c01d50f8efdc55203178cafe091ee07780445 | openapi/openapi.yaml |
- "ReasonRewrite" | <mask> - "FilteredParental"
<mask> - "FilteredInvalid"
<mask> - "FilteredSafeSearch"
<mask> - "FilteredBlockedService"
<mask> service_name:
<mask> type: "string"
<mask> description: "Set if reason=FilteredBlockedService"
<mask> status:
<mask> type: "string"
<mask> description: "DNS response status"
</s> + GET /filtering/check_host: Check if host name is filtered </s> remove version: '0.99.3'
</s> add version: '0.101' </s> remove httpRegister(http.MethodGet, "/control/filtering/status", handleFilteringStatus)
httpRegister(http.MethodPost, "/control/filtering/config", handleFilteringConfig)
httpRegister(http.MethodPost, "/control/filtering/add_url", handleFilteringAddURL)
httpRegister(http.MethodPost, "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister(http.MethodPost, "/control/filtering/set_url", handleFilteringSetURL)
httpRegister(http.MethodPost, "/control/filtering/refresh", handleFilteringRefresh)
httpRegister(http.MethodPost, "/control/filtering/set_rules", handleFilteringSetRules)
</s> add httpRegister("GET", "/control/filtering/status", handleFilteringStatus)
httpRegister("POST", "/control/filtering/config", handleFilteringConfig)
httpRegister("POST", "/control/filtering/add_url", handleFilteringAddURL)
httpRegister("POST", "/control/filtering/remove_url", handleFilteringRemoveURL)
httpRegister("POST", "/control/filtering/set_url", handleFilteringSetURL)
httpRegister("POST", "/control/filtering/refresh", handleFilteringRefresh)
httpRegister("POST", "/control/filtering/set_rules", handleFilteringSetRules)
httpRegister("GET", "/control/filtering/check_host", handleCheckHost) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0d7c01d50f8efdc55203178cafe091ee07780445 | openapi/openapi.yaml |
var clientObjects []clientObject | <mask> func (clients *clientsContainer) WriteDiskConfig(objects *[]clientObject) {
<mask> clients.lock.Lock()
<mask> defer clients.lock.Unlock()
<mask>
<mask> clientObjects := []clientObject{}
<mask> for _, cli := range clients.list {
<mask> cy := clientObject{
<mask> Name: cli.Name,
<mask> UseGlobalSettings: !cli.UseOwnSettings,
<mask> FilteringEnabled: cli.FilteringEnabled,
</s> all: doc changes, imp names </s> remove cy := clientObject{
</s> add cliObj := clientObject{ </s> remove // above loop can generate different orderings when writing to the
// config file: this produces lots of diffs in config files, so sort
// objects by name before writing.
</s> add // above loop can generate different orderings when writing to the config
// file: this produces lots of diffs in config files, so sort objects by
// name before writing. </s> remove clientObjects = append(clientObjects, cy)
</s> add clientObjects = append(clientObjects, cliObj) </s> remove cy.Tags = stringutil.CloneSlice(cli.Tags)
cy.IDs = stringutil.CloneSlice(cli.IDs)
cy.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
cy.Upstreams = stringutil.CloneSlice(cli.Upstreams)
</s> add cliObj.Tags = stringutil.CloneSlice(cli.Tags)
cliObj.IDs = stringutil.CloneSlice(cli.IDs)
cliObj.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
cliObj.Upstreams = stringutil.CloneSlice(cli.Upstreams) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e1015a4ee7f4101ef21cb2b2688beb50a11dc83 | internal/home/clients.go |
cliObj := clientObject{ | <mask> defer clients.lock.Unlock()
<mask>
<mask> clientObjects := []clientObject{}
<mask> for _, cli := range clients.list {
<mask> cy := clientObject{
<mask> Name: cli.Name,
<mask> UseGlobalSettings: !cli.UseOwnSettings,
<mask> FilteringEnabled: cli.FilteringEnabled,
<mask> ParentalEnabled: cli.ParentalEnabled,
<mask> SafeSearchEnabled: cli.SafeSearchEnabled,
</s> all: doc changes, imp names </s> remove clientObjects := []clientObject{}
</s> add var clientObjects []clientObject </s> remove // above loop can generate different orderings when writing to the
// config file: this produces lots of diffs in config files, so sort
// objects by name before writing.
</s> add // above loop can generate different orderings when writing to the config
// file: this produces lots of diffs in config files, so sort objects by
// name before writing. </s> remove clientObjects = append(clientObjects, cy)
</s> add clientObjects = append(clientObjects, cliObj) </s> remove cy.Tags = stringutil.CloneSlice(cli.Tags)
cy.IDs = stringutil.CloneSlice(cli.IDs)
cy.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
cy.Upstreams = stringutil.CloneSlice(cli.Upstreams)
</s> add cliObj.Tags = stringutil.CloneSlice(cli.Tags)
cliObj.IDs = stringutil.CloneSlice(cli.IDs)
cliObj.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
cliObj.Upstreams = stringutil.CloneSlice(cli.Upstreams) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e1015a4ee7f4101ef21cb2b2688beb50a11dc83 | internal/home/clients.go |
cliObj.Tags = stringutil.CloneSlice(cli.Tags)
cliObj.IDs = stringutil.CloneSlice(cli.IDs)
cliObj.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
cliObj.Upstreams = stringutil.CloneSlice(cli.Upstreams) | <mask> SafeBrowsingEnabled: cli.SafeBrowsingEnabled,
<mask> UseGlobalBlockedServices: !cli.UseOwnBlockedServices,
<mask> }
<mask>
<mask> cy.Tags = stringutil.CloneSlice(cli.Tags)
<mask> cy.IDs = stringutil.CloneSlice(cli.IDs)
<mask> cy.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
<mask> cy.Upstreams = stringutil.CloneSlice(cli.Upstreams)
<mask>
<mask> clientObjects = append(clientObjects, cy)
<mask> }
<mask>
<mask> // Maps aren't guaranteed to iterate in the same order each time, so the
</s> all: doc changes, imp names </s> remove clientObjects = append(clientObjects, cy)
</s> add clientObjects = append(clientObjects, cliObj) </s> remove // above loop can generate different orderings when writing to the
// config file: this produces lots of diffs in config files, so sort
// objects by name before writing.
</s> add // above loop can generate different orderings when writing to the config
// file: this produces lots of diffs in config files, so sort objects by
// name before writing. </s> remove clientObjects := []clientObject{}
</s> add var clientObjects []clientObject </s> remove cy := clientObject{
</s> add cliObj := clientObject{ | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e1015a4ee7f4101ef21cb2b2688beb50a11dc83 | internal/home/clients.go |
clientObjects = append(clientObjects, cliObj) | <mask> cy.IDs = stringutil.CloneSlice(cli.IDs)
<mask> cy.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
<mask> cy.Upstreams = stringutil.CloneSlice(cli.Upstreams)
<mask>
<mask> clientObjects = append(clientObjects, cy)
<mask> }
<mask>
<mask> // Maps aren't guaranteed to iterate in the same order each time, so the
<mask> // above loop can generate different orderings when writing to the
<mask> // config file: this produces lots of diffs in config files, so sort
</s> all: doc changes, imp names </s> remove // above loop can generate different orderings when writing to the
// config file: this produces lots of diffs in config files, so sort
// objects by name before writing.
</s> add // above loop can generate different orderings when writing to the config
// file: this produces lots of diffs in config files, so sort objects by
// name before writing. </s> remove cy.Tags = stringutil.CloneSlice(cli.Tags)
cy.IDs = stringutil.CloneSlice(cli.IDs)
cy.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
cy.Upstreams = stringutil.CloneSlice(cli.Upstreams)
</s> add cliObj.Tags = stringutil.CloneSlice(cli.Tags)
cliObj.IDs = stringutil.CloneSlice(cli.IDs)
cliObj.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
cliObj.Upstreams = stringutil.CloneSlice(cli.Upstreams) </s> remove clientObjects := []clientObject{}
</s> add var clientObjects []clientObject </s> remove cy := clientObject{
</s> add cliObj := clientObject{ | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e1015a4ee7f4101ef21cb2b2688beb50a11dc83 | internal/home/clients.go |
// above loop can generate different orderings when writing to the config
// file: this produces lots of diffs in config files, so sort objects by
// name before writing. | <mask> clientObjects = append(clientObjects, cy)
<mask> }
<mask>
<mask> // Maps aren't guaranteed to iterate in the same order each time, so the
<mask> // above loop can generate different orderings when writing to the
<mask> // config file: this produces lots of diffs in config files, so sort
<mask> // objects by name before writing.
<mask> sort.Slice(clientObjects, func(i, j int) bool {
<mask> return clientObjects[i].Name < clientObjects[j].Name
<mask> })
<mask> *objects = append(*objects, clientObjects...)
<mask> }
</s> all: doc changes, imp names </s> remove clientObjects = append(clientObjects, cy)
</s> add clientObjects = append(clientObjects, cliObj) </s> remove cy.Tags = stringutil.CloneSlice(cli.Tags)
cy.IDs = stringutil.CloneSlice(cli.IDs)
cy.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
cy.Upstreams = stringutil.CloneSlice(cli.Upstreams)
</s> add cliObj.Tags = stringutil.CloneSlice(cli.Tags)
cliObj.IDs = stringutil.CloneSlice(cli.IDs)
cliObj.BlockedServices = stringutil.CloneSlice(cli.BlockedServices)
cliObj.Upstreams = stringutil.CloneSlice(cli.Upstreams) </s> remove clientObjects := []clientObject{}
</s> add var clientObjects []clientObject </s> remove cy := clientObject{
</s> add cliObj := clientObject{ | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e1015a4ee7f4101ef21cb2b2688beb50a11dc83 | internal/home/clients.go |
<mask>
<mask> // configure log level and output
<mask> configureLogger(args)
<mask>
<mask> // Go memory hacks
<mask> memoryUsage(args)
<mask>
<mask> // Print the first message after logger is configured.
<mask> log.Println(version.Full())
<mask> log.Debug("current working directory is %s", Context.workDir)
<mask> if args.runningAsService {
<mask> log.Info("AdGuard Home is running as a service")
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove // disableMemoryOptimization - disables memory optimization hacks
// see memoryUsage() function for the details
disableMemoryOptimization bool
</s> add </s> remove nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
</s> add nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, </s> remove assert.False(t, testParseOK(t).disableMemoryOptimization, "empty is not disable update")
assert.True(t, testParseOK(t, "--no-mem-optimization").disableMemoryOptimization, "--no-mem-optimization is disable update")
</s> add o, eff, err := parse("", []string{"--no-mem-optimization"})
require.NoError(t, err)
assert.Nil(t, eff)
assert.Zero(t, o) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/home.go |
|
"github.com/AdguardTeam/golibs/log" | <mask> "strconv"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/version"
<mask> )
<mask>
<mask> // options passed from command-line arguments
<mask> type options struct {
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove // disableMemoryOptimization - disables memory optimization hacks
// see memoryUsage() function for the details
disableMemoryOptimization bool
</s> add </s> remove const reportFmt = "expected %s but got %s"
</s> add </s> remove // Go memory hacks
memoryUsage(args)
</s> add </s> remove }, {
name: "disable_mem_opt",
opts: options{disableMemoryOptimization: true},
ss: []string{"--no-mem-optimization"},
</s> add | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options.go |
<mask>
<mask> // runningAsService flag is set to true when options are passed from the service runner
<mask> runningAsService bool
<mask>
<mask> // disableMemoryOptimization - disables memory optimization hacks
<mask> // see memoryUsage() function for the details
<mask> disableMemoryOptimization bool
<mask>
<mask> glinetMode bool // Activate GL-Inet compatibility mode
<mask>
<mask> // noEtcHosts flag should be provided when /etc/hosts file shouldn't be
<mask> // used.
<mask> noEtcHosts bool
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove // Go memory hacks
memoryUsage(args)
</s> add </s> remove nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
</s> add nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, </s> remove assert.False(t, testParseOK(t).disableMemoryOptimization, "empty is not disable update")
assert.True(t, testParseOK(t, "--no-mem-optimization").disableMemoryOptimization, "--no-mem-optimization is disable update")
</s> add o, eff, err := parse("", []string{"--no-mem-optimization"})
require.NoError(t, err)
assert.Nil(t, eff)
assert.Zero(t, o) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options.go |
|
nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, | <mask>
<mask> var disableMemoryOptimizationArg = arg{
<mask> "Disable memory optimization.",
<mask> "no-mem-optimization", "",
<mask> nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
<mask> func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
<mask> }
<mask>
<mask> var verboseArg = arg{
<mask> "Enable verbose output.",
<mask> "verbose", "v",
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove const reportFmt = "expected %s but got %s"
</s> add </s> remove }, {
name: "disable_mem_opt",
opts: options{disableMemoryOptimization: true},
ss: []string{"--no-mem-optimization"},
</s> add </s> remove assert.False(t, testParseOK(t).disableMemoryOptimization, "empty is not disable update")
assert.True(t, testParseOK(t, "--no-mem-optimization").disableMemoryOptimization, "--no-mem-optimization is disable update")
</s> add o, eff, err := parse("", []string{"--no-mem-optimization"})
require.NoError(t, err)
assert.Nil(t, eff)
assert.Zero(t, o) </s> remove "--no-mem-optimization",
</s> add </s> remove serviceControlAction: "run",
configFilename: "config",
workDir: "work",
pidFile: "pid",
disableUpdate: true,
disableMemoryOptimization: true,
</s> add serviceControlAction: "run",
configFilename: "config",
workDir: "work",
pidFile: "pid",
disableUpdate: true, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options.go |
// TODO(e.burkov): Remove after v0.108.0. | <mask> assert.False(t, testParseOK(t).disableUpdate, "empty is not disable update")
<mask> assert.True(t, testParseOK(t, "--no-check-update").disableUpdate, "--no-check-update is disable update")
<mask> }
<mask>
<mask> func TestParseDisableMemoryOptimization(t *testing.T) {
<mask> o, eff, err := parse("", []string{"--no-mem-optimization"})
<mask> require.NoError(t, err)
<mask>
<mask> assert.Nil(t, eff)
<mask> assert.Zero(t, o)
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove assert.False(t, testParseOK(t).disableMemoryOptimization, "empty is not disable update")
assert.True(t, testParseOK(t, "--no-mem-optimization").disableMemoryOptimization, "--no-mem-optimization is disable update")
</s> add o, eff, err := parse("", []string{"--no-mem-optimization"})
require.NoError(t, err)
assert.Nil(t, eff)
assert.Zero(t, o) </s> remove nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
</s> add nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, </s> remove const reportFmt = "expected %s but got %s"
</s> add </s> remove require.Lenf(t, result, len(tc.ss), reportFmt, tc.ss, result)
for i, r := range result {
assert.Equalf(t, tc.ss[i], r, reportFmt, tc.ss, result)
}
</s> add assert.ElementsMatch(t, tc.ss, result) </s> remove "--no-mem-optimization",
</s> add | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options_test.go |
o, eff, err := parse("", []string{"--no-mem-optimization"})
require.NoError(t, err)
assert.Nil(t, eff)
assert.Zero(t, o) | <mask> assert.True(t, testParseOK(t, "--no-check-update").disableUpdate, "--no-check-update is disable update")
<mask> }
<mask>
<mask> func TestParseDisableMemoryOptimization(t *testing.T) {
<mask> assert.False(t, testParseOK(t).disableMemoryOptimization, "empty is not disable update")
<mask> assert.True(t, testParseOK(t, "--no-mem-optimization").disableMemoryOptimization, "--no-mem-optimization is disable update")
<mask> }
<mask>
<mask> func TestParseService(t *testing.T) {
<mask> assert.Equal(t, "", testParseOK(t).serviceControlAction, "empty is not service cmd")
<mask> assert.Equal(t, "cmd", testParseOK(t, "-s", "cmd").serviceControlAction, "-s is service cmd")
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove const reportFmt = "expected %s but got %s"
</s> add </s> remove nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
</s> add nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, </s> remove "--no-mem-optimization",
</s> add </s> remove // disableMemoryOptimization - disables memory optimization hacks
// see memoryUsage() function for the details
disableMemoryOptimization bool
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options_test.go |
<mask> testParseErr(t, "unknown dash", "-")
<mask> }
<mask>
<mask> func TestSerialize(t *testing.T) {
<mask> const reportFmt = "expected %s but got %s"
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> opts options
<mask> ss []string
<mask> }{{
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
</s> add nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, </s> remove require.Lenf(t, result, len(tc.ss), reportFmt, tc.ss, result)
for i, r := range result {
assert.Equalf(t, tc.ss[i], r, reportFmt, tc.ss, result)
}
</s> add assert.ElementsMatch(t, tc.ss, result) </s> remove "--no-mem-optimization",
</s> add </s> remove assert.False(t, testParseOK(t).disableMemoryOptimization, "empty is not disable update")
assert.True(t, testParseOK(t, "--no-mem-optimization").disableMemoryOptimization, "--no-mem-optimization is disable update")
</s> add o, eff, err := parse("", []string{"--no-mem-optimization"})
require.NoError(t, err)
assert.Nil(t, eff)
assert.Zero(t, o) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options_test.go |
|
<mask> }, {
<mask> name: "glinet_mode",
<mask> opts: options{glinetMode: true},
<mask> ss: []string{"--glinet"},
<mask> }, {
<mask> name: "disable_mem_opt",
<mask> opts: options{disableMemoryOptimization: true},
<mask> ss: []string{"--no-mem-optimization"},
<mask> }, {
<mask> name: "multiple",
<mask> opts: options{
<mask> serviceControlAction: "run",
<mask> configFilename: "config",
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove serviceControlAction: "run",
configFilename: "config",
workDir: "work",
pidFile: "pid",
disableUpdate: true,
disableMemoryOptimization: true,
</s> add serviceControlAction: "run",
configFilename: "config",
workDir: "work",
pidFile: "pid",
disableUpdate: true, </s> remove "--no-mem-optimization",
</s> add </s> remove nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
</s> add nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, </s> remove require.Lenf(t, result, len(tc.ss), reportFmt, tc.ss, result)
for i, r := range result {
assert.Equalf(t, tc.ss[i], r, reportFmt, tc.ss, result)
}
</s> add assert.ElementsMatch(t, tc.ss, result) </s> remove const reportFmt = "expected %s but got %s"
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options_test.go |
|
serviceControlAction: "run",
configFilename: "config",
workDir: "work",
pidFile: "pid",
disableUpdate: true, | <mask> ss: []string{"--no-mem-optimization"},
<mask> }, {
<mask> name: "multiple",
<mask> opts: options{
<mask> serviceControlAction: "run",
<mask> configFilename: "config",
<mask> workDir: "work",
<mask> pidFile: "pid",
<mask> disableUpdate: true,
<mask> disableMemoryOptimization: true,
<mask> },
<mask> ss: []string{
<mask> "-c", "config",
<mask> "-w", "work",
<mask> "-s", "run",
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove }, {
name: "disable_mem_opt",
opts: options{disableMemoryOptimization: true},
ss: []string{"--no-mem-optimization"},
</s> add </s> remove "--no-mem-optimization",
</s> add </s> remove nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
</s> add nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, </s> remove assert.False(t, testParseOK(t).disableMemoryOptimization, "empty is not disable update")
assert.True(t, testParseOK(t, "--no-mem-optimization").disableMemoryOptimization, "--no-mem-optimization is disable update")
</s> add o, eff, err := parse("", []string{"--no-mem-optimization"})
require.NoError(t, err)
assert.Nil(t, eff)
assert.Zero(t, o) </s> remove require.Lenf(t, result, len(tc.ss), reportFmt, tc.ss, result)
for i, r := range result {
assert.Equalf(t, tc.ss[i], r, reportFmt, tc.ss, result)
}
</s> add assert.ElementsMatch(t, tc.ss, result) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options_test.go |
<mask> "-w", "work",
<mask> "-s", "run",
<mask> "--pidfile", "pid",
<mask> "--no-check-update",
<mask> "--no-mem-optimization",
<mask> },
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove require.Lenf(t, result, len(tc.ss), reportFmt, tc.ss, result)
for i, r := range result {
assert.Equalf(t, tc.ss[i], r, reportFmt, tc.ss, result)
}
</s> add assert.ElementsMatch(t, tc.ss, result) </s> remove serviceControlAction: "run",
configFilename: "config",
workDir: "work",
pidFile: "pid",
disableUpdate: true,
disableMemoryOptimization: true,
</s> add serviceControlAction: "run",
configFilename: "config",
workDir: "work",
pidFile: "pid",
disableUpdate: true, </s> remove }, {
name: "disable_mem_opt",
opts: options{disableMemoryOptimization: true},
ss: []string{"--no-mem-optimization"},
</s> add </s> remove const reportFmt = "expected %s but got %s"
</s> add </s> remove nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
</s> add nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options_test.go |
|
assert.ElementsMatch(t, tc.ss, result) | <mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> result := serialize(tc.opts)
<mask> require.Lenf(t, result, len(tc.ss), reportFmt, tc.ss, result)
<mask>
<mask> for i, r := range result {
<mask> assert.Equalf(t, tc.ss[i], r, reportFmt, tc.ss, result)
<mask> }
<mask> })
<mask> }
<mask> }
</s> Pull request: 4437 depr memory opt
Merge in DNS/adguard-home from 4437-rm-mem-opt to master
Updates #4437.
Updates #2044.
Squashed commit of the following:
commit d1e5520213f6b68570d18a8d831d4923112901ba
Merge: 73a6b494 8bb95469
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 19:37:09 2022 +0300
Merge branch 'master' into 4437-rm-mem-opt
commit 73a6b4948cb32f1cb79a54b244018b29382fad76
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:33:23 2022 +0300
all: imp log of changes
commit a62efcdcd44de300726c906c7f6198c0a02d4ccf
Author: Eugene Burkov <[email protected]>
Date: Wed Apr 6 18:27:42 2022 +0300
home: depr memory opt </s> remove "--no-mem-optimization",
</s> add </s> remove const reportFmt = "expected %s but got %s"
</s> add </s> remove assert.False(t, testParseOK(t).disableMemoryOptimization, "empty is not disable update")
assert.True(t, testParseOK(t, "--no-mem-optimization").disableMemoryOptimization, "--no-mem-optimization is disable update")
</s> add o, eff, err := parse("", []string{"--no-mem-optimization"})
require.NoError(t, err)
assert.Nil(t, eff)
assert.Zero(t, o) </s> remove nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
</s> add nil, nil, func(_ options, _ string) (f effect, err error) {
log.Info("warning: using --no-mem-optimization flag has no effect and is deprecated")
return nil, nil
},
func(o options) []string { return nil }, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e608fda1367c33e8da1b8fc28029f45b3d69fab | internal/home/options_test.go |
# Ignore everything except for explicitly allowed stuff.
*
!dist/docker | <mask> .DS_Store
<mask> /.git
<mask> /.github
<mask> /.vscode
<mask> .idea
<mask> /AdGuardHome
<mask> /AdGuardHome.exe
<mask> /AdGuardHome.yaml
<mask> /AdGuardHome.log
<mask> /data
<mask> /build
<mask> /build2
<mask> /dist
<mask> /client/node_modules
<mask> /client2/node_modules
<mask> /.gitattributes
<mask> /.gitignore
<mask> /.goreleaser.yml
<mask> /changelog.config.js
<mask> /coverage.txt
<mask> /Dockerfile
<mask> /LICENSE.txt
<mask> /Makefile
<mask> /querylog.json
<mask> /querylog.json.1
<mask> /*.md
<mask>
<mask> # Test output
<mask> dnsfilter/tests/top-1m.csv
<mask> dnsfilter/tests/dnsfilter.TestLotsOfRules*.pprof
<mask>
<mask> # Snapcraft build temporary files
<mask> *.snap
<mask> launchpad_credentials
<mask> snapcraft_login
<mask> snapcraft.yaml.bak
<mask>
<mask> # IntelliJ IDEA project files
<mask> *.iml
<mask>
<mask> # Packr
<mask> *-packr.go
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release </s> remove # Available targets
</s> add # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
.POSIX:
CHANNEL = development
CLIENT_BETA_DIR = client2
CLIENT_DIR = client
COMMIT = $$(git rev-parse --short HEAD)
DIST_DIR = dist
GO = go
# TODO(a.garipov): Add more default proxies using pipes after update to
# Go 1.15. </s> remove - 'app'
- 'docker'
</s> add - 'build-release' | [
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .dockerignore |
'run': 'make VERBOSE=1 ci' | <mask> 'key': "${{ runner.os }}-node-${{ hashFiles('client/package-lock.json') }}"
<mask> 'restore-keys': '${{ runner.os }}-node-'
<mask> - 'name': 'Run make ci'
<mask> 'shell': 'bash'
<mask> 'run': 'make ci'
<mask> - 'name': 'Upload coverage'
<mask> 'uses': 'codecov/codecov-action@v1'
<mask> 'if': "success() && matrix.os == 'ubuntu-latest'"
<mask> 'with':
<mask> 'token': '${{ secrets.CODECOV_TOKEN }}'
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove - 'name': 'Set up GoReleaser'
'run': 'curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | BINDIR="$(go env GOPATH)/bin" sh'
- 'name': 'Run snapshot build'
'run': 'make release'
'docker':
'runs-on': 'ubuntu-latest'
'needs': 'test'
'steps':
- 'name': 'Checkout'
'uses': 'actions/checkout@v2'
'with':
'fetch-depth': 0
</s> add </s> remove 'app':
</s> add 'build-release': </s> remove 'run': 'npm --prefix client ci'
</s> add 'run': 'npm --prefix="./client" ci' </s> remove 'fields': 'repo, message, commit, author, job'
</s> add 'fields': 'repo, message, commit, author, workflow' </s> remove 'fields': 'repo, message, commit, author, job'
</s> add 'fields': 'repo, message, commit, author, workflow' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/build.yml |
'build-release': | <mask> 'if': "success() && matrix.os == 'ubuntu-latest'"
<mask> 'with':
<mask> 'token': '${{ secrets.CODECOV_TOKEN }}'
<mask> 'file': './coverage.txt'
<mask> 'app':
<mask> 'runs-on': 'ubuntu-latest'
<mask> 'needs': 'test'
<mask> 'steps':
<mask> - 'name': 'Checkout'
<mask> 'uses': 'actions/checkout@v2'
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove 'run': 'make ci'
</s> add 'run': 'make VERBOSE=1 ci' </s> remove - 'name': 'Set up GoReleaser'
'run': 'curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | BINDIR="$(go env GOPATH)/bin" sh'
- 'name': 'Run snapshot build'
'run': 'make release'
'docker':
'runs-on': 'ubuntu-latest'
'needs': 'test'
'steps':
- 'name': 'Checkout'
'uses': 'actions/checkout@v2'
'with':
'fetch-depth': 0
</s> add </s> remove make go-install-tools go-lint
</s> add make go-deps go-tools go-lint </s> remove 'run': 'npm --prefix client ci'
</s> add 'run': 'npm --prefix="./client" ci' </s> remove 'fields': 'repo, message, commit, author, job'
</s> add 'fields': 'repo, message, commit, author, workflow' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/build.yml |
<mask> 'key': "${{ runner.os }}-node-${{ hashFiles('client/package-lock.json') }}"
<mask> 'restore-keys': '${{ runner.os }}-node-'
<mask> - 'name': 'Set up Snapcraft'
<mask> 'run': 'sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft'
<mask> - 'name': 'Set up GoReleaser'
<mask> 'run': 'curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | BINDIR="$(go env GOPATH)/bin" sh'
<mask> - 'name': 'Run snapshot build'
<mask> 'run': 'make release'
<mask>
<mask> 'docker':
<mask> 'runs-on': 'ubuntu-latest'
<mask> 'needs': 'test'
<mask> 'steps':
<mask> - 'name': 'Checkout'
<mask> 'uses': 'actions/checkout@v2'
<mask> 'with':
<mask> 'fetch-depth': 0
<mask> - 'name': 'Set up QEMU'
<mask> 'uses': 'docker/setup-qemu-action@v1'
<mask> - 'name': 'Set up Docker Buildx'
<mask> 'uses': 'docker/setup-buildx-action@v1'
<mask> - 'name': 'Docker Buildx (build)'
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove - 'name': 'Docker Buildx (build)'
'run': 'make docker-multi-arch'
</s> add - 'name': 'Run snapshot build'
'run': 'make SIGN=0 VERBOSE=1 js-deps js-build build-release build-docker' </s> remove 'run': 'make ci'
</s> add 'run': 'make VERBOSE=1 ci' </s> remove 'app':
</s> add 'build-release': </s> remove 'run': 'npm --prefix client ci'
</s> add 'run': 'npm --prefix="./client" ci' </s> remove make go-install-tools go-lint
</s> add make go-deps go-tools go-lint | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/build.yml |
|
- 'name': 'Run snapshot build'
'run': 'make SIGN=0 VERBOSE=1 js-deps js-build build-release build-docker' | <mask> - 'name': 'Set up QEMU'
<mask> 'uses': 'docker/setup-qemu-action@v1'
<mask> - 'name': 'Set up Docker Buildx'
<mask> 'uses': 'docker/setup-buildx-action@v1'
<mask> - 'name': 'Docker Buildx (build)'
<mask> 'run': 'make docker-multi-arch'
<mask>
<mask> 'notify':
<mask> 'needs':
<mask> - 'app'
<mask> - 'docker'
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove - 'name': 'Set up GoReleaser'
'run': 'curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | BINDIR="$(go env GOPATH)/bin" sh'
- 'name': 'Run snapshot build'
'run': 'make release'
'docker':
'runs-on': 'ubuntu-latest'
'needs': 'test'
'steps':
- 'name': 'Checkout'
'uses': 'actions/checkout@v2'
'with':
'fetch-depth': 0
</s> add </s> remove - 'app'
- 'docker'
</s> add - 'build-release' </s> remove 'run': 'npm --prefix client ci'
</s> add 'run': 'npm --prefix="./client" ci' </s> remove 'run': 'npm --prefix client run lint'
</s> add 'run': 'npm --prefix="./client" run lint' </s> remove 'run': 'make ci'
</s> add 'run': 'make VERBOSE=1 ci' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/build.yml |
- 'build-release' | <mask> 'run': 'make docker-multi-arch'
<mask>
<mask> 'notify':
<mask> 'needs':
<mask> - 'app'
<mask> - 'docker'
<mask> # Secrets are not passed to workflows that are triggered by a pull request
<mask> # from a fork.
<mask> #
<mask> # Use always() to signal to the runner that this job must run even if the
<mask> # previous ones failed.
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove 'run': 'npm --prefix client run lint'
</s> add 'run': 'npm --prefix="./client" run lint' </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove - 'name': 'Docker Buildx (build)'
'run': 'make docker-multi-arch'
</s> add - 'name': 'Run snapshot build'
'run': 'make SIGN=0 VERBOSE=1 js-deps js-build build-release build-docker' </s> remove # Available targets
</s> add # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
.POSIX:
CHANNEL = development
CLIENT_BETA_DIR = client2
CLIENT_DIR = client
COMMIT = $$(git rev-parse --short HEAD)
DIST_DIR = dist
GO = go
# TODO(a.garipov): Add more default proxies using pipes after update to
# Go 1.15. </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/build.yml |
'fields': 'repo, message, commit, author, workflow' | <mask> - 'name': 'Send Slack notif'
<mask> 'uses': '8398a7/action-slack@v3'
<mask> 'with':
<mask> 'status': '${{ env.WORKFLOW_CONCLUSION }}'
<mask> 'fields': 'repo, message, commit, author, job'
<mask> 'env':
<mask> 'GITHUB_TOKEN': '${{ secrets.GITHUB_TOKEN }}'
<mask> 'SLACK_WEBHOOK_URL': '${{ secrets.SLACK_WEBHOOK_URL }}'
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove 'fields': 'repo, message, commit, author, job'
</s> add 'fields': 'repo, message, commit, author, workflow' </s> remove 'run': 'make ci'
</s> add 'run': 'make VERBOSE=1 ci' </s> remove 'app':
</s> add 'build-release': </s> remove - 'name': 'Set up GoReleaser'
'run': 'curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | BINDIR="$(go env GOPATH)/bin" sh'
- 'name': 'Run snapshot build'
'run': 'make release'
'docker':
'runs-on': 'ubuntu-latest'
'needs': 'test'
'steps':
- 'name': 'Checkout'
'uses': 'actions/checkout@v2'
'with':
'fetch-depth': 0
</s> add </s> remove - 'name': 'Docker Buildx (build)'
'run': 'make docker-multi-arch'
</s> add - 'name': 'Run snapshot build'
'run': 'make SIGN=0 VERBOSE=1 js-deps js-build build-release build-docker' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/build.yml |
make go-deps go-tools go-lint | <mask> 'steps':
<mask> - 'uses': 'actions/checkout@v2'
<mask> - 'name': 'run-lint'
<mask> 'run': >
<mask> make go-install-tools go-lint
<mask> 'eslint':
<mask> 'runs-on': 'ubuntu-latest'
<mask> 'steps':
<mask> - 'uses': 'actions/checkout@v2'
<mask> - 'name': 'Install modules'
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove 'run': 'npm --prefix client ci'
</s> add 'run': 'npm --prefix="./client" ci' </s> remove - 'name': 'Set up GoReleaser'
'run': 'curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | BINDIR="$(go env GOPATH)/bin" sh'
- 'name': 'Run snapshot build'
'run': 'make release'
'docker':
'runs-on': 'ubuntu-latest'
'needs': 'test'
'steps':
- 'name': 'Checkout'
'uses': 'actions/checkout@v2'
'with':
'fetch-depth': 0
</s> add </s> remove 'app':
</s> add 'build-release': </s> remove 'run': 'npm --prefix client run lint'
</s> add 'run': 'npm --prefix="./client" run lint' </s> remove - 'name': 'Docker Buildx (build)'
'run': 'make docker-multi-arch'
</s> add - 'name': 'Run snapshot build'
'run': 'make SIGN=0 VERBOSE=1 js-deps js-build build-release build-docker' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/lint.yml |
'run': 'npm --prefix="./client" ci' | <mask> 'runs-on': 'ubuntu-latest'
<mask> 'steps':
<mask> - 'uses': 'actions/checkout@v2'
<mask> - 'name': 'Install modules'
<mask> 'run': 'npm --prefix client ci'
<mask> - 'name': 'Run ESLint'
<mask> 'run': 'npm --prefix client run lint'
<mask> 'notify':
<mask> 'needs':
<mask> - 'go-lint'
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove 'run': 'npm --prefix client run lint'
</s> add 'run': 'npm --prefix="./client" run lint' </s> remove make go-install-tools go-lint
</s> add make go-deps go-tools go-lint </s> remove - 'name': 'Set up GoReleaser'
'run': 'curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | BINDIR="$(go env GOPATH)/bin" sh'
- 'name': 'Run snapshot build'
'run': 'make release'
'docker':
'runs-on': 'ubuntu-latest'
'needs': 'test'
'steps':
- 'name': 'Checkout'
'uses': 'actions/checkout@v2'
'with':
'fetch-depth': 0
</s> add </s> remove 'app':
</s> add 'build-release': </s> remove - 'name': 'Docker Buildx (build)'
'run': 'make docker-multi-arch'
</s> add - 'name': 'Run snapshot build'
'run': 'make SIGN=0 VERBOSE=1 js-deps js-build build-release build-docker' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/lint.yml |
'run': 'npm --prefix="./client" run lint' | <mask> - 'uses': 'actions/checkout@v2'
<mask> - 'name': 'Install modules'
<mask> 'run': 'npm --prefix client ci'
<mask> - 'name': 'Run ESLint'
<mask> 'run': 'npm --prefix client run lint'
<mask> 'notify':
<mask> 'needs':
<mask> - 'go-lint'
<mask> - 'eslint'
<mask> # Secrets are not passed to workflows that are triggered by a pull request
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove 'run': 'npm --prefix client ci'
</s> add 'run': 'npm --prefix="./client" ci' </s> remove - 'app'
- 'docker'
</s> add - 'build-release' </s> remove make go-install-tools go-lint
</s> add make go-deps go-tools go-lint </s> remove - 'name': 'Docker Buildx (build)'
'run': 'make docker-multi-arch'
</s> add - 'name': 'Run snapshot build'
'run': 'make SIGN=0 VERBOSE=1 js-deps js-build build-release build-docker' </s> remove 'run': 'make ci'
</s> add 'run': 'make VERBOSE=1 ci' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/lint.yml |
'fields': 'repo, message, commit, author, workflow' | <mask> - 'name': 'Send Slack notif'
<mask> 'uses': '8398a7/action-slack@v3'
<mask> 'with':
<mask> 'status': '${{ env.WORKFLOW_CONCLUSION }}'
<mask> 'fields': 'repo, message, commit, author, job'
<mask> 'env':
<mask> 'GITHUB_TOKEN': '${{ secrets.GITHUB_TOKEN }}'
<mask> 'SLACK_WEBHOOK_URL': '${{ secrets.SLACK_WEBHOOK_URL }}'
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | .github/workflows/lint.yml |
# See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
.POSIX:
CHANNEL = development
CLIENT_BETA_DIR = client2
CLIENT_DIR = client
COMMIT = $$(git rev-parse --short HEAD)
DIST_DIR = dist
GO = go
# TODO(a.garipov): Add more default proxies using pipes after update to
# Go 1.15. | <mask> #
<mask> # Available targets
<mask> #
<mask> # * build -- builds AdGuardHome for the current platform
<mask> # * client -- builds client-side code of AdGuard Home
<mask> # * client-watch -- builds client-side code of AdGuard Home and watches for changes there
<mask> # * docker -- builds a docker image for the current platform
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release </s> remove .DS_Store
/.git
/.github
/.vscode
.idea
/AdGuardHome
/AdGuardHome.exe
/AdGuardHome.yaml
/AdGuardHome.log
/data
/build
/build2
/dist
/client/node_modules
/client2/node_modules
/.gitattributes
/.gitignore
/.goreleaser.yml
/changelog.config.js
/coverage.txt
/Dockerfile
/LICENSE.txt
/Makefile
/querylog.json
/querylog.json.1
/*.md
# Test output
dnsfilter/tests/top-1m.csv
dnsfilter/tests/dnsfilter.TestLotsOfRules*.pprof
# Snapcraft build temporary files
*.snap
launchpad_credentials
snapcraft_login
snapcraft.yaml.bak
# IntelliJ IDEA project files
*.iml
# Packr
*-packr.go
</s> add # Ignore everything except for explicitly allowed stuff.
*
!dist/docker </s> remove npm --prefix client ci
yarn --cwd client2 install
$(GO) mod download
clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/
</s> add @ echo "use make deps instead"
@ $(MAKE) deps | [
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | Makefile |
# GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps | <mask> #
<mask> # Available targets
<mask> #
<mask> # * build -- builds AdGuardHome for the current platform
<mask> # * client -- builds client-side code of AdGuard Home
<mask> # * client-watch -- builds client-side code of AdGuard Home and watches for changes there
<mask> # * docker -- builds a docker image for the current platform
<mask> # * clean -- clean everything created by previous builds
<mask> # * lint -- run all linters
<mask> # * test -- run all unit-tests
<mask> # * dependencies -- installs dependencies (go and npm modules)
<mask> # * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
<mask> #
<mask> # Building releases:
<mask> #
<mask> # * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
<mask> # * release_and_sign -- builds AdGuard Home distros and signs the binary files.
<mask> # CHANNEL must be specified (edge, release or beta).
<mask> # * sign -- Repacks all release archive files and signs the binary files inside them.
<mask> # For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
<mask> # gpg --import public.txt
<mask> # gpg --import private.txt
<mask> # GPG_KEY_PASSPHRASE must contain the GPG key passphrase
<mask> # * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
<mask> # you must specify:
<mask> # * DOCKER_IMAGE_NAME - adguard/adguard-home
<mask> # * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
<mask>
<mask> GO := go
<mask> GOPATH := $(shell $(GO) env GOPATH)
<mask> PWD := $(shell pwd)
<mask> TARGET=AdGuardHome
<mask> BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
<mask> GPG_KEY := [email protected]
<mask> GPG_KEY_PASSPHRASE :=
<mask> GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
<mask> VERBOSE := -v
<mask> REBUILD_CLIENT = 1
<mask>
<mask> # See release target
<mask> DIST_DIR=dist
<mask>
<mask> # Update channel. Can be release, beta or edge. Uses edge by default.
<mask> CHANNEL ?= edge
<mask>
<mask> # Validate channel
<mask> ifneq ($(CHANNEL),release)
<mask> ifneq ($(CHANNEL),beta)
<mask> ifneq ($(CHANNEL),edge)
<mask> $(error CHANNEL value is not valid. Valid values are release,beta or edge)
<mask> endif
<mask> endif
<mask> endif
<mask>
<mask> # Version history URL (see
<mask> VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
<mask> ifeq ($(CHANNEL),edge)
<mask> VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
<mask> endif
<mask>
<mask> # goreleaser command depends on the $CHANNEL
<mask> GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
<mask> ifneq ($(CHANNEL),edge)
<mask> # If this is not an "edge" build, use normal release command
<mask> GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
<mask> endif
<mask>
<mask> # Version properties
<mask> COMMIT=$(shell git rev-parse --short HEAD)
<mask> TAG_NAME=$(shell git describe --abbrev=0)
<mask> PRERELEASE_VERSION=$(shell git describe --abbrev=0)
<mask> # TODO(a.garipov): The cut call is a temporary solution to trim
<mask> # prerelease versions. See the comment in .goreleaser.yml.
<mask> RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
<mask> SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
<mask>
<mask> # Set proper version
<mask> VERSION=
<mask> ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
<mask> ifeq ($(CHANNEL),edge)
<mask> VERSION=$(SNAPSHOT_VERSION)
<mask> else ifeq ($(CHANNEL),beta)
<mask> VERSION=$(PRERELEASE_VERSION)
<mask> else
<mask> VERSION=$(RELEASE_VERSION)
<mask> endif
<mask> else
<mask> VERSION=$(SNAPSHOT_VERSION)
<mask> endif
<mask>
<mask> # Docker target parameters
<mask> DOCKER_IMAGE_NAME ?= adguardhome-dev
<mask> DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
<mask> DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
<mask> DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
<mask> BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
<mask>
<mask> # Docker tags (can be redefined)
<mask> DOCKER_TAGS ?=
<mask> ifndef DOCKER_TAGS
<mask> ifeq ($(CHANNEL),release)
<mask> DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
<mask> endif
<mask> ifeq ($(CHANNEL),beta)
<mask> DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
<mask> endif
<mask> ifeq ($(CHANNEL),edge)
<mask> # Don't set the version tag when pushing to "edge"
<mask> DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
<mask> # DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
<mask> endif
<mask> endif
<mask>
<mask> # Validate docker build arguments
<mask> ifndef DOCKER_IMAGE_NAME
<mask> $(error DOCKER_IMAGE_NAME value is not set)
<mask> endif
<mask>
<mask> # OS-specific flags
<mask> TEST_FLAGS := --race $(VERBOSE)
<mask> ifeq ($(OS),Windows_NT)
<mask> TEST_FLAGS :=
<mask> endif
<mask>
<mask> .PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
<mask> all: build
<mask>
<mask> init:
<mask> git config core.hooksPath .githooks
<mask>
<mask> build:
<mask> test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
<mask> $(GO) mod download
<mask> PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
<mask> CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
<mask> PATH=$(GOPATH)/bin:$(PATH) packr clean
<mask>
<mask> client:
<mask> npm --prefix client run build-prod
<mask> yarn --cwd client2 build
<mask>
<mask> client_with_deps:
<mask> npm --prefix client ci
<mask> npm --prefix client run build-prod
<mask> yarn --cwd client2 build
<mask>
<mask> client-watch:
<mask> npm --prefix client run watch
<mask> yarn --cwd client2 start
<mask>
<mask> docker:
<mask> DOCKER_CLI_EXPERIMENTAL=enabled \
<mask> docker buildx build \
<mask> --build-arg VERSION=$(VERSION) \
<mask> --build-arg CHANNEL=$(CHANNEL) \
<mask> --build-arg VCS_REF=$(COMMIT) \
<mask> --build-arg BUILD_DATE=$(BUILD_DATE) \
<mask> $(DOCKER_TAGS) \
<mask> --load \
<mask> -t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
<mask>
<mask> @echo Now you can run the docker image:
<mask> @echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
<mask>
<mask> lint: js-lint go-lint
<mask>
<mask> js-lint: dependencies
<mask> npm --prefix client run lint
<mask> yarn --cwd client2 lint
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove # Available targets
</s> add # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
.POSIX:
CHANNEL = development
CLIENT_BETA_DIR = client2
CLIENT_DIR = client
COMMIT = $$(git rev-parse --short HEAD)
DIST_DIR = dist
GO = go
# TODO(a.garipov): Add more default proxies using pipes after update to
# Go 1.15. </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release </s> remove npm --prefix client ci
yarn --cwd client2 install
$(GO) mod download
clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/
</s> add @ echo "use make deps instead"
@ $(MAKE) deps </s> remove
js-lint: dependencies
npm --prefix client run lint
yarn --cwd client2 lint
go-install-tools:
env GO=$(GO) sh ./scripts/go-install-tools.sh
go-lint:
env GO=$(GO) PATH="$$PWD/bin:$$PATH" sh ./scripts/go-lint.sh
</s> add </s> remove - 'app'
- 'docker'
</s> add - 'build-release' | [
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | Makefile |
<mask> @echo Now you can run the docker image:
<mask> @echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
<mask>
<mask> lint: js-lint go-lint
<mask>
<mask> js-lint: dependencies
<mask> npm --prefix client run lint
<mask> yarn --cwd client2 lint
<mask>
<mask> go-install-tools:
<mask> env GO=$(GO) sh ./scripts/go-install-tools.sh
<mask>
<mask> go-lint:
<mask> env GO=$(GO) PATH="$$PWD/bin:$$PATH" sh ./scripts/go-lint.sh
<mask>
<mask> test: js-test go-test
<mask>
<mask> js-test:
<mask> npm run test --prefix client
<mask>
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove npm run test --prefix client
go-test:
$(GO) test $(TEST_FLAGS) --coverprofile coverage.txt ./...
</s> add $(NPM) $(NPM_FLAGS) run test </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release </s> remove npm --prefix client ci
yarn --cwd client2 install
$(GO) mod download
clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/
</s> add @ echo "use make deps instead"
@ $(MAKE) deps </s> remove ci: client_with_deps
$(GO) mod download
$(MAKE) test
</s> add go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
go-test: ; $(ENV) "$(SHELL)" ./scripts/make/go-test.sh
go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | Makefile |
|
$(NPM) $(NPM_FLAGS) run test | <mask>
<mask> test: js-test go-test
<mask>
<mask> js-test:
<mask> npm run test --prefix client
<mask>
<mask> go-test:
<mask> $(GO) test $(TEST_FLAGS) --coverprofile coverage.txt ./...
<mask>
<mask> ci: client_with_deps
<mask> $(GO) mod download
<mask> $(MAKE) test
<mask>
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove ci: client_with_deps
$(GO) mod download
$(MAKE) test
</s> add go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
go-test: ; $(ENV) "$(SHELL)" ./scripts/make/go-test.sh
go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh </s> remove
js-lint: dependencies
npm --prefix client run lint
yarn --cwd client2 lint
go-install-tools:
env GO=$(GO) sh ./scripts/go-install-tools.sh
go-lint:
env GO=$(GO) PATH="$$PWD/bin:$$PATH" sh ./scripts/go-lint.sh
</s> add </s> remove npm --prefix client ci
yarn --cwd client2 install
$(GO) mod download
clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/
</s> add @ echo "use make deps instead"
@ $(MAKE) deps </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | Makefile |
go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
go-test: ; $(ENV) "$(SHELL)" ./scripts/make/go-test.sh
go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh | <mask>
<mask> go-test:
<mask> $(GO) test $(TEST_FLAGS) --coverprofile coverage.txt ./...
<mask>
<mask> ci: client_with_deps
<mask> $(GO) mod download
<mask> $(MAKE) test
<mask>
<mask> dependencies:
<mask> npm --prefix client ci
<mask> yarn --cwd client2 install
<mask> $(GO) mod download
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove npm run test --prefix client
go-test:
$(GO) test $(TEST_FLAGS) --coverprofile coverage.txt ./...
</s> add $(NPM) $(NPM_FLAGS) run test </s> remove npm --prefix client ci
yarn --cwd client2 install
$(GO) mod download
clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/
</s> add @ echo "use make deps instead"
@ $(MAKE) deps </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove
js-lint: dependencies
npm --prefix client run lint
yarn --cwd client2 lint
go-install-tools:
env GO=$(GO) sh ./scripts/go-install-tools.sh
go-lint:
env GO=$(GO) PATH="$$PWD/bin:$$PATH" sh ./scripts/go-lint.sh
</s> add </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | Makefile |
# TODO(a.garipov): Remove the legacy targets once the build
# infrastructure stops using them. | <mask> go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh
<mask>
<mask> dependencies:
<mask> @ echo "use make deps instead"
<mask> @ $(MAKE) deps
<mask> docker-multi-arch:
<mask> @ echo "use make build-docker instead"
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove npm --prefix client ci
yarn --cwd client2 install
$(GO) mod download
clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/
</s> add @ echo "use make deps instead"
@ $(MAKE) deps </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release </s> remove ci: client_with_deps
$(GO) mod download
$(MAKE) test
</s> add go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
go-test: ; $(ENV) "$(SHELL)" ./scripts/make/go-test.sh
go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh </s> remove make go-install-tools go-lint
</s> add make go-deps go-tools go-lint </s> remove 'run': 'make ci'
</s> add 'run': 'make VERBOSE=1 ci' | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | Makefile |
@ echo "use make deps instead"
@ $(MAKE) deps | <mask> $(GO) mod download
<mask> $(MAKE) test
<mask>
<mask> dependencies:
<mask> npm --prefix client ci
<mask> yarn --cwd client2 install
<mask> $(GO) mod download
<mask>
<mask> clean:
<mask> rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
<mask> rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
<mask> # Set the GOPATH explicitly in case make clean is called from under sudo
<mask> # after a Docker build.
<mask> env PATH="$(GOPATH)/bin:$$PATH" packr clean
<mask> rm -f -r ./bin/
<mask>
<mask> docker-multi-arch:
<mask> DOCKER_CLI_EXPERIMENTAL=enabled \
<mask> docker buildx build \
<mask> --platform $(DOCKER_PLATFORMS) \
<mask> --build-arg VERSION=$(VERSION) \
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove ci: client_with_deps
$(GO) mod download
$(MAKE) test
</s> add go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
go-test: ; $(ENV) "$(SHELL)" ./scripts/make/go-test.sh
go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh </s> remove npm run test --prefix client
go-test:
$(GO) test $(TEST_FLAGS) --coverprofile coverage.txt ./...
</s> add $(NPM) $(NPM_FLAGS) run test </s> remove
js-lint: dependencies
npm --prefix client run lint
yarn --cwd client2 lint
go-install-tools:
env GO=$(GO) sh ./scripts/go-install-tools.sh
go-lint:
env GO=$(GO) PATH="$$PWD/bin:$$PATH" sh ./scripts/go-lint.sh
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | Makefile |
@ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release | <mask> env PATH="$(GOPATH)/bin:$$PATH" packr clean
<mask> rm -f -r ./bin/
<mask>
<mask> docker-multi-arch:
<mask> DOCKER_CLI_EXPERIMENTAL=enabled \
<mask> docker buildx build \
<mask> --platform $(DOCKER_PLATFORMS) \
<mask> --build-arg VERSION=$(VERSION) \
<mask> --build-arg CHANNEL=$(CHANNEL) \
<mask> --build-arg VCS_REF=$(COMMIT) \
<mask> --build-arg BUILD_DATE=$(BUILD_DATE) \
<mask> $(DOCKER_TAGS) \
<mask> --output "$(DOCKER_OUTPUT)" \
<mask> -t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
<mask>
<mask> @echo If the image was pushed to the registry, you can now run it:
<mask> @echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
<mask>
<mask> release: client_with_deps
<mask> $(GO) mod download
<mask> @echo Starting release build: version $(VERSION), channel $(CHANNEL)
<mask> CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
<mask> $(call write_version_file,$(VERSION))
<mask> PATH=$(GOPATH)/bin:$(PATH) packr clean
<mask>
<mask> release_and_sign: client_with_deps
<mask> $(MAKE) release
<mask> $(call repack_dist)
<mask>
<mask> sign:
<mask> $(call repack_dist)
<mask>
<mask> define write_version_file
<mask> $(eval version := $(1))
<mask>
<mask> @echo Writing version file: $(version)
<mask>
<mask> # Variables for CI
<mask> rm -f $(DIST_DIR)/version.txt
<mask> echo "version=$(version)" > $(DIST_DIR)/version.txt
<mask>
<mask> # Prepare the version.json file
<mask> rm -f $(DIST_DIR)/version.json
<mask> echo "{" >> $(DIST_DIR)/version.json
<mask> echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
<mask> echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
<mask> echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
<mask> echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
<mask>
<mask> # Windows builds
<mask> echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
<mask>
<mask> # MacOS builds
<mask> echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
<mask>
<mask> # Linux
<mask> echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
<mask>
<mask> # Linux, all kinds of ARM
<mask> echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
<mask>
<mask> # Linux, MIPS
<mask> echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
<mask>
<mask> # FreeBSD
<mask> echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
<mask>
<mask> # FreeBSD, all kinds of ARM
<mask> echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
<mask> echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
<mask>
<mask> # Finish
<mask> echo "}" >> $(DIST_DIR)/version.json
<mask> endef
<mask>
<mask> define repack_dist
<mask> # Repack archive files
<mask> # A temporary solution for our auto-update code to be able to unpack these archive files
<mask> # The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
<mask> # and we can't create it
<mask> rm -rf $(DIST_DIR)/AdGuardHome
<mask>
<mask> # Windows builds
<mask> $(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
<mask> $(call zip_repack_windows,AdGuardHome_windows_386.zip)
<mask>
<mask> # MacOS builds
<mask> $(call zip_repack,AdGuardHome_darwin_amd64.zip)
<mask> $(call zip_repack,AdGuardHome_darwin_386.zip)
<mask>
<mask> # Linux
<mask> $(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
<mask> $(call tar_repack,AdGuardHome_linux_386.tar.gz)
<mask>
<mask> # Linux, all kinds of ARM
<mask> $(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
<mask> $(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
<mask> $(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
<mask> $(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
<mask>
<mask> # Linux, MIPS
<mask> $(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
<mask> $(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
<mask> $(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
<mask> $(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
<mask>
<mask> # FreeBSD
<mask> $(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
<mask> $(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
<mask>
<mask> # FreeBSD, all kinds of ARM
<mask> $(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
<mask> $(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
<mask> $(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
<mask> $(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
<mask> endef
<mask>
<mask> define zip_repack_windows
<mask> $(eval ARC := $(1))
<mask> cd $(DIST_DIR) && \
<mask> unzip $(ARC) && \
<mask> $(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
<mask> zip -r $(ARC) AdGuardHome/ && \
<mask> rm -rf AdGuardHome
<mask> endef
<mask>
<mask> define zip_repack
<mask> $(eval ARC := $(1))
<mask> cd $(DIST_DIR) && \
<mask> unzip $(ARC) && \
<mask> $(GPG_CMD) AdGuardHome/AdGuardHome && \
<mask> zip -r $(ARC) AdGuardHome/ && \
<mask> rm -rf AdGuardHome
<mask> endef
<mask>
<mask> define tar_repack
<mask> $(eval ARC := $(1))
<mask> cd $(DIST_DIR) && \
<mask> tar xzf $(ARC) && \
<mask> $(GPG_CMD) AdGuardHome/AdGuardHome && \
<mask> tar czf $(ARC) AdGuardHome/ && \
<mask> rm -rf AdGuardHome
<mask> endef
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove npm --prefix client ci
yarn --cwd client2 install
$(GO) mod download
clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/
</s> add @ echo "use make deps instead"
@ $(MAKE) deps </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove # Available targets
</s> add # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
.POSIX:
CHANNEL = development
CLIENT_BETA_DIR = client2
CLIENT_DIR = client
COMMIT = $$(git rev-parse --short HEAD)
DIST_DIR = dist
GO = go
# TODO(a.garipov): Add more default proxies using pipes after update to
# Go 1.15. </s> remove
js-lint: dependencies
npm --prefix client run lint
yarn --cwd client2 lint
go-install-tools:
env GO=$(GO) sh ./scripts/go-install-tools.sh
go-lint:
env GO=$(GO) PATH="$$PWD/bin:$$PATH" sh ./scripts/go-lint.sh
</s> add | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | Makefile |
<mask> //go:generate go install -v github.com/gobuffalo/packr/packr
<mask> //go:generate packr clean
<mask> //go:generate packr -z
<mask> package main
<mask>
<mask> import (
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove npm --prefix client ci
yarn --cwd client2 install
$(GO) mod download
clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/
</s> add @ echo "use make deps instead"
@ $(MAKE) deps </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--output "$(DOCKER_OUTPUT)" \
-t "$(DOCKER_IMAGE_FULL_NAME)" -f ./Dockerfile .
@echo If the image was pushed to the registry, you can now run it:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
release: client_with_deps
$(GO) mod download
@echo Starting release build: version $(VERSION), channel $(CHANNEL)
CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
$(call write_version_file,$(VERSION))
PATH=$(GOPATH)/bin:$(PATH) packr clean
release_and_sign: client_with_deps
$(MAKE) release
$(call repack_dist)
sign:
$(call repack_dist)
define write_version_file
$(eval version := $(1))
@echo Writing version file: $(version)
# Variables for CI
rm -f $(DIST_DIR)/version.txt
echo "version=$(version)" > $(DIST_DIR)/version.txt
# Prepare the version.json file
rm -f $(DIST_DIR)/version.json
echo "{" >> $(DIST_DIR)/version.json
echo " \"version\": \"$(version)\"," >> $(DIST_DIR)/version.json
echo " \"announcement\": \"AdGuard Home $(version) is now available!\"," >> $(DIST_DIR)/version.json
echo " \"announcement_url\": \"$(VERSION_HISTORY_URL)\"," >> $(DIST_DIR)/version.json
echo " \"selfupdate_min_version\": \"0.0\"," >> $(DIST_DIR)/version.json
# Windows builds
echo " \"download_windows_amd64\": \"$(BASE_URL)/AdGuardHome_windows_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_windows_386\": \"$(BASE_URL)/AdGuardHome_windows_386.zip\"," >> $(DIST_DIR)/version.json
# MacOS builds
echo " \"download_darwin_amd64\": \"$(BASE_URL)/AdGuardHome_darwin_amd64.zip\"," >> $(DIST_DIR)/version.json
echo " \"download_darwin_386\": \"$(BASE_URL)/AdGuardHome_darwin_386.zip\"," >> $(DIST_DIR)/version.json
# Linux
echo " \"download_linux_amd64\": \"$(BASE_URL)/AdGuardHome_linux_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_386\": \"$(BASE_URL)/AdGuardHome_linux_386.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, all kinds of ARM
echo " \"download_linux_arm\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv5\": \"$(BASE_URL)/AdGuardHome_linux_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv6\": \"$(BASE_URL)/AdGuardHome_linux_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_armv7\": \"$(BASE_URL)/AdGuardHome_linux_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_arm64\": \"$(BASE_URL)/AdGuardHome_linux_arm64.tar.gz\"," >> $(DIST_DIR)/version.json
# Linux, MIPS
echo " \"download_linux_mips\": \"$(BASE_URL)/AdGuardHome_linux_mips_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mipsle\": \"$(BASE_URL)/AdGuardHome_linux_mipsle_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64\": \"$(BASE_URL)/AdGuardHome_linux_mips64_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_linux_mips64le\": \"$(BASE_URL)/AdGuardHome_linux_mips64le_softfloat.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD
echo " \"download_freebsd_386\": \"$(BASE_URL)/AdGuardHome_freebsd_386.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_amd64\": \"$(BASE_URL)/AdGuardHome_freebsd_amd64.tar.gz\"," >> $(DIST_DIR)/version.json
# FreeBSD, all kinds of ARM
echo " \"download_freebsd_arm\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv5\": \"$(BASE_URL)/AdGuardHome_freebsd_armv5.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv6\": \"$(BASE_URL)/AdGuardHome_freebsd_armv6.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_armv7\": \"$(BASE_URL)/AdGuardHome_freebsd_armv7.tar.gz\"," >> $(DIST_DIR)/version.json
echo " \"download_freebsd_arm64\": \"$(BASE_URL)/AdGuardHome_freebsd_arm64.tar.gz\"" >> $(DIST_DIR)/version.json
# Finish
echo "}" >> $(DIST_DIR)/version.json
endef
define repack_dist
# Repack archive files
# A temporary solution for our auto-update code to be able to unpack these archive files
# The problem is that goreleaser doesn't add directory AdGuardHome/ to the archive file
# and we can't create it
rm -rf $(DIST_DIR)/AdGuardHome
# Windows builds
$(call zip_repack_windows,AdGuardHome_windows_amd64.zip)
$(call zip_repack_windows,AdGuardHome_windows_386.zip)
# MacOS builds
$(call zip_repack,AdGuardHome_darwin_amd64.zip)
$(call zip_repack,AdGuardHome_darwin_386.zip)
# Linux
$(call tar_repack,AdGuardHome_linux_amd64.tar.gz)
$(call tar_repack,AdGuardHome_linux_386.tar.gz)
# Linux, all kinds of ARM
$(call tar_repack,AdGuardHome_linux_armv5.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv6.tar.gz)
$(call tar_repack,AdGuardHome_linux_armv7.tar.gz)
$(call tar_repack,AdGuardHome_linux_arm64.tar.gz)
# Linux, MIPS
$(call tar_repack,AdGuardHome_linux_mips_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mipsle_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64_softfloat.tar.gz)
$(call tar_repack,AdGuardHome_linux_mips64le_softfloat.tar.gz)
# FreeBSD
$(call tar_repack,AdGuardHome_freebsd_386.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_amd64.tar.gz)
# FreeBSD, all kinds of ARM
$(call tar_repack,AdGuardHome_freebsd_armv5.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv6.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_armv7.tar.gz)
$(call tar_repack,AdGuardHome_freebsd_arm64.tar.gz)
endef
define zip_repack_windows
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome.exe && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define zip_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
unzip $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
zip -r $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
define tar_repack
$(eval ARC := $(1))
cd $(DIST_DIR) && \
tar xzf $(ARC) && \
$(GPG_CMD) AdGuardHome/AdGuardHome && \
tar czf $(ARC) AdGuardHome/ && \
rm -rf AdGuardHome
endef
</s> add @ echo "use make build-docker instead"
@ $(MAKE) build-docker
go-install-tools:
@ echo "use make go-tools instead"
@ $(MAKE) go-tools
release:
@ echo "use make build-release instead"
@ $(MAKE) build-release </s> remove # Available targets
</s> add # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
.POSIX:
CHANNEL = development
CLIENT_BETA_DIR = client2
CLIENT_DIR = client
COMMIT = $$(git rev-parse --short HEAD)
DIST_DIR = dist
GO = go
# TODO(a.garipov): Add more default proxies using pipes after update to
# Go 1.15. </s> remove ci: client_with_deps
$(GO) mod download
$(MAKE) test
</s> add go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
go-test: ; $(ENV) "$(SHELL)" ./scripts/make/go-test.sh
go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh | [
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | main.go |
|
<mask> // goarm is the GOARM value. It is set by the linker.
<mask> var goarm = ""
<mask>
<mask> // gomips is the GOMIPS value. It is set by the linker.
<mask> //
<mask> // TODO(a.garipov): Implement.
<mask> var gomips = ""
<mask>
<mask> func main() {
<mask> home.Main(version, channel, goarm, gomips)
<mask> }
</s> Pull request: all: add a new Makefile and scripts, remove goreleaaser
Merge in DNS/adguard-home from 2276-releases to master
Updates #2276.
Squashed commit of the following:
commit 84961947c51477aae53606ec6e2e0cce0bdfc139
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:36:13 2020 +0300
all: fix github build
commit 54af2adbf2f433e80393fb142e66ba6b3a78b13e
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 14:34:02 2020 +0300
all: remove old Dockerfile, improve build scripts
commit 99bb2f2ba1458d32074ac0911b5c02ce6669e43e
Merge: 2292b677a 5e20ac7ed
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:47:19 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 2292b677a20ce8e93d9e6e2bb042cd468606fec3
Author: Ainar Garipov <[email protected]>
Date: Wed Dec 30 13:30:10 2020 +0300
all: improve docker build
commit 0bcc97c41f105ee4a4363f20fa4775c7643bf0cc
Merge: c7d3f12ef aef4659e9
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 17:47:45 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit c7d3f12ef2b63ddfa2acf46e3129fcbc56fb0a90
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 16:28:25 2020 +0300
all: improve build scripts
commit 55de1e5d7ef0fbdbd1a76cfb71362d16ca0a1966
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 15:36:47 2020 +0300
all: fix Makefile
commit d11b1fe28d0fde1efeaf6160a614951b19d0ef94
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 14:16:19 2020 +0300
scripts: fix build-release
commit ecc0577e2451afa86c37da7283a63a9d26fb37ba
Merge: dde64ed8e 483f02c92
Author: Ainar Garipov <[email protected]>
Date: Tue Dec 29 13:59:32 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit dde64ed8e456f73559f21c2ca549dc3b46724add
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 18:04:46 2020 +0300
all: imp docs, other improvements
commit be8574408db79901bb15c1d31916db3ca352a35f
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 14:48:30 2020 +0300
all: imp docker build
commit fc1876f34b93d667bf166226f4bc666d394f10c7
Merge: fa5a304c8 955b735c8
Author: Ainar Garipov <[email protected]>
Date: Fri Dec 25 13:54:29 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit fa5a304c83d86145796a2de4141de6d18f7c56bf
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 19:10:51 2020 +0300
all: improve scripts
commit 3f32e3fd5e658d058d5c5172519384efc6cfef83
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:50:01 2020 +0300
all: improve scripts
commit 2d38b81421acab4b90a7a19da7598c75063e8e93
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:25:21 2020 +0300
all: fix shell for windows, improve go-lint.sh
commit d695285cd6dc476c0d972cfe0c49bbeea5f5a049
Merge: 313b020e9 9fb6bf82c
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:14:38 2020 +0300
Merge branch 'master' into WIP-2276-releases
commit 313b020e9dfcdab736670cee72b2171eac8c32b7
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 18:13:31 2020 +0300
Makefile: use npm ci again
commit 5acee9d6a6c8cd2a7dd04b173a73929650882bad
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:57:54 2020 +0300
all: try fixing windows build
commit c63a2a54641ac8cd032a3306bb35e49b9ae74728
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:39:30 2020 +0300
all: imp scripts, try another goproxy and direct
commit 423229e8b63ee73caeee8e84c23f67d145aff9df
Author: Ainar Garipov <[email protected]>
Date: Thu Dec 24 17:25:29 2020 +0300
all: imp HACKING.md, try a new proxy
... and 1 more commit </s> remove # * build -- builds AdGuardHome for the current platform
# * client -- builds client-side code of AdGuard Home
# * client-watch -- builds client-side code of AdGuard Home and watches for changes there
# * docker -- builds a docker image for the current platform
# * clean -- clean everything created by previous builds
# * lint -- run all linters
# * test -- run all unit-tests
# * dependencies -- installs dependencies (go and npm modules)
# * ci -- installs dependencies, runs linters and tests, intended to be used by CI/CD
#
# Building releases:
#
# * release -- builds AdGuard Home distros. CHANNEL must be specified (edge, release or beta).
# * release_and_sign -- builds AdGuard Home distros and signs the binary files.
# CHANNEL must be specified (edge, release or beta).
# * sign -- Repacks all release archive files and signs the binary files inside them.
# For signing to work, the public+private key pair for $(GPG_KEY) must be imported:
# gpg --import public.txt
# gpg --import private.txt
# GPG_KEY_PASSPHRASE must contain the GPG key passphrase
# * docker-multi-arch -- builds a multi-arch image. If you want it to be pushed to docker hub,
# you must specify:
# * DOCKER_IMAGE_NAME - adguard/adguard-home
# * DOCKER_OUTPUT - type=image,name=adguard/adguard-home,push=true
GO := go
GOPATH := $(shell $(GO) env GOPATH)
PWD := $(shell pwd)
TARGET=AdGuardHome
BASE_URL="https://static.adguard.com/adguardhome/$(CHANNEL)"
GPG_KEY := [email protected]
GPG_KEY_PASSPHRASE :=
GPG_CMD := gpg --detach-sig --default-key $(GPG_KEY) --pinentry-mode loopback --passphrase $(GPG_KEY_PASSPHRASE)
VERBOSE := -v
REBUILD_CLIENT = 1
# See release target
DIST_DIR=dist
# Update channel. Can be release, beta or edge. Uses edge by default.
CHANNEL ?= edge
# Validate channel
ifneq ($(CHANNEL),release)
ifneq ($(CHANNEL),beta)
ifneq ($(CHANNEL),edge)
$(error CHANNEL value is not valid. Valid values are release,beta or edge)
endif
endif
endif
# Version history URL (see
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/releases"
ifeq ($(CHANNEL),edge)
VERSION_HISTORY_URL="https://github.com/AdguardTeam/AdGuardHome/commits/master"
endif
# goreleaser command depends on the $CHANNEL
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
ifneq ($(CHANNEL),edge)
# If this is not an "edge" build, use normal release command
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
endif
# Version properties
COMMIT=$(shell git rev-parse --short HEAD)
TAG_NAME=$(shell git describe --abbrev=0)
PRERELEASE_VERSION=$(shell git describe --abbrev=0)
# TODO(a.garipov): The cut call is a temporary solution to trim
# prerelease versions. See the comment in .goreleaser.yml.
RELEASE_VERSION=$(shell git describe --abbrev=0 | cut -c 1-8)
SNAPSHOT_VERSION=$(RELEASE_VERSION)-SNAPSHOT-$(COMMIT)
# Set proper version
VERSION=
ifeq ($(TAG_NAME),$(shell git describe --abbrev=4))
ifeq ($(CHANNEL),edge)
VERSION=$(SNAPSHOT_VERSION)
else ifeq ($(CHANNEL),beta)
VERSION=$(PRERELEASE_VERSION)
else
VERSION=$(RELEASE_VERSION)
endif
else
VERSION=$(SNAPSHOT_VERSION)
endif
# Docker target parameters
DOCKER_IMAGE_NAME ?= adguardhome-dev
DOCKER_IMAGE_FULL_NAME = $(DOCKER_IMAGE_NAME):$(VERSION)
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le
DOCKER_OUTPUT ?= type=image,name=$(DOCKER_IMAGE_NAME),push=false
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
# Docker tags (can be redefined)
DOCKER_TAGS ?=
ifndef DOCKER_TAGS
ifeq ($(CHANNEL),release)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):latest
endif
ifeq ($(CHANNEL),beta)
DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):beta
endif
ifeq ($(CHANNEL),edge)
# Don't set the version tag when pushing to "edge"
DOCKER_IMAGE_FULL_NAME := $(DOCKER_IMAGE_NAME):edge
# DOCKER_TAGS := --tag $(DOCKER_IMAGE_NAME):edge
endif
endif
# Validate docker build arguments
ifndef DOCKER_IMAGE_NAME
$(error DOCKER_IMAGE_NAME value is not set)
endif
# OS-specific flags
TEST_FLAGS := --race $(VERBOSE)
ifeq ($(OS),Windows_NT)
TEST_FLAGS :=
endif
.PHONY: all build client client-watch docker lint lint-js lint-go test dependencies clean release docker-multi-arch
all: build
init:
git config core.hooksPath .githooks
build:
test '$(REBUILD_CLIENT)' = '1' && $(MAKE) client_with_deps || exit 0
$(GO) mod download
PATH=$(GOPATH)/bin:$(PATH) $(GO) generate ./...
CGO_ENABLED=0 $(GO) build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
PATH=$(GOPATH)/bin:$(PATH) packr clean
client:
npm --prefix client run build-prod
yarn --cwd client2 build
client_with_deps:
npm --prefix client ci
npm --prefix client run build-prod
yarn --cwd client2 build
client-watch:
npm --prefix client run watch
yarn --cwd client2 start
docker:
DOCKER_CLI_EXPERIMENTAL=enabled \
docker buildx build \
--build-arg VERSION=$(VERSION) \
--build-arg CHANNEL=$(CHANNEL) \
--build-arg VCS_REF=$(COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
$(DOCKER_TAGS) \
--load \
-t "$(DOCKER_IMAGE_NAME)" -f ./Dockerfile .
@echo Now you can run the docker image:
@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
</s> add # GOPROXY = https://goproxy.io|https://goproxy.cn|direct
GOPROXY = https://goproxy.cn,https://goproxy.io,direct
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
YARN = yarn
YARN_FLAGS = --cwd $(CLIENT_BETA_DIR)
ENV = env\
COMMIT='$(COMMIT)'\
CHANNEL='$(CHANNEL)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
# Keep the line above blank.
# Keep this target first, so that a naked make invocation triggers
# a full build.
build: deps quick-build
quick-build: js-build go-build
ci: deps test
deps: js-deps go-deps </s> remove # Available targets
</s> add # See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
.POSIX:
CHANNEL = development
CLIENT_BETA_DIR = client2
CLIENT_DIR = client
COMMIT = $$(git rev-parse --short HEAD)
DIST_DIR = dist
GO = go
# TODO(a.garipov): Add more default proxies using pipes after update to
# Go 1.15. </s> remove npm --prefix client ci
yarn --cwd client2 install
$(GO) mod download
clean:
rm -f ./AdGuardHome ./AdGuardHome.exe ./coverage.txt
rm -f -r ./build/ ./client/node_modules/ ./data/ ./$(DIST_DIR)/
# Set the GOPATH explicitly in case make clean is called from under sudo
# after a Docker build.
env PATH="$(GOPATH)/bin:$$PATH" packr clean
rm -f -r ./bin/
</s> add @ echo "use make deps instead"
@ $(MAKE) deps </s> remove - 'app'
- 'docker'
</s> add - 'build-release' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e84962fde7bbb430d4c23e1d7582bfcf173dcb5 | main.go |
|
"access_settings_saved": "Access settings successfully saved",
"updates_checked": "Updates successfully checked",
"check_updates_now": "Check updates now" | <mask> "access_disallowed_title": "Disallowed clients",
<mask> "access_disallowed_desc": "A list of CIDR or IP addresses. If configured, AdGuard Home will drop requests from these IP addresses.",
<mask> "access_blocked_title": "Blocked domains",
<mask> "access_blocked_desc": "Don't confuse this with filters. AdGuard Home will drop DNS queries with these domains in query's question.",
<mask> "access_settings_saved": "Access settings successfully saved"
<mask> } </s> + client: add button for check updates </s> remove function Version(props) {
const { dnsVersion, dnsAddresses, dnsPort } = props;
</s> add const Version = (props) => {
const {
dnsVersion, dnsAddresses, dnsPort, processingVersion, t,
} = props;
</s> remove { ...this.props.dashboard }
</s> add { ...dashboard }
getVersion={getVersion} </s> remove .card-refresh {
height: 26px;
width: 26px;
background-size: 14px;
background-position: center;
background-repeat: no-repeat;
background-image: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiBzdHJva2U9IiM0NjdmY2YiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtMjMgNHY2aC02Ii8+PHBhdGggZD0ibTEgMjB2LTZoNiIvPjxwYXRoIGQ9Im0zLjUxIDlhOSA5IDAgMCAxIDE0Ljg1LTMuMzZsNC42NCA0LjM2bS0yMiA0IDQuNjQgNC4zNmE5IDkgMCAwIDAgMTQuODUtMy4zNiIvPjwvc3ZnPg==");
}
.card-refresh:hover,
.card-refresh:not(:disabled):not(.disabled):active,
.card-refresh:focus:active {
background-image: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI0IiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtMjMgNHY2aC02Ii8+PHBhdGggZD0ibTEgMjB2LTZoNiIvPjxwYXRoIGQ9Im0zLjUxIDlhOSA5IDAgMCAxIDE0Ljg1LTMuMzZsNC42NCA0LjM2bS0yMiA0IDQuNjQgNC4zNmE5IDkgMCAwIDAgMTQuODUtMy4zNiIvPjwvc3ZnPg==");
}
</s> add </s> remove getGlobalVersion() {
</s> add getGlobalVersion(data) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/0e9df33a409dbffeb2d5d45b7f31f30587a2e4f7 | client/src/__locales/en.json |
Subsets and Splits