docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
listlengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
setts := &FilteringSettings{
<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) <mask> ipv4p2 := net.IPv4(127, 0, 0, 2) </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove _, err := d.checkSafeBrowsing("smthng.com") assert.NotNil(t, err) </s> add setts := &FilteringSettings{ SafeBrowsingEnabled: true, ParentalEnabled: true, } _, err := d.checkSafeBrowsing("smthng.com", dns.TypeA, setts) assert.Error(t, err) </s> remove res, err := tc.testFunc(hostname) require.Nil(t, err) </s> add res, err := tc.testFunc(hostname, dns.TypeA, setts) require.NoError(t, err) </s> remove setts = RequestFilteringSettings{ </s> add setts = FilteringSettings{ </s> remove res := Result{ </s> add res = Result{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/dnsrewrite_test.go
// TODO(a.garipov): Unify with checkParental. func (d *DNSFilter) checkSafeBrowsing( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeBrowsingEnabled { return Result{}, nil }
<mask> <mask> return Result{}, nil <mask> } <mask> <mask> func (d *DNSFilter) checkSafeBrowsing(host string) (Result, error) { <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("SafeBrowsing lookup for %s", host) <mask> } <mask> ctx := &sbCtx{ </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove func (d *DNSFilter) checkParental(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkSafeBrowsing. func (d *DNSFilter) checkParental( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.ParentalEnabled { return Result{}, nil } </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove func (d *DNSFilter) checkSafeSearch(host string) (Result, error) { </s> add func (d *DNSFilter) checkSafeSearch( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeSearchEnabled { return Result{}, nil } </s> remove return check(ctx, res, d.safeBrowsingUpstream) </s> add return check(sctx, res, d.safeBrowsingUpstream)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing.go
sctx := &sbCtx{
<mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("SafeBrowsing lookup for %s", host) <mask> } <mask> ctx := &sbCtx{ <mask> host: host, <mask> svc: "SafeBrowsing", <mask> cache: gctx.safebrowsingCache, <mask> cacheTime: d.Config.CacheTime, <mask> } </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove func (d *DNSFilter) checkSafeBrowsing(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkParental. func (d *DNSFilter) checkSafeBrowsing( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeBrowsingEnabled { return Result{}, nil } </s> remove func (d *DNSFilter) checkParental(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkSafeBrowsing. func (d *DNSFilter) checkParental( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.ParentalEnabled { return Result{}, nil } </s> remove res := Result{ </s> add res = Result{ </s> remove func (d *DNSFilter) checkSafeSearch(host string) (Result, error) { </s> add func (d *DNSFilter) checkSafeSearch( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeSearchEnabled { return Result{}, nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing.go
res = Result{
<mask> svc: "SafeBrowsing", <mask> cache: gctx.safebrowsingCache, <mask> cacheTime: d.Config.CacheTime, <mask> } <mask> res := Result{ <mask> IsFiltered: true, <mask> Reason: FilteredSafeBrowsing, <mask> Rules: []*ResultRule{{ <mask> Text: "adguard-malware-shavar", <mask> }}, </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove res := Result{ </s> add res = Result{ </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove res := Result{ </s> add res = Result{ </s> remove return check(ctx, res, d.safeBrowsingUpstream) </s> add return check(sctx, res, d.safeBrowsingUpstream) </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing.go
return check(sctx, res, d.safeBrowsingUpstream)
<mask> Rules: []*ResultRule{{ <mask> Text: "adguard-malware-shavar", <mask> }}, <mask> } <mask> return check(ctx, res, d.safeBrowsingUpstream) <mask> } <mask> <mask> func (d *DNSFilter) checkParental(host string) (Result, error) { <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove func (d *DNSFilter) checkParental(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkSafeBrowsing. func (d *DNSFilter) checkParental( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.ParentalEnabled { return Result{}, nil } </s> remove func (d *DNSFilter) checkSafeSearch(host string) (Result, error) { </s> add func (d *DNSFilter) checkSafeSearch( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeSearchEnabled { return Result{}, nil } </s> remove func (d *DNSFilter) checkSafeBrowsing(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkParental. func (d *DNSFilter) checkSafeBrowsing( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeBrowsingEnabled { return Result{}, nil } </s> remove return check(ctx, res, d.parentalUpstream) </s> add return check(sctx, res, d.parentalUpstream) </s> remove res := Result{ </s> add res = Result{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing.go
// TODO(a.garipov): Unify with checkSafeBrowsing. func (d *DNSFilter) checkParental( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.ParentalEnabled { return Result{}, nil }
<mask> } <mask> return check(ctx, res, d.safeBrowsingUpstream) <mask> } <mask> <mask> func (d *DNSFilter) checkParental(host string) (Result, error) { <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("Parental lookup for %s", host) <mask> } <mask> ctx := &sbCtx{ </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove return check(ctx, res, d.safeBrowsingUpstream) </s> add return check(sctx, res, d.safeBrowsingUpstream) </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove func (d *DNSFilter) checkSafeBrowsing(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkParental. func (d *DNSFilter) checkSafeBrowsing( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeBrowsingEnabled { return Result{}, nil } </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove func (d *DNSFilter) checkSafeSearch(host string) (Result, error) { </s> add func (d *DNSFilter) checkSafeSearch( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeSearchEnabled { return Result{}, nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing.go
sctx := &sbCtx{
<mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("Parental lookup for %s", host) <mask> } <mask> ctx := &sbCtx{ <mask> host: host, <mask> svc: "Parental", <mask> cache: gctx.parentalCache, <mask> cacheTime: d.Config.CacheTime, <mask> } </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove func (d *DNSFilter) checkParental(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkSafeBrowsing. func (d *DNSFilter) checkParental( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.ParentalEnabled { return Result{}, nil } </s> remove func (d *DNSFilter) checkSafeBrowsing(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkParental. func (d *DNSFilter) checkSafeBrowsing( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeBrowsingEnabled { return Result{}, nil } </s> remove res := Result{ </s> add res = Result{ </s> remove func (d *DNSFilter) checkSafeSearch(host string) (Result, error) { </s> add func (d *DNSFilter) checkSafeSearch( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeSearchEnabled { return Result{}, nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing.go
res = Result{
<mask> svc: "Parental", <mask> cache: gctx.parentalCache, <mask> cacheTime: d.Config.CacheTime, <mask> } <mask> res := Result{ <mask> IsFiltered: true, <mask> Reason: FilteredParental, <mask> Rules: []*ResultRule{{ <mask> Text: "parental CATEGORY_BLACKLISTED", <mask> }}, </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove res := Result{ </s> add res = Result{ </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove res := Result{ </s> add res = Result{ </s> remove return check(ctx, res, d.parentalUpstream) </s> add return check(sctx, res, d.parentalUpstream) </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing.go
return check(sctx, res, d.parentalUpstream)
<mask> Rules: []*ResultRule{{ <mask> Text: "parental CATEGORY_BLACKLISTED", <mask> }}, <mask> } <mask> return check(ctx, res, d.parentalUpstream) <mask> } <mask> <mask> func httpError(r *http.Request, w http.ResponseWriter, code int, format string, args ...interface{}) { <mask> text := fmt.Sprintf(format, args...) <mask> log.Info("DNSFilter: %s %s: %s", r.Method, r.URL, text) </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove res := Result{ </s> add res = Result{ </s> remove return check(ctx, res, d.safeBrowsingUpstream) </s> add return check(sctx, res, d.safeBrowsingUpstream) </s> remove res := Result{ </s> add res = Result{ </s> remove return res </s> add return res, nil </s> remove func (d *DNSFilter) checkParental(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkSafeBrowsing. func (d *DNSFilter) checkParental( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.ParentalEnabled { return Result{}, nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing.go
"github.com/miekg/dns"
<mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest" <mask> "github.com/AdguardTeam/golibs/cache" <mask> "github.com/stretchr/testify/assert" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> <mask> func TestSafeBrowsingHash(t *testing.T) { <mask> // test hostnameToHashes() </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove res, err := tc.testFunc(hostname) require.Nil(t, err) </s> add res, err := tc.testFunc(hostname, dns.TypeA, setts) require.NoError(t, err) </s> remove _, err = d.checkParental("smthng.com") assert.NotNil(t, err) </s> add _, err = d.checkParental("smthng.com", dns.TypeA, setts) assert.Error(t, err) </s> remove func (d *DNSFilter) checkSafeBrowsing(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkParental. func (d *DNSFilter) checkSafeBrowsing( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeBrowsingEnabled { return Result{}, nil } </s> remove func (d *DNSFilter) checkParental(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkSafeBrowsing. func (d *DNSFilter) checkParental( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.ParentalEnabled { return Result{}, nil } </s> remove func matchBlockedServicesRules(host string, svcs []ServiceEntry) Result { req := rules.NewRequestForHostname(host) res := Result{} </s> add // matchBlockedServicesRules checks the host against the blocked services rules // in settings, if any. The err is always nil, it is only there to make this // a valid hostChecker function. func matchBlockedServicesRules( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { svcs := setts.ServicesRules if len(svcs) == 0 { return Result{}, nil }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing_test.go
setts := &FilteringSettings{ SafeBrowsingEnabled: true, ParentalEnabled: true, } _, err := d.checkSafeBrowsing("smthng.com", dns.TypeA, setts) assert.Error(t, err)
<mask> <mask> d.SetSafeBrowsingUpstream(ups) <mask> d.SetParentalUpstream(ups) <mask> <mask> _, err := d.checkSafeBrowsing("smthng.com") <mask> assert.NotNil(t, err) <mask> <mask> _, err = d.checkParental("smthng.com") <mask> assert.NotNil(t, err) <mask> } <mask> </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove _, err = d.checkParental("smthng.com") assert.NotNil(t, err) </s> add _, err = d.checkParental("smthng.com", dns.TypeA, setts) assert.Error(t, err) </s> remove // apply safe search if needed if setts.SafeSearchEnabled { result, err = d.checkSafeSearch(host) </s> add for _, hc := range d.hostCheckers { res, err = hc.check(host, qtype, setts) </s> remove res, err := tc.testFunc(hostname) require.Nil(t, err) </s> add res, err := tc.testFunc(hostname, dns.TypeA, setts) require.NoError(t, err) </s> remove log.Info("SafeSearch: failed: %v", err) return Result{}, nil </s> add return Result{}, fmt.Errorf("%s: %w", hc.name, err)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing_test.go
_, err = d.checkParental("smthng.com", dns.TypeA, setts) assert.Error(t, err)
<mask> <mask> _, err := d.checkSafeBrowsing("smthng.com") <mask> assert.NotNil(t, err) <mask> <mask> _, err = d.checkParental("smthng.com") <mask> assert.NotNil(t, err) <mask> } <mask> <mask> func TestSBPC(t *testing.T) { <mask> d := newForTest(&Config{SafeBrowsingEnabled: true}, nil) <mask> t.Cleanup(d.Close) </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove _, err := d.checkSafeBrowsing("smthng.com") assert.NotNil(t, err) </s> add setts := &FilteringSettings{ SafeBrowsingEnabled: true, ParentalEnabled: true, } _, err := d.checkSafeBrowsing("smthng.com", dns.TypeA, setts) assert.Error(t, err) </s> remove // apply safe search if needed if setts.SafeSearchEnabled { result, err = d.checkSafeSearch(host) </s> add for _, hc := range d.hostCheckers { res, err = hc.check(host, qtype, setts) </s> remove res, err := tc.testFunc(hostname) require.Nil(t, err) </s> add res, err := tc.testFunc(hostname, dns.TypeA, setts) require.NoError(t, err) </s> remove func matchBlockedServicesRules(host string, svcs []ServiceEntry) Result { req := rules.NewRequestForHostname(host) res := Result{} </s> add // matchBlockedServicesRules checks the host against the blocked services rules // in settings, if any. The err is always nil, it is only there to make this // a valid hostChecker function. func matchBlockedServicesRules( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { svcs := setts.ServicesRules if len(svcs) == 0 { return Result{}, nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing_test.go
setts := &FilteringSettings{ SafeBrowsingEnabled: true, ParentalEnabled: true, }
<mask> const hostname = "example.org" <mask> <mask> testCases := []struct { <mask> name string <mask> block bool <mask> testFunc func(host string, _ uint16, _ *FilteringSettings) (res Result, err error) </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove testFunc func(string) (Result, error) </s> add testFunc func(host string, _ uint16, _ *FilteringSettings) (res Result, err error) </s> remove func (d *DNSFilter) checkSafeSearch(host string) (Result, error) { </s> add func (d *DNSFilter) checkSafeSearch( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeSearchEnabled { return Result{}, nil } </s> remove func (d *DNSFilter) checkSafeBrowsing(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkParental. func (d *DNSFilter) checkSafeBrowsing( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeBrowsingEnabled { return Result{}, nil } </s> remove func (d *DNSFilter) checkParental(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkSafeBrowsing. func (d *DNSFilter) checkParental( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.ParentalEnabled { return Result{}, nil }
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing_test.go
testFunc func(host string, _ uint16, _ *FilteringSettings) (res Result, err error)
<mask> <mask> testCases := []struct { <mask> name string <mask> block bool <mask> testFunc func(string) (Result, error) <mask> testCache cache.Cache <mask> }{{ <mask> name: "sb_no_block", <mask> block: false, <mask> testFunc: d.checkSafeBrowsing, </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove // RequestFilteringSettings is custom filtering settings type RequestFilteringSettings struct { FilteringEnabled bool SafeSearchEnabled bool SafeBrowsingEnabled bool ParentalEnabled bool </s> add // FilteringSettings are custom filtering settings for a client. type FilteringSettings struct { </s> remove func (d *DNSFilter) checkSafeSearch(host string) (Result, error) { </s> add func (d *DNSFilter) checkSafeSearch( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeSearchEnabled { return Result{}, nil }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing_test.go
res, err := tc.testFunc(hostname, dns.TypeA, setts) require.NoError(t, err)
<mask> <mask> t.Run(tc.name, func(t *testing.T) { <mask> // Firstly, check the request blocking. <mask> hits := 0 <mask> res, err := tc.testFunc(hostname) <mask> require.Nil(t, err) <mask> if tc.block { <mask> assert.True(t, res.IsFiltered) <mask> require.Len(t, res.Rules, 1) <mask> hits++ <mask> } else { </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove res, err = tc.testFunc(hostname) require.Nil(t, err) </s> add res, err = tc.testFunc(hostname, dns.TypeA, setts) require.NoError(t, err) </s> remove _, err = d.checkParental("smthng.com") assert.NotNil(t, err) </s> add _, err = d.checkParental("smthng.com", dns.TypeA, setts) assert.Error(t, err) </s> remove host = strings.ToLower(host) var result Result var err error // first - check rewrites, they have the highest priority result = d.processRewrites(host, qtype) if result.Reason == Rewritten { return result, nil } // Now check the hosts file -- do we have any rules for it? // just like DNS rewrites, it has higher priority than filtering rules. if d.Config.AutoHosts != nil { matched := d.checkAutoHosts(host, qtype, &result) if matched { return result, nil } } </s> add </s> remove // apply safe search if needed if setts.SafeSearchEnabled { result, err = d.checkSafeSearch(host) </s> add for _, hc := range d.hostCheckers { res, err = hc.check(host, qtype, setts) </s> remove func matchBlockedServicesRules(host string, svcs []ServiceEntry) Result { req := rules.NewRequestForHostname(host) res := Result{} </s> add // matchBlockedServicesRules checks the host against the blocked services rules // in settings, if any. The err is always nil, it is only there to make this // a valid hostChecker function. func matchBlockedServicesRules( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { svcs := setts.ServicesRules if len(svcs) == 0 { return Result{}, nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing_test.go
res, err = tc.testFunc(hostname, dns.TypeA, setts) require.NoError(t, err)
<mask> // There was one request to an upstream. <mask> assert.Equal(t, 1, ups.RequestsCount()) <mask> <mask> // Now make the same request to check the cache was used. <mask> res, err = tc.testFunc(hostname) <mask> require.Nil(t, err) <mask> if tc.block { <mask> assert.True(t, res.IsFiltered) <mask> require.Len(t, res.Rules, 1) <mask> } else { <mask> require.False(t, res.IsFiltered) </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove res, err := tc.testFunc(hostname) require.Nil(t, err) </s> add res, err := tc.testFunc(hostname, dns.TypeA, setts) require.NoError(t, err) </s> remove host = strings.ToLower(host) var result Result var err error // first - check rewrites, they have the highest priority result = d.processRewrites(host, qtype) if result.Reason == Rewritten { return result, nil } // Now check the hosts file -- do we have any rules for it? // just like DNS rewrites, it has higher priority than filtering rules. if d.Config.AutoHosts != nil { matched := d.checkAutoHosts(host, qtype, &result) if matched { return result, nil } } </s> add </s> remove // CheckHost tries to match the host against filtering rules, then // safebrowsing and parental control rules, if they are enabled. func (d *DNSFilter) CheckHost(host string, qtype uint16, setts *RequestFilteringSettings) (Result, error) { // sometimes DNS clients will try to resolve ".", which is a request to get root servers </s> add // CheckHost tries to match the host against filtering rules, then safebrowsing // and parental control rules, if they are enabled. func (d *DNSFilter) CheckHost( host string, qtype uint16, setts *FilteringSettings, ) (res Result, err error) { // Sometimes clients try to resolve ".", which is a request to get root // servers. </s> remove func matchBlockedServicesRules(host string, svcs []ServiceEntry) Result { req := rules.NewRequestForHostname(host) res := Result{} </s> add // matchBlockedServicesRules checks the host against the blocked services rules // in settings, if any. The err is always nil, it is only there to make this // a valid hostChecker function. func matchBlockedServicesRules( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { svcs := setts.ServicesRules if len(svcs) == 0 { return Result{}, nil } </s> remove func (d *DNSFilter) checkAutoHosts(host string, qtype uint16, result *Result) (matched bool) { </s> add // checkAutoHosts compares the host against our autohosts table. The err is // always nil, it is only there to make this a valid hostChecker function. func (d *DNSFilter) checkAutoHosts( host string, qtype uint16, _ *FilteringSettings, ) (res Result, err error) { if d.Config.AutoHosts == nil { return Result{}, nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safebrowsing_test.go
func (d *DNSFilter) checkSafeSearch( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeSearchEnabled { return Result{}, nil }
<mask> val, ok := safeSearchDomains[host] <mask> return val, ok <mask> } <mask> <mask> func (d *DNSFilter) checkSafeSearch(host string) (Result, error) { <mask> if log.GetLevel() >= log.DEBUG { <mask> timer := log.StartTimer() <mask> defer timer.LogElapsed("SafeSearch: lookup for %s", host) <mask> } <mask> </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove func (d *DNSFilter) checkSafeBrowsing(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkParental. func (d *DNSFilter) checkSafeBrowsing( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.SafeBrowsingEnabled { return Result{}, nil } </s> remove func (d *DNSFilter) checkParental(host string) (Result, error) { </s> add // TODO(a.garipov): Unify with checkSafeBrowsing. func (d *DNSFilter) checkParental( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.ParentalEnabled { return Result{}, nil } </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove ctx := &sbCtx{ </s> add sctx := &sbCtx{ </s> remove return check(ctx, res, d.safeBrowsingUpstream) </s> add return check(sctx, res, d.safeBrowsingUpstream)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safesearch.go
res = Result{
<mask> if !ok { <mask> return Result{}, nil <mask> } <mask> <mask> res := Result{ <mask> IsFiltered: true, <mask> Reason: FilteredSafeSearch, <mask> Rules: []*ResultRule{{}}, <mask> } <mask> </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove res := Result{ </s> add res = Result{ </s> remove res := Result{ </s> add res = Result{ </s> remove result.Reason = RewrittenAutoHosts result.IPList = ips </s> add res = Result{ Reason: RewrittenAutoHosts, IPList: ips, } </s> remove result.Reason = RewrittenAutoHosts </s> add res = Result{ Reason: RewrittenAutoHosts, } </s> remove return check(ctx, res, d.safeBrowsingUpstream) </s> add return check(sctx, res, d.safeBrowsingUpstream)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsfilter/safesearch.go
FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.FilteringSettings) `yaml:"-"`
<mask> // Callbacks for other modules <mask> // -- <mask> <mask> // FilterHandler is an optional additional filtering callback. <mask> FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.RequestFilteringSettings) `yaml:"-"` <mask> <mask> // GetCustomUpstreamByClient - a callback function that returns upstreams configuration <mask> // based on the client IP address. Returns nil if there are no custom upstreams for the client <mask> // <mask> // TODO(e.burkov): Replace argument type with net.IP. </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove func applyAdditionalFiltering(clientAddr net.IP, clientID string, setts *dnsfilter.RequestFilteringSettings) { </s> add func applyAdditionalFiltering(clientAddr net.IP, clientID string, setts *dnsfilter.FilteringSettings) { </s> remove // RequestFilteringSettings is custom filtering settings type RequestFilteringSettings struct { FilteringEnabled bool SafeSearchEnabled bool SafeBrowsingEnabled bool ParentalEnabled bool </s> add // FilteringSettings are custom filtering settings for a client. type FilteringSettings struct { </s> remove setts *dnsfilter.RequestFilteringSettings </s> add setts *dnsfilter.FilteringSettings </s> remove func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.RequestFilteringSettings { </s> add func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.FilteringSettings {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsforward/config.go
setts *dnsfilter.FilteringSettings
<mask> // *Server instead. <mask> srv *Server <mask> proxyCtx *proxy.DNSContext <mask> // setts are the filtering settings for the client. <mask> setts *dnsfilter.RequestFilteringSettings <mask> startTime time.Time <mask> result *dnsfilter.Result <mask> // origResp is the response received from upstream. It is set when the <mask> // response is modified by filters. <mask> origResp *dns.Msg </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.RequestFilteringSettings) `yaml:"-"` </s> add FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.FilteringSettings) `yaml:"-"` </s> remove // RequestFilteringSettings is custom filtering settings type RequestFilteringSettings struct { FilteringEnabled bool SafeSearchEnabled bool SafeBrowsingEnabled bool ParentalEnabled bool </s> add // FilteringSettings are custom filtering settings for a client. type FilteringSettings struct { </s> remove func (d *DNSFilter) matchHost(host string, qtype uint16, setts RequestFilteringSettings) (res Result, err error) { </s> add func (d *DNSFilter) matchHost( host string, qtype uint16, setts *FilteringSettings, ) (res Result, err error) { if !setts.FilteringEnabled { return Result{}, nil } </s> remove func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.RequestFilteringSettings { </s> add func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.FilteringSettings { </s> remove // CheckHost tries to match the host against filtering rules, then // safebrowsing and parental control rules, if they are enabled. func (d *DNSFilter) CheckHost(host string, qtype uint16, setts *RequestFilteringSettings) (Result, error) { // sometimes DNS clients will try to resolve ".", which is a request to get root servers </s> add // CheckHost tries to match the host against filtering rules, then safebrowsing // and parental control rules, if they are enabled. func (d *DNSFilter) CheckHost( host string, qtype uint16, setts *FilteringSettings, ) (res Result, err error) { // Sometimes clients try to resolve ".", which is a request to get root // servers.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsforward/dns.go
FilterHandler: func(_ net.IP, _ string, settings *dnsfilter.FilteringSettings) {
<mask> UDPListenAddrs: []*net.UDPAddr{{}}, <mask> TCPListenAddrs: []*net.TCPAddr{{}}, <mask> FilteringConfig: FilteringConfig{ <mask> ProtectionEnabled: true, <mask> FilterHandler: func(_ net.IP, _ string, settings *dnsfilter.RequestFilteringSettings) { <mask> settings.FilteringEnabled = false <mask> }, <mask> }, <mask> } <mask> s := createTestServer(t, &dnsfilter.Config{}, forwardConf) </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove func applyAdditionalFiltering(clientAddr net.IP, clientID string, setts *dnsfilter.RequestFilteringSettings) { </s> add func applyAdditionalFiltering(clientAddr net.IP, clientID string, setts *dnsfilter.FilteringSettings) { </s> remove func applyClientSettings(setts *RequestFilteringSettings) { </s> add func applyClientSettings(setts *FilteringSettings) { </s> remove FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.RequestFilteringSettings) `yaml:"-"` </s> add FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.FilteringSettings) `yaml:"-"`
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsforward/dnsforward_test.go
func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.FilteringSettings {
<mask> } <mask> <mask> // getClientRequestFilteringSettings looks up client filtering settings using <mask> // the client's IP address and ID, if any, from ctx. <mask> func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.RequestFilteringSettings { <mask> setts := s.dnsFilter.GetConfig() <mask> setts.FilteringEnabled = true <mask> if s.conf.FilterHandler != nil { <mask> s.conf.FilterHandler(IPFromAddr(ctx.proxyCtx.Addr), ctx.clientID, &setts) <mask> } </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove func applyAdditionalFiltering(clientAddr net.IP, clientID string, setts *dnsfilter.RequestFilteringSettings) { </s> add func applyAdditionalFiltering(clientAddr net.IP, clientID string, setts *dnsfilter.FilteringSettings) { </s> remove setts = RequestFilteringSettings{ </s> add setts = FilteringSettings{ </s> remove setts *dnsfilter.RequestFilteringSettings </s> add setts *dnsfilter.FilteringSettings </s> remove if setts.FilteringEnabled { result, err = d.matchHost(host, qtype, *setts) if err != nil { return result, err } if result.Reason.Matched() { return result, nil } } // are there any blocked services? if len(setts.ServicesRules) != 0 { result = matchBlockedServicesRules(host, setts.ServicesRules) if result.Reason.Matched() { return result, nil } } // browsing security web service if setts.SafeBrowsingEnabled { result, err = d.checkSafeBrowsing(host) if err != nil { log.Info("SafeBrowsing: failed: %v", err) return Result{}, nil } if result.Reason.Matched() { return result, nil } } </s> add host = strings.ToLower(host) </s> remove FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.RequestFilteringSettings) `yaml:"-"` </s> add FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.FilteringSettings) `yaml:"-"`
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/dnsforward/filter.go
func applyAdditionalFiltering(clientAddr net.IP, clientID string, setts *dnsfilter.FilteringSettings) {
<mask> } <mask> <mask> // applyAdditionalFiltering adds additional client information and settings if <mask> // the client has them. <mask> func applyAdditionalFiltering(clientAddr net.IP, clientID string, setts *dnsfilter.RequestFilteringSettings) { <mask> Context.dnsFilter.ApplyBlockedServices(setts, nil, true) <mask> <mask> if clientAddr == nil { <mask> return <mask> } </s> Pull request: all: imp code, decr cyclo Updates #2646. Squashed commit of the following: commit c83c230f3d2c542d7b1a4bc0e1c503d5bbc16cb8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Mar 25 19:47:11 2021 +0300 all: imp code, decr cyclo </s> remove FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.RequestFilteringSettings) `yaml:"-"` </s> add FilterHandler func(clientAddr net.IP, clientID string, settings *dnsfilter.FilteringSettings) `yaml:"-"` </s> remove func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.RequestFilteringSettings { </s> add func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.FilteringSettings { </s> remove FilterHandler: func(_ net.IP, _ string, settings *dnsfilter.RequestFilteringSettings) { </s> add FilterHandler: func(_ net.IP, _ string, settings *dnsfilter.FilteringSettings) { </s> remove func matchBlockedServicesRules(host string, svcs []ServiceEntry) Result { req := rules.NewRequestForHostname(host) res := Result{} </s> add // matchBlockedServicesRules checks the host against the blocked services rules // in settings, if any. The err is always nil, it is only there to make this // a valid hostChecker function. func matchBlockedServicesRules( host string, _ uint16, setts *FilteringSettings, ) (res Result, err error) { svcs := setts.ServicesRules if len(svcs) == 0 { return Result{}, nil } </s> remove host = strings.ToLower(host) var result Result var err error // first - check rewrites, they have the highest priority result = d.processRewrites(host, qtype) if result.Reason == Rewritten { return result, nil } // Now check the hosts file -- do we have any rules for it? // just like DNS rewrites, it has higher priority than filtering rules. if d.Config.AutoHosts != nil { matched := d.checkAutoHosts(host, qtype, &result) if matched { return result, nil } } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c735d0dd5c2158e2230fa12a140e27960f89e0b
internal/home/dns.go
};
<mask> }; <mask> <mask> handleCheck = (values) => { <mask> this.props.checkHost(values); <mask> } <mask> <mask> render() { <mask> const { <mask> t, <mask> filtering: { </s> - client: Enabling or disabling a filter list triggers a "loading" screen </s> remove const loading = processingFilters </s> add const loading = processingConfigFilter || processingFilters </s> remove const loading = processingFilters </s> add const loading = processingConfigFilter || processingFilters
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c74f983d1c08c03a9f131abdea8e712a5cf7505
client/src/components/Filters/CustomRules.js
const loading = processingConfigFilter || processingFilters
<mask> modalFilterUrl, <mask> }, <mask> } = this.props; <mask> const currentFilterData = getCurrentFilter(modalFilterUrl, whitelistFilters); <mask> const loading = processingFilters <mask> || processingAddFilter <mask> || processingRemoveFilter <mask> || processingRefreshFilters; <mask> const whitelist = true; <mask> </s> - client: Enabling or disabling a filter list triggers a "loading" screen </s> remove } </s> add }; </s> remove const loading = processingFilters </s> add const loading = processingConfigFilter || processingFilters
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c74f983d1c08c03a9f131abdea8e712a5cf7505
client/src/components/Filters/DnsAllowlist.js
const loading = processingConfigFilter || processingFilters
<mask> modalFilterUrl, <mask> }, <mask> } = this.props; <mask> const currentFilterData = getCurrentFilter(modalFilterUrl, filters); <mask> const loading = processingFilters <mask> || processingAddFilter <mask> || processingRemoveFilter <mask> || processingRefreshFilters; <mask> <mask> return ( </s> - client: Enabling or disabling a filter list triggers a "loading" screen </s> remove } </s> add }; </s> remove const loading = processingFilters </s> add const loading = processingConfigFilter || processingFilters
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c74f983d1c08c03a9f131abdea8e712a5cf7505
client/src/components/Filters/DnsBlocklist.js
import apiClient from '../api/Api';
<mask> import { createAction } from 'redux-actions'; <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> import { normalizeTextarea } from '../helpers/helpers'; <mask> <mask> const apiClient = new Api(); <mask> </s> - client: fix api client export </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/access.js
<mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> import { normalizeTextarea } from '../helpers/helpers'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const getAccessListRequest = createAction('GET_ACCESS_LIST_REQUEST'); <mask> export const getAccessListFailure = createAction('GET_ACCESS_LIST_FAILURE'); <mask> export const getAccessListSuccess = createAction('GET_ACCESS_LIST_SUCCESS'); <mask> <mask> export const getAccessList = () => async (dispatch) => { </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/access.js
import apiClient from '../api/Api';
<mask> import { createAction } from 'redux-actions'; <mask> import { t } from 'i18next'; <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast, getClients } from './index'; <mask> import { CLIENT_ID } from '../helpers/constants'; <mask> <mask> const apiClient = new Api(); <mask> </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/clients.js
<mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast, getClients } from './index'; <mask> import { CLIENT_ID } from '../helpers/constants'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const toggleClientModal = createAction('TOGGLE_CLIENT_MODAL'); <mask> <mask> export const addClientRequest = createAction('ADD_CLIENT_REQUEST'); <mask> export const addClientFailure = createAction('ADD_CLIENT_FAILURE'); <mask> export const addClientSuccess = createAction('ADD_CLIENT_SUCCESS'); </s> - client: fix api client export </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; const apiClient = new Api(); </s> add import apiClient from '../api/Api'; </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/clients.js
import apiClient from '../api/Api';
<mask> import { createAction } from 'redux-actions'; <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> import { redirectToCurrentProtocol } from '../helpers/helpers'; <mask> <mask> const apiClient = new Api(); <mask> </s> - client: fix api client export </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/encryption.js
<mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> import { redirectToCurrentProtocol } from '../helpers/helpers'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const getTlsStatusRequest = createAction('GET_TLS_STATUS_REQUEST'); <mask> export const getTlsStatusFailure = createAction('GET_TLS_STATUS_FAILURE'); <mask> export const getTlsStatusSuccess = createAction('GET_TLS_STATUS_SUCCESS'); <mask> <mask> export const getTlsStatus = () => async (dispatch) => { </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; const apiClient = new Api(); </s> add import apiClient from '../api/Api';
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/encryption.js
import apiClient from '../api/Api';
<mask> import versionCompare from '../helpers/versionCompare'; <mask> import { normalizeFilteringStatus, normalizeTextarea, sortClients } from '../helpers/helpers'; <mask> import { SETTINGS_NAMES, CHECK_TIMEOUT } from '../helpers/constants'; <mask> import { getTlsStatus } from './encryption'; <mask> import Api from '../api/Api'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const addErrorToast = createAction('ADD_ERROR_TOAST'); <mask> export const addSuccessToast = createAction('ADD_SUCCESS_TOAST'); <mask> export const addNoticeToast = createAction('ADD_NOTICE_TOAST'); <mask> export const removeToast = createAction('REMOVE_TOAST'); </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/index.js
import apiClient from '../api/Api';
<mask> import { createAction } from 'redux-actions'; <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const nextStep = createAction('NEXT_STEP'); </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/install.js
<mask> import { createAction } from 'redux-actions'; <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const nextStep = createAction('NEXT_STEP'); <mask> export const prevStep = createAction('PREV_STEP'); <mask> <mask> export const getDefaultAddressesRequest = createAction('GET_DEFAULT_ADDRESSES_REQUEST'); <mask> export const getDefaultAddressesFailure = createAction('GET_DEFAULT_ADDRESSES_FAILURE'); </s> - client: fix api client export </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/install.js
import apiClient from '../api/Api';
<mask> import { createAction } from 'redux-actions'; <mask> <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> import { normalizeLogs } from '../helpers/helpers'; <mask> <mask> const apiClient = new Api(); <mask> </s> - client: fix api client export </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/queryLogs.js
<mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> import { normalizeLogs } from '../helpers/helpers'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const getLogsRequest = createAction('GET_LOGS_REQUEST'); <mask> export const getLogsFailure = createAction('GET_LOGS_FAILURE'); <mask> export const getLogsSuccess = createAction('GET_LOGS_SUCCESS'); <mask> <mask> export const getLogs = () => async (dispatch) => { </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/queryLogs.js
import apiClient from '../api/Api';
<mask> import { createAction } from 'redux-actions'; <mask> import { t } from 'i18next'; <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const toggleRewritesModal = createAction('TOGGLE_REWRITES_MODAL'); </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/rewrites.js
<mask> import { t } from 'i18next'; <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const toggleRewritesModal = createAction('TOGGLE_REWRITES_MODAL'); <mask> <mask> export const getRewritesListRequest = createAction('GET_REWRITES_LIST_REQUEST'); <mask> export const getRewritesListFailure = createAction('GET_REWRITES_LIST_FAILURE'); <mask> export const getRewritesListSuccess = createAction('GET_REWRITES_LIST_SUCCESS'); </s> - client: fix api client export </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/rewrites.js
import apiClient from '../api/Api';
<mask> import { createAction } from 'redux-actions'; <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const getBlockedServicesRequest = createAction('GET_BLOCKED_SERVICES_REQUEST'); </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/services.js
<mask> import { createAction } from 'redux-actions'; <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const getBlockedServicesRequest = createAction('GET_BLOCKED_SERVICES_REQUEST'); <mask> export const getBlockedServicesFailure = createAction('GET_BLOCKED_SERVICES_FAILURE'); <mask> export const getBlockedServicesSuccess = createAction('GET_BLOCKED_SERVICES_SUCCESS'); <mask> <mask> export const getBlockedServices = () => async (dispatch) => { </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/services.js
import apiClient from '../api/Api';
<mask> import { createAction } from 'redux-actions'; <mask> <mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> import { normalizeTopStats, secondsToMilliseconds } from '../helpers/helpers'; <mask> <mask> const apiClient = new Api(); <mask> </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/stats.js
<mask> import Api from '../api/Api'; <mask> import { addErrorToast, addSuccessToast } from './index'; <mask> import { normalizeTopStats, secondsToMilliseconds } from '../helpers/helpers'; <mask> <mask> const apiClient = new Api(); <mask> <mask> export const getStatsConfigRequest = createAction('GET_STATS_CONFIG_REQUEST'); <mask> export const getStatsConfigFailure = createAction('GET_STATS_CONFIG_FAILURE'); <mask> export const getStatsConfigSuccess = createAction('GET_STATS_CONFIG_SUCCESS'); <mask> <mask> export const getStatsConfig = () => async (dispatch) => { </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/actions/stats.js
class Api {
<mask> import axios from 'axios'; <mask> <mask> export default class Api { <mask> baseUrl = 'control'; <mask> <mask> async makeRequest(path, method = 'POST', config) { <mask> try { <mask> const response = await axios({ </s> - client: fix api client export </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/api/Api.js
const apiClient = new Api(); export default apiClient;
<mask> const { path, method } = this.QUERY_LOG_CLEAR; <mask> return this.makeRequest(path, method); <mask> } <mask> } </s> - client: fix api client export </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import { toggleLogStatus, clearLogs, getLogsConfig, setLogsConfig } from '../actions/queryLogs'; </s> add import { clearLogs, getLogsConfig, setLogsConfig } from '../actions/queryLogs'; </s> remove import Api from '../api/Api'; const apiClient = new Api(); </s> add import apiClient from '../api/Api'; </s> remove const apiClient = new Api(); </s> add </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "keep", "add" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/api/Api.js
{!enabled && !processingGetConfig && (
<mask> {enabled && (processingGetLogs || processingClients || processingGetConfig) && ( <mask> <Loading /> <mask> )} <mask> {enabled && isDataReady && this.renderLogs(queryLogs.logs)} <mask> {!enabled && isDataReady && ( <mask> <div className="lead text-center py-6"> <mask> <Trans components={[<Link to="/settings#logs-config" key="0">link</Link>]}> <mask> query_log_disabled <mask> </Trans> <mask> </div> </s> - client: fix api client export </s> remove toggleLogStatus, </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove const apiClient = new Api(); </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/components/Logs/index.js
import { clearLogs, getLogsConfig, setLogsConfig } from '../actions/queryLogs';
<mask> import { connect } from 'react-redux'; <mask> import { initSettings, toggleSetting } from '../actions'; <mask> import { getBlockedServices, setBlockedServices } from '../actions/services'; <mask> import { getStatsConfig, setStatsConfig, resetStats } from '../actions/stats'; <mask> import { toggleLogStatus, clearLogs, getLogsConfig, setLogsConfig } from '../actions/queryLogs'; <mask> import Settings from '../components/Settings'; <mask> <mask> const mapStateToProps = (state) => { <mask> const { <mask> settings, services, stats, queryLogs, </s> - client: fix api client export </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/containers/Settings.js
<mask> setBlockedServices, <mask> getStatsConfig, <mask> setStatsConfig, <mask> resetStats, <mask> toggleLogStatus, <mask> clearLogs, <mask> getLogsConfig, <mask> setLogsConfig, <mask> }; <mask> </s> - client: fix api client export </s> remove import { toggleLogStatus, clearLogs, getLogsConfig, setLogsConfig } from '../actions/queryLogs'; </s> add import { clearLogs, getLogsConfig, setLogsConfig } from '../actions/queryLogs'; </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api'; </s> remove const apiClient = new Api(); </s> add </s> remove import Api from '../api/Api'; </s> add import apiClient from '../api/Api';
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8c89973365e660d47fa5fce88113414011961acb
client/src/containers/Settings.js
<mask> package dnsfilter <mask> <mask> import ( <mask> "bytes" <mask> "fmt" <mask> "io/ioutil" <mask> "net" <mask> "net/http" <mask> "os" </s> * dnsfilter: change DNS answer for host rules When matched by a host rule, return only the IP address specified in rule. Respond with an empty IP list to another request type. :: host -- return nothing to A, return :: to AAAA request 0.0.0.0 host -- return 0.0.0.0 to A, return nothing to AAAA request </s> remove } else if req.Question[0].Qtype == dns.TypeAAAA && ip.To4() == nil { </s> add } else if req.Question[0].Qtype == dns.TypeAAAA && len(ip) == net.IPv6len && ip.To4() == nil { </s> remove d.checkMatchIP(t, "block.com", "::", dns.TypeAAAA) </s> add // ...but empty IPv6 ret, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) // IPv6 d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) // ...but empty IPv4 ret, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) </s> remove // IPv6 address d.checkMatchIP(t, "google.com", addr6, dns.TypeAAAA) // block both IPv4 and IPv6 </s> add // IPv4 </s> remove text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s google.com\n0.0.0.0 block.com\n", </s> add text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s ipv6.com\n0.0.0.0 block.com\n", </s> remove continue </s> add return res, nil
[ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d2a9ce923eae4673a74f4c4a7e1d9ef840f04d2
dnsfilter/dnsfilter.go
res.IP = net.IP{}
<mask> return res, nil <mask> <mask> } else if hostRule, ok := rule.(*rules.HostRule); ok { <mask> <mask> if qtype == dns.TypeA && hostRule.IP.To4() != nil { <mask> // either IPv4 or IPv4-mapped IPv6 address <mask> res.IP = hostRule.IP.To4() <mask> <mask> } else if qtype == dns.TypeAAAA && hostRule.IP.To4() == nil { </s> * dnsfilter: change DNS answer for host rules When matched by a host rule, return only the IP address specified in rule. Respond with an empty IP list to another request type. :: host -- return nothing to A, return :: to AAAA request 0.0.0.0 host -- return 0.0.0.0 to A, return nothing to AAAA request </s> remove return res, nil } else if qtype == dns.TypeAAAA { ip4 := hostRule.IP.To4() if ip4 == nil { res.IP = hostRule.IP return res, nil } if bytes.Equal(ip4, []byte{0, 0, 0, 0}) { // send IP="::" response for a rule "0.0.0.0 blockdomain" res.IP = net.IPv6zero return res, nil } </s> add } else if qtype == dns.TypeAAAA && hostRule.IP.To4() == nil { res.IP = hostRule.IP </s> remove } else if req.Question[0].Qtype == dns.TypeAAAA && ip.To4() == nil { </s> add } else if req.Question[0].Qtype == dns.TypeAAAA && len(ip) == net.IPv6len && ip.To4() == nil { </s> remove continue </s> add return res, nil </s> remove d.checkMatchIP(t, "block.com", "::", dns.TypeAAAA) </s> add // ...but empty IPv6 ret, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) // IPv6 d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) // ...but empty IPv4 ret, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) </s> remove text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s google.com\n0.0.0.0 block.com\n", </s> add text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s ipv6.com\n0.0.0.0 block.com\n",
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d2a9ce923eae4673a74f4c4a7e1d9ef840f04d2
dnsfilter/dnsfilter.go
} else if qtype == dns.TypeAAAA && hostRule.IP.To4() == nil { res.IP = hostRule.IP
<mask> <mask> if qtype == dns.TypeA && hostRule.IP.To4() != nil { <mask> // either IPv4 or IPv4-mapped IPv6 address <mask> res.IP = hostRule.IP.To4() <mask> return res, nil <mask> <mask> } else if qtype == dns.TypeAAAA { <mask> ip4 := hostRule.IP.To4() <mask> if ip4 == nil { <mask> res.IP = hostRule.IP <mask> return res, nil <mask> } <mask> if bytes.Equal(ip4, []byte{0, 0, 0, 0}) { <mask> // send IP="::" response for a rule "0.0.0.0 blockdomain" <mask> res.IP = net.IPv6zero <mask> return res, nil <mask> } <mask> } <mask> continue <mask> <mask> } else { <mask> log.Tracef("Rule type is unsupported: '%s' list_id: %d", </s> * dnsfilter: change DNS answer for host rules When matched by a host rule, return only the IP address specified in rule. Respond with an empty IP list to another request type. :: host -- return nothing to A, return :: to AAAA request 0.0.0.0 host -- return 0.0.0.0 to A, return nothing to AAAA request </s> remove continue </s> add return res, nil </s> remove } else if req.Question[0].Qtype == dns.TypeAAAA && ip.To4() == nil { </s> add } else if req.Question[0].Qtype == dns.TypeAAAA && len(ip) == net.IPv6len && ip.To4() == nil { </s> remove d.checkMatchIP(t, "block.com", "::", dns.TypeAAAA) </s> add // ...but empty IPv6 ret, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) // IPv6 d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) // ...but empty IPv4 ret, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) </s> remove text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s google.com\n0.0.0.0 block.com\n", </s> add text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s ipv6.com\n0.0.0.0 block.com\n",
[ "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/8d2a9ce923eae4673a74f4c4a7e1d9ef840f04d2
dnsfilter/dnsfilter.go
return res, nil
<mask> res.IP = net.IPv6zero <mask> return res, nil <mask> } <mask> } <mask> continue <mask> <mask> } else { <mask> log.Tracef("Rule type is unsupported: '%s' list_id: %d", <mask> rule.Text(), rule.GetFilterListID()) <mask> } </s> * dnsfilter: change DNS answer for host rules When matched by a host rule, return only the IP address specified in rule. Respond with an empty IP list to another request type. :: host -- return nothing to A, return :: to AAAA request 0.0.0.0 host -- return 0.0.0.0 to A, return nothing to AAAA request </s> remove return res, nil } else if qtype == dns.TypeAAAA { ip4 := hostRule.IP.To4() if ip4 == nil { res.IP = hostRule.IP return res, nil } if bytes.Equal(ip4, []byte{0, 0, 0, 0}) { // send IP="::" response for a rule "0.0.0.0 blockdomain" res.IP = net.IPv6zero return res, nil } </s> add } else if qtype == dns.TypeAAAA && hostRule.IP.To4() == nil { res.IP = hostRule.IP </s> remove } else if req.Question[0].Qtype == dns.TypeAAAA && ip.To4() == nil { </s> add } else if req.Question[0].Qtype == dns.TypeAAAA && len(ip) == net.IPv6len && ip.To4() == nil { </s> remove d.checkMatchIP(t, "block.com", "::", dns.TypeAAAA) </s> add // ...but empty IPv6 ret, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) // IPv6 d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) // ...but empty IPv4 ret, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) </s> remove // IPv6 address d.checkMatchIP(t, "google.com", addr6, dns.TypeAAAA) // block both IPv4 and IPv6 </s> add // IPv4
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d2a9ce923eae4673a74f4c4a7e1d9ef840f04d2
dnsfilter/dnsfilter.go
text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s ipv6.com\n0.0.0.0 block.com\n",
<mask> <mask> func TestEtcHostsMatching(t *testing.T) { <mask> addr := "216.239.38.120" <mask> addr6 := "::1" <mask> text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s google.com\n0.0.0.0 block.com\n", <mask> addr, addr6) <mask> filters := make(map[int]string) <mask> filters[0] = text <mask> d := NewForTest(nil, filters) <mask> defer d.Close() </s> * dnsfilter: change DNS answer for host rules When matched by a host rule, return only the IP address specified in rule. Respond with an empty IP list to another request type. :: host -- return nothing to A, return :: to AAAA request 0.0.0.0 host -- return 0.0.0.0 to A, return nothing to AAAA request </s> remove d.checkMatchIP(t, "block.com", "::", dns.TypeAAAA) </s> add // ...but empty IPv6 ret, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) // IPv6 d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) // ...but empty IPv4 ret, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) </s> remove } else if req.Question[0].Qtype == dns.TypeAAAA && ip.To4() == nil { </s> add } else if req.Question[0].Qtype == dns.TypeAAAA && len(ip) == net.IPv6len && ip.To4() == nil { </s> remove return res, nil } else if qtype == dns.TypeAAAA { ip4 := hostRule.IP.To4() if ip4 == nil { res.IP = hostRule.IP return res, nil } if bytes.Equal(ip4, []byte{0, 0, 0, 0}) { // send IP="::" response for a rule "0.0.0.0 blockdomain" res.IP = net.IPv6zero return res, nil } </s> add } else if qtype == dns.TypeAAAA && hostRule.IP.To4() == nil { res.IP = hostRule.IP </s> remove // IPv6 address d.checkMatchIP(t, "google.com", addr6, dns.TypeAAAA) // block both IPv4 and IPv6 </s> add // IPv4
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d2a9ce923eae4673a74f4c4a7e1d9ef840f04d2
dnsfilter/dnsfilter_test.go
// IPv4
<mask> d.checkMatchIP(t, "www.google.com", addr, dns.TypeA) <mask> d.checkMatchEmpty(t, "subdomain.google.com") <mask> d.checkMatchEmpty(t, "example.org") <mask> <mask> // IPv6 address <mask> d.checkMatchIP(t, "google.com", addr6, dns.TypeAAAA) <mask> <mask> // block both IPv4 and IPv6 <mask> d.checkMatchIP(t, "block.com", "0.0.0.0", dns.TypeA) <mask> d.checkMatchIP(t, "block.com", "::", dns.TypeAAAA) <mask> } <mask> <mask> // SAFE BROWSING </s> * dnsfilter: change DNS answer for host rules When matched by a host rule, return only the IP address specified in rule. Respond with an empty IP list to another request type. :: host -- return nothing to A, return :: to AAAA request 0.0.0.0 host -- return 0.0.0.0 to A, return nothing to AAAA request </s> remove d.checkMatchIP(t, "block.com", "::", dns.TypeAAAA) </s> add // ...but empty IPv6 ret, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) // IPv6 d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) // ...but empty IPv4 ret, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) </s> remove } else if req.Question[0].Qtype == dns.TypeAAAA && ip.To4() == nil { </s> add } else if req.Question[0].Qtype == dns.TypeAAAA && len(ip) == net.IPv6len && ip.To4() == nil { </s> remove return res, nil } else if qtype == dns.TypeAAAA { ip4 := hostRule.IP.To4() if ip4 == nil { res.IP = hostRule.IP return res, nil } if bytes.Equal(ip4, []byte{0, 0, 0, 0}) { // send IP="::" response for a rule "0.0.0.0 blockdomain" res.IP = net.IPv6zero return res, nil } </s> add } else if qtype == dns.TypeAAAA && hostRule.IP.To4() == nil { res.IP = hostRule.IP </s> remove text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s google.com\n0.0.0.0 block.com\n", </s> add text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s ipv6.com\n0.0.0.0 block.com\n",
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d2a9ce923eae4673a74f4c4a7e1d9ef840f04d2
dnsfilter/dnsfilter_test.go
// ...but empty IPv6 ret, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) // IPv6 d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) // ...but empty IPv4 ret, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0)
<mask> d.checkMatchIP(t, "google.com", addr6, dns.TypeAAAA) <mask> <mask> // block both IPv4 and IPv6 <mask> d.checkMatchIP(t, "block.com", "0.0.0.0", dns.TypeA) <mask> d.checkMatchIP(t, "block.com", "::", dns.TypeAAAA) <mask> } <mask> <mask> // SAFE BROWSING <mask> <mask> func TestSafeBrowsing(t *testing.T) { </s> * dnsfilter: change DNS answer for host rules When matched by a host rule, return only the IP address specified in rule. Respond with an empty IP list to another request type. :: host -- return nothing to A, return :: to AAAA request 0.0.0.0 host -- return 0.0.0.0 to A, return nothing to AAAA request </s> remove // IPv6 address d.checkMatchIP(t, "google.com", addr6, dns.TypeAAAA) // block both IPv4 and IPv6 </s> add // IPv4 </s> remove } else if req.Question[0].Qtype == dns.TypeAAAA && ip.To4() == nil { </s> add } else if req.Question[0].Qtype == dns.TypeAAAA && len(ip) == net.IPv6len && ip.To4() == nil { </s> remove return res, nil } else if qtype == dns.TypeAAAA { ip4 := hostRule.IP.To4() if ip4 == nil { res.IP = hostRule.IP return res, nil } if bytes.Equal(ip4, []byte{0, 0, 0, 0}) { // send IP="::" response for a rule "0.0.0.0 blockdomain" res.IP = net.IPv6zero return res, nil } </s> add } else if qtype == dns.TypeAAAA && hostRule.IP.To4() == nil { res.IP = hostRule.IP </s> remove text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s google.com\n0.0.0.0 block.com\n", </s> add text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s ipv6.com\n0.0.0.0 block.com\n",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d2a9ce923eae4673a74f4c4a7e1d9ef840f04d2
dnsfilter/dnsfilter_test.go
} else if req.Question[0].Qtype == dns.TypeAAAA && len(ip) == net.IPv6len && ip.To4() == nil {
<mask> // generate DNS response message with an IP address <mask> func (s *Server) genResponseWithIP(req *dns.Msg, ip net.IP) *dns.Msg { <mask> if req.Question[0].Qtype == dns.TypeA && ip.To4() != nil { <mask> return s.genARecord(req, ip.To4()) <mask> } else if req.Question[0].Qtype == dns.TypeAAAA && ip.To4() == nil { <mask> return s.genAAAARecord(req, ip) <mask> } <mask> <mask> // empty response <mask> resp := s.makeResponse(req) </s> * dnsfilter: change DNS answer for host rules When matched by a host rule, return only the IP address specified in rule. Respond with an empty IP list to another request type. :: host -- return nothing to A, return :: to AAAA request 0.0.0.0 host -- return 0.0.0.0 to A, return nothing to AAAA request </s> remove return res, nil } else if qtype == dns.TypeAAAA { ip4 := hostRule.IP.To4() if ip4 == nil { res.IP = hostRule.IP return res, nil } if bytes.Equal(ip4, []byte{0, 0, 0, 0}) { // send IP="::" response for a rule "0.0.0.0 blockdomain" res.IP = net.IPv6zero return res, nil } </s> add } else if qtype == dns.TypeAAAA && hostRule.IP.To4() == nil { res.IP = hostRule.IP </s> remove d.checkMatchIP(t, "block.com", "::", dns.TypeAAAA) </s> add // ...but empty IPv6 ret, err := d.CheckHost("block.com", dns.TypeAAAA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) // IPv6 d.checkMatchIP(t, "ipv6.com", addr6, dns.TypeAAAA) // ...but empty IPv4 ret, err = d.CheckHost("ipv6.com", dns.TypeA, &setts) assert.True(t, err == nil && ret.IsFiltered && ret.IP != nil && len(ret.IP) == 0) </s> remove continue </s> add return res, nil </s> remove text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s google.com\n0.0.0.0 block.com\n", </s> add text := fmt.Sprintf(" %s google.com www.google.com # enforce google's safesearch \n%s ipv6.com\n0.0.0.0 block.com\n",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d2a9ce923eae4673a74f4c4a7e1d9ef840f04d2
dnsforward/dnsforward.go
'GO_VERSION': '1.18.9'
<mask> 'name': 'build' <mask> <mask> 'env': <mask> 'GO_VERSION': '1.18.8' <mask> 'NODE_VERSION': '14' <mask> <mask> 'on': <mask> 'push': <mask> 'branches': </s> Pull request: 5238-default-filter-urls Updates #5238. Squashed commit of the following: commit 6a1b58bfa0f0bb8cc924e294485e8f650ce7f7aa Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:18:54 2022 +0300 all: upd go in github actions commit 98366880dc32290258dfae152be069cb84ed86c6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:08:36 2022 +0300 home: sync default filter urls </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9' </s> remove URL: "https://adaway.org/hosts.txt", </s> add URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt", </s> remove URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", </s> add URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt",
[ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d453e75a457bd0f6048e7e01ce7ca6f73779a0b
.github/workflows/build.yml
'GO_VERSION': '1.18.9'
<mask> 'name': 'lint' <mask> <mask> 'env': <mask> 'GO_VERSION': '1.18.8' <mask> <mask> 'on': <mask> 'push': <mask> 'tags': <mask> - 'v*' </s> Pull request: 5238-default-filter-urls Updates #5238. Squashed commit of the following: commit 6a1b58bfa0f0bb8cc924e294485e8f650ce7f7aa Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:18:54 2022 +0300 all: upd go in github actions commit 98366880dc32290258dfae152be069cb84ed86c6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:08:36 2022 +0300 home: sync default filter urls </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9' </s> remove URL: "https://adaway.org/hosts.txt", </s> add URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt", </s> remove URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", </s> add URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt",
[ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d453e75a457bd0f6048e7e01ce7ca6f73779a0b
.github/workflows/lint.yml
// NOTE: Keep these parameters in sync with the one put into // client/src/helpers/filters/filters.js by scripts/vetted-filters. // // TODO(a.garipov): Think of a way to make scripts/vetted-filters update // these as well if necessary.
<mask> PortDNSOverTLS: defaultPortTLS, // needs to be passed through to dnsproxy <mask> PortDNSOverQUIC: defaultPortQUIC, <mask> }, <mask> Filters: []filtering.FilterYAML{{ <mask> Filter: filtering.Filter{ID: 1}, <mask> Enabled: true, <mask> URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt", <mask> Name: "AdGuard DNS filter", </s> Pull request: 5238-default-filter-urls Updates #5238. Squashed commit of the following: commit 6a1b58bfa0f0bb8cc924e294485e8f650ce7f7aa Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:18:54 2022 +0300 all: upd go in github actions commit 98366880dc32290258dfae152be069cb84ed86c6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:08:36 2022 +0300 home: sync default filter urls </s> remove URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", </s> add URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt", </s> remove URL: "https://adaway.org/hosts.txt", </s> add URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt", </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9' </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9'
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d453e75a457bd0f6048e7e01ce7ca6f73779a0b
internal/home/config.go
URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt",
<mask> }, <mask> Filters: []filtering.FilterYAML{{ <mask> Filter: filtering.Filter{ID: 1}, <mask> Enabled: true, <mask> URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", <mask> Name: "AdGuard DNS filter", <mask> }, { <mask> Filter: filtering.Filter{ID: 2}, <mask> Enabled: false, <mask> URL: "https://adaway.org/hosts.txt", </s> Pull request: 5238-default-filter-urls Updates #5238. Squashed commit of the following: commit 6a1b58bfa0f0bb8cc924e294485e8f650ce7f7aa Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:18:54 2022 +0300 all: upd go in github actions commit 98366880dc32290258dfae152be069cb84ed86c6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:08:36 2022 +0300 home: sync default filter urls </s> remove URL: "https://adaway.org/hosts.txt", </s> add URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt", </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9' </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9'
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d453e75a457bd0f6048e7e01ce7ca6f73779a0b
internal/home/config.go
URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt",
<mask> Name: "AdGuard DNS filter", <mask> }, { <mask> Filter: filtering.Filter{ID: 2}, <mask> Enabled: false, <mask> URL: "https://adaway.org/hosts.txt", <mask> Name: "AdAway Default Blocklist", <mask> }}, <mask> DHCP: &dhcpd.ServerConfig{ <mask> LocalDomainName: "lan", <mask> Conf4: dhcpd.V4ServerConf{ </s> Pull request: 5238-default-filter-urls Updates #5238. Squashed commit of the following: commit 6a1b58bfa0f0bb8cc924e294485e8f650ce7f7aa Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:18:54 2022 +0300 all: upd go in github actions commit 98366880dc32290258dfae152be069cb84ed86c6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Dec 8 14:08:36 2022 +0300 home: sync default filter urls </s> remove URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", </s> add URL: "https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt", </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9' </s> remove 'GO_VERSION': '1.18.8' </s> add 'GO_VERSION': '1.18.9'
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d453e75a457bd0f6048e7e01ce7ca6f73779a0b
internal/home/config.go
"os/exec"
<mask> "net/http" <mask> "os" <mask> "sort" <mask> "strconv" <mask> "strings" <mask> "sync" <mask> "time" </s> + control: /install/check_config: Check and deactivate DNSStubListener </s> remove if reqData.DNS.Port != 0 && reqData.DNS.Port != config.DNS.Port { </s> add if reqData.DNS.Port != 0 {
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d936b5756cb93741a4162edb778b86ac1f78e72
control.go
if reqData.DNS.Port != 0 {
<mask> respData.Web.Status = fmt.Sprintf("%v", err) <mask> } <mask> } <mask> <mask> if reqData.DNS.Port != 0 && reqData.DNS.Port != config.DNS.Port { <mask> err = checkPacketPortAvailable(reqData.DNS.IP, reqData.DNS.Port) <mask> if err != nil { <mask> respData.DNS.Status = fmt.Sprintf("%v", err) <mask> } <mask> } </s> + control: /install/check_config: Check and deactivate DNSStubListener
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d936b5756cb93741a4162edb778b86ac1f78e72
control.go
if errorIsAddrInUse(err) { canAutofix := checkDNSStubListener() if canAutofix && reqData.DNS.Autofix { err = disableDNSStubListener() if err != nil { log.Error("Couldn't disable DNSStubListener: %s", err) } err = checkPacketPortAvailable(reqData.DNS.IP, reqData.DNS.Port) canAutofix = false } respData.DNS.CanAutofix = canAutofix }
<mask> <mask> if reqData.DNS.Port != 0 { <mask> err = checkPacketPortAvailable(reqData.DNS.IP, reqData.DNS.Port) <mask> if err != nil { <mask> respData.DNS.Status = fmt.Sprintf("%v", err) <mask> } <mask> } </s> + control: /install/check_config: Check and deactivate DNSStubListener </s> remove if reqData.DNS.Port != 0 && reqData.DNS.Port != config.DNS.Port { </s> add if reqData.DNS.Port != 0 {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d936b5756cb93741a4162edb778b86ac1f78e72
control.go
"syscall"
<mask> "path/filepath" <mask> "runtime" <mask> "strconv" <mask> "strings" <mask> "time" <mask> <mask> "github.com/AdguardTeam/dnsproxy/upstream" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/joomcode/errorx" </s> + control: /install/check_config: Check and deactivate DNSStubListener </s> remove if reqData.DNS.Port != 0 && reqData.DNS.Port != config.DNS.Port { </s> add if reqData.DNS.Port != 0 {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8d936b5756cb93741a4162edb778b86ac1f78e72
helpers.go
<mask> package home <mask> <mask> import ( <mask> "io/ioutil" <mask> "net/http" <mask> "os" <mask> "path/filepath" <mask> "sync" <mask> "time" <mask> </s> * move HTTP server code </s> remove "github.com/NYTimes/gziphandler" "github.com/gobuffalo/packr" </s> add </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove stopHTTPServer() </s> add if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil } </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove startWeb() </s> add Context.web.Start()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/config.go
<mask> LogFile string `yaml:"log_file"` // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog <mask> Verbose bool `yaml:"verbose"` // If true, verbose logging is enabled <mask> } <mask> <mask> // HTTPSServer - HTTPS Server <mask> type HTTPSServer struct { <mask> server *http.Server <mask> cond *sync.Cond // reacts to config.TLS.Enabled, PortHTTPS, CertificateChain and PrivateKey <mask> sync.Mutex // protects config.TLS <mask> shutdown bool // if TRUE, don't restart the server <mask> } <mask> <mask> // configuration is loaded from YAML <mask> // field ordering is important -- yaml fields will mirror ordering from here <mask> type configuration struct { <mask> // Raw file data to avoid re-reading of configuration file <mask> // It's reset after config is parsed </s> * move HTTP server code </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove clients clientsContainer // per-client-settings module stats stats.Stats // statistics module queryLog querylog.QueryLog // query log module dnsServer *dnsforward.Server // DNS module rdns *RDNS // rDNS module whois *Whois // WHOIS module dnsFilter *dnsfilter.Dnsfilter // DNS filtering module dhcpServer *dhcpd.Server // DHCP module auth *Auth // HTTP authentication module httpServer *http.Server // HTTP module httpsServer HTTPSServer // HTTPS module filters Filtering </s> add clients clientsContainer // per-client-settings module stats stats.Stats // statistics module queryLog querylog.QueryLog // query log module dnsServer *dnsforward.Server // DNS module rdns *RDNS // rDNS module whois *Whois // WHOIS module dnsFilter *dnsfilter.Dnsfilter // DNS filtering module dhcpServer *dhcpd.Server // DHCP module auth *Auth // HTTP authentication module filters Filtering web *Web </s> remove Context.httpsServer.cond.L.Lock() Context.httpsServer.cond.Broadcast() if Context.httpsServer.server != nil { Context.httpsServer.server.Shutdown(context.TODO()) </s> add Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO()) </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/config.go
if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil {
<mask> return <mask> } <mask> <mask> // enforce https? <mask> if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { <mask> // yes, and we want host from host:port <mask> host, _, err := net.SplitHostPort(r.Host) <mask> if err != nil { <mask> // no port in host <mask> host = r.Host </s> * move HTTP server code </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module") </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control.go
_ = Context.web.httpServer.Shutdown(context.TODO())
<mask> // this needs to be done in a goroutine because Shutdown() is a blocking call, and it will block <mask> // until all requests are finished, and _we_ are inside a request right now, so it will block indefinitely <mask> if restartHTTP { <mask> go func() { <mask> _ = Context.httpServer.Shutdown(context.TODO()) <mask> }() <mask> } <mask> <mask> returnOK(w) <mask> } </s> * move HTTP server code </s> remove Context.httpsServer.cond.L.Lock() Context.httpsServer.cond.Broadcast() if Context.httpsServer.server != nil { Context.httpsServer.server.Shutdown(context.TODO()) </s> add Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO()) </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control_install.go
if Context.web.httpsServer.server != nil {
<mask> <mask> // check if port is available <mask> // BUT: if we are already using this port, no need <mask> alreadyRunning := false <mask> if Context.httpsServer.server != nil { <mask> alreadyRunning = true <mask> } <mask> if !alreadyRunning { <mask> err = util.CheckPortAvailable(config.BindHost, data.PortHTTPS) <mask> if err != nil { </s> * move HTTP server code </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil { </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control_tls.go
if Context.web.httpsServer.server != nil {
<mask> <mask> // check if port is available <mask> // BUT: if we are already using this port, no need <mask> alreadyRunning := false <mask> if Context.httpsServer.server != nil { <mask> alreadyRunning = true <mask> } <mask> if !alreadyRunning { <mask> err = util.CheckPortAvailable(config.BindHost, data.PortHTTPS) <mask> if err != nil { </s> * move HTTP server code
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control_tls.go
Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO())
<mask> // until all requests are finished, and _we_ are inside a request right now, so it will block indefinitely <mask> if restartHTTPS { <mask> go func() { <mask> time.Sleep(time.Second) // TODO: could not find a way to reliably know that data was fully sent to client by https server, so we wait a bit to let response through before closing the server <mask> Context.httpsServer.cond.L.Lock() <mask> Context.httpsServer.cond.Broadcast() <mask> if Context.httpsServer.server != nil { <mask> Context.httpsServer.server.Shutdown(context.TODO()) <mask> } <mask> Context.httpsServer.cond.L.Unlock() <mask> }() <mask> } <mask> } </s> * move HTTP server code </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove Context.httpsServer.cond.L.Unlock() </s> add Context.web.httpsServer.cond.L.Unlock() </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control_tls.go
Context.web.httpsServer.cond.L.Unlock()
<mask> Context.httpsServer.cond.Broadcast() <mask> if Context.httpsServer.server != nil { <mask> Context.httpsServer.server.Shutdown(context.TODO()) <mask> } <mask> Context.httpsServer.cond.L.Unlock() <mask> }() <mask> } <mask> } <mask> <mask> func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) error { </s> * move HTTP server code </s> remove Context.httpsServer.cond.L.Lock() Context.httpsServer.cond.Broadcast() if Context.httpsServer.server != nil { Context.httpsServer.server.Shutdown(context.TODO()) </s> add Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO()) </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove stopHTTPServer() </s> add if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil } </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/control_tls.go
<mask> "github.com/AdguardTeam/AdGuardHome/dnsforward" <mask> "github.com/AdguardTeam/AdGuardHome/querylog" <mask> "github.com/AdguardTeam/AdGuardHome/stats" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/NYTimes/gziphandler" <mask> "github.com/gobuffalo/packr" <mask> ) <mask> <mask> const ( <mask> // Used in config to indicate that syslog or eventlog (win) should be used for logger output <mask> configSyslog = "syslog" </s> * move HTTP server code </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond // reacts to config.TLS.Enabled, PortHTTPS, CertificateChain and PrivateKey sync.Mutex // protects config.TLS shutdown bool // if TRUE, don't restart the server } </s> add </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove "net/http" </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
clients clientsContainer // per-client-settings module stats stats.Stats // statistics module queryLog querylog.QueryLog // query log module dnsServer *dnsforward.Server // DNS module rdns *RDNS // rDNS module whois *Whois // WHOIS module dnsFilter *dnsfilter.Dnsfilter // DNS filtering module dhcpServer *dhcpd.Server // DHCP module auth *Auth // HTTP authentication module filters Filtering web *Web
<mask> type homeContext struct { <mask> // Modules <mask> // -- <mask> <mask> clients clientsContainer // per-client-settings module <mask> stats stats.Stats // statistics module <mask> queryLog querylog.QueryLog // query log module <mask> dnsServer *dnsforward.Server // DNS module <mask> rdns *RDNS // rDNS module <mask> whois *Whois // WHOIS module <mask> dnsFilter *dnsfilter.Dnsfilter // DNS filtering module <mask> dhcpServer *dhcpd.Server // DHCP module <mask> auth *Auth // HTTP authentication module <mask> httpServer *http.Server // HTTP module <mask> httpsServer HTTPSServer // HTTPS module <mask> filters Filtering <mask> <mask> // Runtime properties <mask> // -- <mask> <mask> configFilename string // Config filename (can be overridden via the command line arguments) </s> * move HTTP server code </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond // reacts to config.TLS.Enabled, PortHTTPS, CertificateChain and PrivateKey sync.Mutex // protects config.TLS shutdown bool // if TRUE, don't restart the server } </s> add </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil { </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO())
[ "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/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module")
<mask> if err != nil { <mask> log.Fatalf("Cannot create DNS data dir at %s: %s", Context.getDataDir(), err) <mask> } <mask> <mask> err = initWeb() <mask> if err != nil { <mask> log.Fatalf("%s", err) <mask> } <mask> <mask> if !Context.firstRun { <mask> err := initDNSServer() <mask> if err != nil { </s> * move HTTP server code </s> remove stopHTTPServer() </s> add if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil } </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
Context.web.Start()
<mask> log.Fatal(err) <mask> } <mask> } <mask> <mask> startWeb() <mask> <mask> // wait indefinitely for other go-routines to complete their job <mask> select {} <mask> } <mask> </s> * move HTTP server code </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove Context.httpsServer.cond.L.Lock() Context.httpsServer.cond.Broadcast() if Context.httpsServer.server != nil { Context.httpsServer.server.Shutdown(context.TODO()) </s> add Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO()) </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO()) </s> remove // HTTPSServer - HTTPS Server type HTTPSServer struct { server *http.Server cond *sync.Cond // reacts to config.TLS.Enabled, PortHTTPS, CertificateChain and PrivateKey sync.Mutex // protects config.TLS shutdown bool // if TRUE, don't restart the server } </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
<mask> // wait indefinitely for other go-routines to complete their job <mask> select {} <mask> } <mask> <mask> // Initialize Web modules <mask> func initWeb() error { <mask> sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") <mask> Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) <mask> if Context.auth == nil { <mask> return fmt.Errorf("Couldn't initialize Auth module") <mask> } <mask> config.Users = nil <mask> <mask> // Initialize and run the admin Web interface <mask> box := packr.NewBox("../build/static") <mask> <mask> // if not configured, redirect / to /install.html, otherwise redirect /install.html to / <mask> http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) <mask> <mask> // add handlers for /install paths, we only need them when we're not configured yet <mask> if Context.firstRun { <mask> log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") <mask> http.Handle("/install.html", preInstallHandler(http.FileServer(box))) <mask> registerInstallHandlers() <mask> } else { <mask> registerControlHandlers() <mask> } <mask> <mask> Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) <mask> return nil <mask> } <mask> <mask> func startWeb() { <mask> // for https, we have a separate goroutine loop <mask> go httpServerLoop() <mask> <mask> // this loop is used as an ability to change listening host and/or port <mask> for !Context.httpsServer.shutdown { <mask> printHTTPAddresses("http") <mask> <mask> // we need to have new instance, because after Shutdown() the Server is not usable <mask> address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) <mask> Context.httpServer = &http.Server{ <mask> Addr: address, <mask> } <mask> err := Context.httpServer.ListenAndServe() <mask> if err != http.ErrServerClosed { <mask> cleanupAlways() <mask> log.Fatal(err) <mask> } <mask> // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop <mask> } <mask> } <mask> <mask> func httpServerLoop() { <mask> for !Context.httpsServer.shutdown { <mask> Context.httpsServer.cond.L.Lock() <mask> // this mechanism doesn't let us through until all conditions are met <mask> for config.TLS.Enabled == false || <mask> config.TLS.PortHTTPS == 0 || <mask> len(config.TLS.PrivateKeyData) == 0 || <mask> len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied <mask> Context.httpsServer.cond.Wait() <mask> } <mask> address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) <mask> // validate current TLS config and update warnings (it could have been loaded from file) <mask> data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) <mask> if !data.ValidPair { <mask> cleanupAlways() <mask> log.Fatal(data.WarningValidation) <mask> } <mask> config.Lock() <mask> config.TLS.tlsConfigStatus = data // update warnings <mask> config.Unlock() <mask> <mask> // prepare certs for HTTPS server <mask> // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests <mask> certchain := make([]byte, len(config.TLS.CertificateChainData)) <mask> copy(certchain, config.TLS.CertificateChainData) <mask> privatekey := make([]byte, len(config.TLS.PrivateKeyData)) <mask> copy(privatekey, config.TLS.PrivateKeyData) <mask> cert, err := tls.X509KeyPair(certchain, privatekey) <mask> if err != nil { <mask> cleanupAlways() <mask> log.Fatal(err) <mask> } <mask> Context.httpsServer.cond.L.Unlock() <mask> <mask> // prepare HTTPS server <mask> Context.httpsServer.server = &http.Server{ <mask> Addr: address, <mask> TLSConfig: &tls.Config{ <mask> Certificates: []tls.Certificate{cert}, <mask> MinVersion: tls.VersionTLS12, <mask> RootCAs: Context.tlsRoots, <mask> }, <mask> } <mask> <mask> printHTTPAddresses("https") <mask> err = Context.httpsServer.server.ListenAndServeTLS("", "") <mask> if err != http.ErrServerClosed { <mask> cleanupAlways() <mask> log.Fatal(err) <mask> } <mask> } <mask> } <mask> <mask> // Check if the current user has root (administrator) rights <mask> // and if not, ask and try to run as root <mask> func requireAdminRights() { <mask> admin, _ := util.HaveAdminRights() <mask> if //noinspection ALL </s> * move HTTP server code </s> remove Context.httpsServer.cond.L.Lock() Context.httpsServer.cond.Broadcast() if Context.httpsServer.server != nil { Context.httpsServer.server.Shutdown(context.TODO()) </s> add Context.web.httpsServer.cond.L.Lock() Context.web.httpsServer.cond.Broadcast() if Context.web.httpsServer.server != nil { Context.web.httpsServer.server.Shutdown(context.TODO()) </s> remove if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.httpsServer.server != nil { </s> add if config.TLS.ForceHTTPS && r.TLS == nil && config.TLS.Enabled && config.TLS.PortHTTPS != 0 && Context.web.httpsServer.server != nil { </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module") </s> remove _ = Context.httpServer.Shutdown(context.TODO()) </s> add _ = Context.web.httpServer.Shutdown(context.TODO())
[ "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", "re...
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil }
<mask> <mask> func cleanup() { <mask> log.Info("Stopping AdGuard Home") <mask> <mask> stopHTTPServer() <mask> <mask> err := stopDNSServer() <mask> if err != nil { <mask> log.Error("Couldn't stop DNS server: %s", err) <mask> } </s> * move HTTP server code </s> remove // Stop HTTP server, possibly waiting for all active connections to be closed func stopHTTPServer() { log.Info("Stopping HTTP server...") Context.httpsServer.shutdown = true if Context.httpsServer.server != nil { _ = Context.httpsServer.server.Shutdown(context.TODO()) } if Context.httpServer != nil { _ = Context.httpServer.Shutdown(context.TODO()) } if Context.auth != nil { Context.auth.Close() Context.auth = nil } log.Info("Stopped HTTP server") } </s> add </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module") </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
<mask> log.Error("Couldn't stop DHCP server: %s", err) <mask> } <mask> } <mask> <mask> // Stop HTTP server, possibly waiting for all active connections to be closed <mask> func stopHTTPServer() { <mask> log.Info("Stopping HTTP server...") <mask> Context.httpsServer.shutdown = true <mask> if Context.httpsServer.server != nil { <mask> _ = Context.httpsServer.server.Shutdown(context.TODO()) <mask> } <mask> if Context.httpServer != nil { <mask> _ = Context.httpServer.Shutdown(context.TODO()) <mask> } <mask> <mask> if Context.auth != nil { <mask> Context.auth.Close() <mask> Context.auth = nil <mask> } <mask> <mask> log.Info("Stopped HTTP server") <mask> } <mask> <mask> // This function is called before application exits <mask> func cleanupAlways() { <mask> if len(Context.pidFileName) != 0 { <mask> _ = os.Remove(Context.pidFileName) <mask> } </s> * move HTTP server code </s> remove stopHTTPServer() </s> add if Context.web != nil { Context.web.Close() Context.web = nil } if Context.auth != nil { Context.auth.Close() Context.auth = nil } </s> remove // Initialize Web modules func initWeb() error { sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { return fmt.Errorf("Couldn't initialize Auth module") } config.Users = nil // Initialize and run the admin Web interface box := packr.NewBox("../build/static") // if not configured, redirect / to /install.html, otherwise redirect /install.html to / http.Handle("/", postInstallHandler(optionalAuthHandler(gziphandler.GzipHandler(http.FileServer(box))))) // add handlers for /install paths, we only need them when we're not configured yet if Context.firstRun { log.Info("This is the first launch of AdGuard Home, redirecting everything to /install.html ") http.Handle("/install.html", preInstallHandler(http.FileServer(box))) registerInstallHandlers() } else { registerControlHandlers() } Context.httpsServer.cond = sync.NewCond(&Context.httpsServer.Mutex) return nil } func startWeb() { // for https, we have a separate goroutine loop go httpServerLoop() // this loop is used as an ability to change listening host and/or port for !Context.httpsServer.shutdown { printHTTPAddresses("http") // we need to have new instance, because after Shutdown() the Server is not usable address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) Context.httpServer = &http.Server{ Addr: address, } err := Context.httpServer.ListenAndServe() if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } // We use ErrServerClosed as a sign that we need to rebind on new address, so go back to the start of the loop } } func httpServerLoop() { for !Context.httpsServer.shutdown { Context.httpsServer.cond.L.Lock() // this mechanism doesn't let us through until all conditions are met for config.TLS.Enabled == false || config.TLS.PortHTTPS == 0 || len(config.TLS.PrivateKeyData) == 0 || len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied Context.httpsServer.cond.Wait() } address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS)) // validate current TLS config and update warnings (it could have been loaded from file) data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) if !data.ValidPair { cleanupAlways() log.Fatal(data.WarningValidation) } config.Lock() config.TLS.tlsConfigStatus = data // update warnings config.Unlock() // prepare certs for HTTPS server // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests certchain := make([]byte, len(config.TLS.CertificateChainData)) copy(certchain, config.TLS.CertificateChainData) privatekey := make([]byte, len(config.TLS.PrivateKeyData)) copy(privatekey, config.TLS.PrivateKeyData) cert, err := tls.X509KeyPair(certchain, privatekey) if err != nil { cleanupAlways() log.Fatal(err) } Context.httpsServer.cond.L.Unlock() // prepare HTTPS server Context.httpsServer.server = &http.Server{ Addr: address, TLSConfig: &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, RootCAs: Context.tlsRoots, }, } printHTTPAddresses("https") err = Context.httpsServer.server.ListenAndServeTLS("", "") if err != http.ErrServerClosed { cleanupAlways() log.Fatal(err) } } } </s> add </s> remove err = initWeb() if err != nil { log.Fatalf("%s", err) </s> add sessFilename := filepath.Join(Context.getDataDir(), "sessions.db") Context.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60) if Context.auth == nil { log.Fatalf("Couldn't initialize Auth module") } config.Users = nil webConf := WebConfig{ firstRun: Context.firstRun, BindHost: config.BindHost, BindPort: config.BindPort, TLS: config.TLS, } Context.web = CreateWeb(&webConf) if Context.web == nil { log.Fatalf("Can't initialize Web module") </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil { </s> remove if Context.httpsServer.server != nil { </s> add if Context.web.httpsServer.server != nil {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", ...
https://github.com/AdguardTeam/AdGuardHome/commit/8e4bc29103e5a9093ac277f05bb069e2e7b17db1
home/home.go
overflow-y: auto;
<mask> } <mask> <mask> .modal-body--medium { <mask> max-height: 20rem; <mask> overflow-y: scroll; <mask> } <mask> <mask> .modal-body__item:not(:first-child) { <mask> padding-top: 1.5rem; <mask> } </s> Pull request: 3395 fix table scroll styles Closes #3395 Squashed commit of the following: commit 63fd4593977cd2ac6595344f681df499dc62abb1 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Aug 16 11:58:26 2021 +0300 client: fix table scroll styles </s> remove overflow-y: scroll; </s> add overflow-y: auto; </s> remove overflow-y: scroll; </s> add overflow-y: auto;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e667d3cc4551cec2438b4f0f4fdf7749d4a7ed3
client/src/components/App/index.css
overflow-y: auto;
<mask> border-radius: 4px !important; <mask> pointer-events: auto !important; <mask> background-color: var(--white); <mask> z-index: 102; <mask> overflow-y: scroll; <mask> max-height: 100%; <mask> } <mask> <mask> .white-space--nowrap { <mask> white-space: nowrap !important; </s> Pull request: 3395 fix table scroll styles Closes #3395 Squashed commit of the following: commit 63fd4593977cd2ac6595344f681df499dc62abb1 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Aug 16 11:58:26 2021 +0300 client: fix table scroll styles </s> remove overflow-y: scroll; </s> add overflow-y: auto; </s> remove overflow-y: scroll; </s> add overflow-y: auto;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e667d3cc4551cec2438b4f0f4fdf7749d4a7ed3
client/src/components/Logs/Cells/IconTooltip.css
overflow-y: auto;
<mask> width: 100%; <mask> border-collapse: collapse; <mask> contain: layout; <mask> overflow-x: hidden; <mask> overflow-y: scroll; <mask> will-change: scroll-position; <mask> } <mask> <mask> .logs__table .logs__cell--response, <mask> .logs__table .logs__cell--client { </s> Pull request: 3395 fix table scroll styles Closes #3395 Squashed commit of the following: commit 63fd4593977cd2ac6595344f681df499dc62abb1 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Aug 16 11:58:26 2021 +0300 client: fix table scroll styles </s> remove overflow-y: scroll; </s> add overflow-y: auto; </s> remove overflow-y: scroll; </s> add overflow-y: auto;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e667d3cc4551cec2438b4f0f4fdf7749d4a7ed3
client/src/components/Logs/Logs.css
"form_error_password_length": "Password must be at least {{value}} characters long", "anonymizer_notification": "<0>Note:</0> IP anonymization is enabled. You can disable it in <1>General settings</1>."
<mask> "use_saved_key": "Use the previously saved key", <mask> "parental_control": "Parental Control", <mask> "safe_browsing": "Safe Browsing", <mask> "served_from_cache": "{{value}} <i>(served from cache)</i>", <mask> "form_error_password_length": "Password must be at least {{value}} characters long" <mask> } </s> Pull request: 4913 IP anonymizer notification Updates #4913 Squashed commit of the following: commit baa63c647bdecf10a2c5e91568231864c423c4c3 Merge: 70de6540 9ffe0787 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:53:24 2022 +0300 Merge branch 'master' into 4913-anonymizer-notification commit 70de65405fa34ba764408ce1331f90ec0ef7aec2 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:03:52 2022 +0300 client: fix text commit e6d8db0086903fe61b0aa511807e97dd12bd571c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Sep 16 20:37:42 2022 +0300 client: IP anonymizer notification </s> remove return <> {enabled && processingGetConfig && <Loading />} {enabled && !processingGetConfig && renderPage()} {!enabled && !processingGetConfig && <Disabled />} </>; </s> add return ( <> {enabled && ( <> {processingGetConfig && <Loading />} {anonymizeClientIp && <AnonymizerNotification />} {!processingGetConfig && renderPage()} </> )} {!enabled && !processingGetConfig && <Disabled />} </> );
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e89cc129cb5b7327975af31dbfaa41f9d7d0dfe
client/src/__locales/en.json
import AnonymizerNotification from './AnonymizerNotification';
<mask> import InfiniteTable from './InfiniteTable'; <mask> import './Logs.css'; <mask> import { BUTTON_PREFIX } from './Cells/helpers'; <mask> <mask> const processContent = (data) => Object.entries(data) <mask> .map(([key, value]) => { <mask> if (!value) { <mask> return null; </s> Pull request: 4913 IP anonymizer notification Updates #4913 Squashed commit of the following: commit baa63c647bdecf10a2c5e91568231864c423c4c3 Merge: 70de6540 9ffe0787 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:53:24 2022 +0300 Merge branch 'master' into 4913-anonymizer-notification commit 70de65405fa34ba764408ce1331f90ec0ef7aec2 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:03:52 2022 +0300 client: fix text commit e6d8db0086903fe61b0aa511807e97dd12bd571c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Sep 16 20:37:42 2022 +0300 client: IP anonymizer notification </s> remove "form_error_password_length": "Password must be at least {{value}} characters long" </s> add "form_error_password_length": "Password must be at least {{value}} characters long", "anonymizer_notification": "<0>Note:</0> IP anonymization is enabled. You can disable it in <1>General settings</1>." </s> remove return <> {enabled && processingGetConfig && <Loading />} {enabled && !processingGetConfig && renderPage()} {!enabled && !processingGetConfig && <Disabled />} </>; </s> add return ( <> {enabled && ( <> {processingGetConfig && <Loading />} {anonymizeClientIp && <AnonymizerNotification />} {!processingGetConfig && renderPage()} </> )} {!enabled && !processingGetConfig && <Disabled />} </> );
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e89cc129cb5b7327975af31dbfaa41f9d7d0dfe
client/src/components/Logs/index.js
anonymize_client_ip: anonymizeClientIp,
<mask> processingGetConfig, <mask> processingAdditionalLogs, <mask> processingGetLogs, <mask> } = useSelector((state) => state.queryLogs, shallowEqual); <mask> const filter = useSelector((state) => state.queryLogs.filter, shallowEqual); <mask> const logs = useSelector((state) => state.queryLogs.logs, shallowEqual); <mask> </s> Pull request: 4913 IP anonymizer notification Updates #4913 Squashed commit of the following: commit baa63c647bdecf10a2c5e91568231864c423c4c3 Merge: 70de6540 9ffe0787 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:53:24 2022 +0300 Merge branch 'master' into 4913-anonymizer-notification commit 70de65405fa34ba764408ce1331f90ec0ef7aec2 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:03:52 2022 +0300 client: fix text commit e6d8db0086903fe61b0aa511807e97dd12bd571c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Sep 16 20:37:42 2022 +0300 client: IP anonymizer notification </s> remove "form_error_password_length": "Password must be at least {{value}} characters long" </s> add "form_error_password_length": "Password must be at least {{value}} characters long", "anonymizer_notification": "<0>Note:</0> IP anonymization is enabled. You can disable it in <1>General settings</1>." </s> remove return <> {enabled && processingGetConfig && <Loading />} {enabled && !processingGetConfig && renderPage()} {!enabled && !processingGetConfig && <Disabled />} </>; </s> add return ( <> {enabled && ( <> {processingGetConfig && <Loading />} {anonymizeClientIp && <AnonymizerNotification />} {!processingGetConfig && renderPage()} </> )} {!enabled && !processingGetConfig && <Disabled />} </> );
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e89cc129cb5b7327975af31dbfaa41f9d7d0dfe
client/src/components/Logs/index.js
return ( <> {enabled && ( <> {processingGetConfig && <Loading />} {anonymizeClientIp && <AnonymizerNotification />} {!processingGetConfig && renderPage()} </> )} {!enabled && !processingGetConfig && <Disabled />} </> );
<mask> {processContent(detailedDataCurrent, buttonType)} <mask> </Modal> <mask> </>; <mask> <mask> return <> <mask> {enabled && processingGetConfig && <Loading />} <mask> {enabled && !processingGetConfig && renderPage()} <mask> {!enabled && !processingGetConfig && <Disabled />} <mask> </>; <mask> }; <mask> <mask> export default Logs; </s> Pull request: 4913 IP anonymizer notification Updates #4913 Squashed commit of the following: commit baa63c647bdecf10a2c5e91568231864c423c4c3 Merge: 70de6540 9ffe0787 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:53:24 2022 +0300 Merge branch 'master' into 4913-anonymizer-notification commit 70de65405fa34ba764408ce1331f90ec0ef7aec2 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Sep 19 18:03:52 2022 +0300 client: fix text commit e6d8db0086903fe61b0aa511807e97dd12bd571c Author: Ildar Kamalov <ik@adguard.com> Date: Fri Sep 16 20:37:42 2022 +0300 client: IP anonymizer notification </s> remove "form_error_password_length": "Password must be at least {{value}} characters long" </s> add "form_error_password_length": "Password must be at least {{value}} characters long", "anonymizer_notification": "<0>Note:</0> IP anonymization is enabled. You can disable it in <1>General settings</1>."
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e89cc129cb5b7327975af31dbfaa41f9d7d0dfe
client/src/components/Logs/index.js
config.Lock()
<mask> log.Fatal(data.WarningValidation) <mask> os.Exit(1) <mask> } <mask> config.TLS = data // update warnings <mask> config.Unlock() <mask> <mask> // prepare certs for HTTPS server </s> Fix data races found by race detector.
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e993cd788d7e5ec4e085e58799b76aa45a393b5
app.go
config.Unlock()
<mask> config.Lock() <mask> config.TLS = data // update warnings <mask> <mask> // prepare certs for HTTPS server <mask> // important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests <mask> certchain := make([]byte, len(config.TLS.CertificateChain)) <mask> copy(certchain, []byte(config.TLS.CertificateChain)) </s> Fix data races found by race detector.
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e993cd788d7e5ec4e085e58799b76aa45a393b5
app.go
httpsServer.cond.L.Lock()
<mask> go func() { <mask> time.Sleep(time.Second) // TODO: could not find a way to reliably know that data was fully sent to client by https server, so we wait a bit to let response through before closing the server <mask> httpsServer.cond.Broadcast() <mask> if httpsServer.server != nil { <mask> httpsServer.server.Shutdown(context.TODO()) <mask> } <mask> httpsServer.cond.L.Unlock() <mask> }() </s> Fix data races found by race detector.
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e993cd788d7e5ec4e085e58799b76aa45a393b5
control.go
httpsServer.cond.L.Unlock()
<mask> httpsServer.server.Shutdown(context.TODO()) <mask> } <mask> }() <mask> } <mask> } <mask> <mask> func validateCertificates(data tlsConfig) tlsConfig { </s> Fix data races found by race detector.
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8e993cd788d7e5ec4e085e58799b76aa45a393b5
control.go
const { t } = useTranslation();
<mask> const Form = ({ <mask> submitting, invalid, processingSetConfig, processingTestUpstream, handleSubmit, <mask> }) => { <mask> const dispatch = useDispatch(); <mask> const [t] = useTranslation(); <mask> const upstream_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM].values.upstream_dns); <mask> const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] <mask> .values.bootstrap_dns); <mask> <mask> const handleUpstreamTest = () => dispatch(testUpstream({ </s> - client: Fix DNS settings </s> remove const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] .values.bootstrap_dns); </s> add const bootstrap_dns = useSelector( (store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns, ); </s> remove } = ((state) => state.dnsConfig, shallowEqual); </s> add } = useSelector((state) => state.dnsConfig, shallowEqual); </s> remove import { shallowEqual, useDispatch } from 'react-redux'; </s> add import { shallowEqual, useDispatch, useSelector } from 'react-redux'; </s> remove return ( <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </div> </s> add return <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </s> remove </Card> ); </s> add </div> </Card>;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/Form.js
const bootstrap_dns = useSelector( (store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns, );
<mask> }) => { <mask> const dispatch = useDispatch(); <mask> const [t] = useTranslation(); <mask> const upstream_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM].values.upstream_dns); <mask> const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] <mask> .values.bootstrap_dns); <mask> <mask> const handleUpstreamTest = () => dispatch(testUpstream({ <mask> upstream_dns, <mask> bootstrap_dns, <mask> })); </s> - client: Fix DNS settings </s> remove const [t] = useTranslation(); </s> add const { t } = useTranslation(); </s> remove } = ((state) => state.dnsConfig, shallowEqual); </s> add } = useSelector((state) => state.dnsConfig, shallowEqual); </s> remove import { shallowEqual, useDispatch } from 'react-redux'; </s> add import { shallowEqual, useDispatch, useSelector } from 'react-redux'; </s> remove return ( <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </div> </s> add return <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </s> remove </Card> ); </s> add </div> </Card>;
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/Form.js
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
<mask> import React from 'react'; <mask> import { useTranslation } from 'react-i18next'; <mask> import { shallowEqual, useDispatch } from 'react-redux'; <mask> import Form from './Form'; <mask> import Card from '../../../ui/Card'; <mask> import { setDnsConfig } from '../../../../actions/dnsConfig'; <mask> <mask> const Upstream = () => { </s> - client: Fix DNS settings </s> remove const [t] = useTranslation(); </s> add const { t } = useTranslation(); </s> remove } = ((state) => state.dnsConfig, shallowEqual); </s> add } = useSelector((state) => state.dnsConfig, shallowEqual); </s> remove const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] .values.bootstrap_dns); </s> add const bootstrap_dns = useSelector( (store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns, ); </s> remove return ( <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </div> </s> add return <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </s> remove </Card> ); </s> add </div> </Card>;
[ "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/index.js
} = useSelector((state) => state.dnsConfig, shallowEqual);
<mask> upstream_dns, <mask> bootstrap_dns, <mask> upstream_mode, <mask> processingSetConfig, <mask> } = ((state) => state.dnsConfig, shallowEqual); <mask> <mask> const { processingTestUpstream } = ((state) => state.settings, shallowEqual); <mask> <mask> const handleSubmit = (values) => { <mask> dispatch(setDnsConfig(values)); </s> - client: Fix DNS settings </s> remove const [t] = useTranslation(); </s> add const { t } = useTranslation(); </s> remove return ( <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </div> </s> add return <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </s> remove const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] .values.bootstrap_dns); </s> add const bootstrap_dns = useSelector( (store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns, ); </s> remove import { shallowEqual, useDispatch } from 'react-redux'; </s> add import { shallowEqual, useDispatch, useSelector } from 'react-redux'; </s> remove </Card> ); </s> add </div> </Card>;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/index.js
return <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} />
<mask> const handleSubmit = (values) => { <mask> dispatch(setDnsConfig(values)); <mask> }; <mask> <mask> return ( <mask> <Card <mask> title={t('upstream_dns')} <mask> subtitle={t('upstream_dns_hint')} <mask> bodyType="card-body box-body--settings" <mask> > <mask> <div className="row"> <mask> <div className="col"> <mask> <Form <mask> initialValues={{ <mask> upstream_dns, <mask> bootstrap_dns, <mask> upstream_mode, <mask> }} <mask> onSubmit={handleSubmit} <mask> processingTestUpstream={processingTestUpstream} <mask> processingSetConfig={processingSetConfig} <mask> /> <mask> </div> <mask> </div> <mask> </Card> <mask> ); <mask> }; <mask> </s> - client: Fix DNS settings </s> remove </Card> ); </s> add </div> </Card>; </s> remove } = ((state) => state.dnsConfig, shallowEqual); </s> add } = useSelector((state) => state.dnsConfig, shallowEqual); </s> remove const [t] = useTranslation(); </s> add const { t } = useTranslation(); </s> remove const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] .values.bootstrap_dns); </s> add const bootstrap_dns = useSelector( (store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns, ); </s> remove import { shallowEqual, useDispatch } from 'react-redux'; </s> add import { shallowEqual, useDispatch, useSelector } from 'react-redux';
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", ...
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/index.js
</div> </Card>;
<mask> processingSetConfig={processingSetConfig} <mask> /> <mask> </div> <mask> </div> <mask> </Card> <mask> ); <mask> }; <mask> <mask> export default Upstream; </s> - client: Fix DNS settings </s> remove return ( <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </div> </s> add return <Card title={t('upstream_dns')} subtitle={t('upstream_dns_hint')} bodyType="card-body box-body--settings" > <div className="row"> <div className="col"> <Form initialValues={{ upstream_dns, bootstrap_dns, upstream_mode, }} onSubmit={handleSubmit} processingTestUpstream={processingTestUpstream} processingSetConfig={processingSetConfig} /> </s> remove } = ((state) => state.dnsConfig, shallowEqual); </s> add } = useSelector((state) => state.dnsConfig, shallowEqual); </s> remove import { shallowEqual, useDispatch } from 'react-redux'; </s> add import { shallowEqual, useDispatch, useSelector } from 'react-redux'; </s> remove const bootstrap_dns = useSelector((store) => store.form[FORM_NAME.UPSTREAM] .values.bootstrap_dns); </s> add const bootstrap_dns = useSelector( (store) => store.form[FORM_NAME.UPSTREAM].values.bootstrap_dns, ); </s> remove const [t] = useTranslation(); </s> add const { t } = useTranslation();
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8ea1e64c7ba8ab2b9618a6fe8c83f570b88ce124
client/src/components/Settings/Dns/Upstream/index.js
// Default blocking - REFUSED
<mask> } <mask> addr := s.dnsProxy.Addr(proxy.ProtoUDP) <mask> <mask> // <mask> // NXDomain blocking <mask> // <mask> req := dns.Msg{} <mask> req.Id = dns.Id() <mask> req.RecursionDesired = true <mask> req.Question = []dns.Question{ </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove // If there is no IP, return NXDOMAIN </s> add // If there is no IP, return REFUSED </s> remove d.Res = s.genNXDomain(d.Req) </s> add d.Res = s.makeResponseREFUSED(d.Req)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/dnsforward_test.go
assert.Equal(t, dns.RcodeRefused, reply.Rcode)
<mask> reply, err := dns.Exchange(&req, addr.String()) <mask> if err != nil { <mask> t.Fatalf("Couldn't talk to server %s: %s", addr, err) <mask> } <mask> if reply.Rcode != dns.RcodeNameError { <mask> t.Fatalf("Wrong response: %s", reply.String()) <mask> } <mask> <mask> err = s.Stop() <mask> if err != nil { <mask> t.Fatalf("DNS server failed to stop: %s", err) <mask> } </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> remove // If there is no IP, return NXDOMAIN </s> add // If there is no IP, return REFUSED </s> remove return s.genNXDomain(m) </s> add return s.makeResponseREFUSED(m) </s> remove d.Res = s.genNXDomain(d.Req) </s> add d.Res = s.makeResponseREFUSED(d.Req)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/dnsforward_test.go
assert.Equal(t, dns.RcodeRefused, reply.Rcode)
<mask> // response is blocked <mask> req := createTestMessage("badhost.") <mask> reply, err := dns.Exchange(req, addr.String()) <mask> assert.Nil(t, err, nil) <mask> assert.Equal(t, dns.RcodeNameError, reply.Rcode) <mask> <mask> // 'whitelist.example.org' has a canonical name 'null.example.org' which is blocked by filters <mask> // but 'whitelist.example.org' is in a whitelist: <mask> // response isn't blocked <mask> req = createTestMessage("whitelist.example.org.") </s> * DNS: use REFUSED DNS error code as the default blocking method </s> remove assert.Equal(t, dns.RcodeNameError, reply.Rcode) </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode) </s> remove // NXDomain blocking </s> add // Default blocking - REFUSED </s> remove // If there is no IP, return NXDOMAIN </s> add // If there is no IP, return REFUSED </s> remove if reply.Rcode != dns.RcodeNameError { t.Fatalf("Wrong response: %s", reply.String()) } </s> add assert.Equal(t, dns.RcodeRefused, reply.Rcode)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/8f017d2c0e25969bd86eafa4adbc184e41c61dc0
dnsforward/dnsforward_test.go