code_before
stringlengths 16
1.81M
| edits
stringlengths 4
328k
| next_edit
stringlengths 0
76.5k
| code_after
stringlengths 3
49.9M
| label_window
sequencelengths 4
1.81k
| instruction
stringlengths 20
51.9k
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|---|---|---|---|
}
a2 = convertMapToArray(m, maxDomains)
d["top_blocked_domains"] = convertTopArray(a2)
m = map[string]uint64{}
for _, u := range units {
for _, it := range u.Clients {
m[it.Name] += it.Count
}
}
a2 = convertMapToArray(m, maxClients)
d["top_clients"] = convertTopArray(a2)
// total counters:
| </s> remove a2 = convertMapToArray(m, maxDomains)
d["top_blocked_domains"] = convertTopArray(a2)
</s> add </s> remove a2 = convertMapToArray(m, maxClients)
d["top_clients"] = convertTopArray(a2)
</s> add </s> remove a2 := convertMapToArray(m, maxDomains)
d["top_queried_domains"] = convertTopArray(a2)
</s> add </s> remove m := map[string]uint64{}
for _, u := range units {
for _, it := range u.Domains {
m[it.Name] += it.Count
}
</s> add dnsQueries := statsCollector(func(u *unitDB) (num uint64) { return u.NTotal })
if timeUnit != Hours && len(dnsQueries) != int(limit/24) {
log.Fatalf("len(dnsQueries) != limit: %d %d", len(dnsQueries), limit) </s> remove m = map[string]uint64{}
for _, u := range units {
for _, it := range u.BlockedDomains {
m[it.Name] += it.Count
}
</s> add statsData := map[string]interface{}{
"dns_queries": dnsQueries,
"blocked_filtering": statsCollector(func(u *unitDB) (num uint64) { return u.NResult[RFiltered] }),
"replaced_safebrowsing": statsCollector(func(u *unitDB) (num uint64) { return u.NResult[RSafeBrowsing] }),
"replaced_parental": statsCollector(func(u *unitDB) (num uint64) { return u.NResult[RParental] }),
"top_queried_domains": topsCollector(maxDomains, func(u *unitDB) (pairs []countPair) { return u.Domains }),
"top_blocked_domains": topsCollector(maxDomains, func(u *unitDB) (pairs []countPair) { return u.BlockedDomains }),
"top_clients": topsCollector(maxClients, func(u *unitDB) (pairs []countPair) { return u.Clients }), | for dataKey, dataValue := range statsData {
d[dataKey] = dataValue | }
a2 = convertMapToArray(m, maxDomains)
d["top_blocked_domains"] = convertTopArray(a2)
for dataKey, dataValue := range statsData {
d[dataKey] = dataValue
for dataKey, dataValue := range statsData {
d[dataKey] = dataValue
for dataKey, dataValue := range statsData {
d[dataKey] = dataValue
for dataKey, dataValue := range statsData {
d[dataKey] = dataValue
for dataKey, dataValue := range statsData {
d[dataKey] = dataValue
}
a2 = convertMapToArray(m, maxClients)
d["top_clients"] = convertTopArray(a2)
// total counters: | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 2271 handle nolint
Merge in DNS/adguard-home from 2271-handle-nolint to master
Closes #2271.
Squashed commit of the following:
commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e
Merge: fc2acd898 642dcd647
Author: Eugene Burkov <[email protected]>
Date: Fri Nov 20 17:12:28 2020 +0300
Merge branch 'master' into 2271-handle-nolint
commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 17 11:55:29 2020 +0300
dnsforward: fix test output strings
commit c4ebae6ea9c293bad239519c44ca5a6c576bb921
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 22:43:20 2020 +0300
dnsfilter: make package pass tests
commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 20:05:00 2020 +0300
querylog: make decoding pass tests
commit ab5850d24c50d53b8393f2de448cc340241351d7
Merge: 6ed2066bf 8a9c6e8a0
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 19:48:31 2020 +0300
Merge branch 'master' into 2271-handle-nolint
commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 18:13:45 2020 +0300
home: fix tests naming
commit af691081fb02b7500a746b16492f01f7f9befe9a
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 12:15:49 2020 +0300
home: impove code quality
commit 2914cd3cd23ef2a1964116baab9187d89b377f86
Author: Eugene Burkov <[email protected]>
Date: Wed Nov 11 15:46:39 2020 +0300
* querylog: remove useless check
commit 9996840650e784ccc76d1f29964560435ba27dc7
Author: Eugene Burkov <[email protected]>
Date: Wed Nov 11 13:18:34 2020 +0300
* all: fix noticed defects
commit 2b15293e59337f70302fbc0db81ebb26bee0bed2
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 20:15:53 2020 +0300
* stats: remove last nolint directive
commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 18:35:41 2020 +0300
* all: remove another nolint directive
commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 18:11:28 2020 +0300
* querylog: remove nolint directive
commit 226ddbf2c92f737f085b44a4ddf6daec7b602153
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 16:35:26 2020 +0300
* home: remove nolint directive
commit 2ea3086ad41e9003282add7e996ae722d72d878b
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 16:13:57 2020 +0300
* home: reduce cyclomatic complexity of run function
commit f479b480c48e0bb832ddef8f57586f56b8a55bab
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 15:35:46 2020 +0300
* home: use crypto/rand instead of math/rand
commit a28d4a53e3b930136b036606fc7e78404f1d208b
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 14:11:07 2020 +0300
* dnsforward: remove gocyclo nolint directive
commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 11:45:49 2020 +0300
all *: remove some nolint directives
Updates #2271. | https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4 | internal/stats/stats_unit.go |
for _, it := range u.Clients {
m[it.Name] += it.Count
}
}
a2 = convertMapToArray(m, maxClients)
d["top_clients"] = convertTopArray(a2)
// total counters:
sum := unitDB{}
sum.NResult = make([]uint64, rLast)
| </s> remove m = map[string]uint64{}
for _, u := range units {
for _, it := range u.Clients {
m[it.Name] += it.Count
}
</s> add for dataKey, dataValue := range statsData {
d[dataKey] = dataValue </s> remove a2 = convertMapToArray(m, maxDomains)
d["top_blocked_domains"] = convertTopArray(a2)
</s> add </s> remove a2 := convertMapToArray(m, maxDomains)
d["top_queried_domains"] = convertTopArray(a2)
</s> add </s> remove m := map[string]uint64{}
for _, u := range units {
for _, it := range u.Domains {
m[it.Name] += it.Count
}
</s> add dnsQueries := statsCollector(func(u *unitDB) (num uint64) { return u.NTotal })
if timeUnit != Hours && len(dnsQueries) != int(limit/24) {
log.Fatalf("len(dnsQueries) != limit: %d %d", len(dnsQueries), limit) </s> remove m = map[string]uint64{}
for _, u := range units {
for _, it := range u.BlockedDomains {
m[it.Name] += it.Count
}
</s> add statsData := map[string]interface{}{
"dns_queries": dnsQueries,
"blocked_filtering": statsCollector(func(u *unitDB) (num uint64) { return u.NResult[RFiltered] }),
"replaced_safebrowsing": statsCollector(func(u *unitDB) (num uint64) { return u.NResult[RSafeBrowsing] }),
"replaced_parental": statsCollector(func(u *unitDB) (num uint64) { return u.NResult[RParental] }),
"top_queried_domains": topsCollector(maxDomains, func(u *unitDB) (pairs []countPair) { return u.Domains }),
"top_blocked_domains": topsCollector(maxDomains, func(u *unitDB) (pairs []countPair) { return u.BlockedDomains }),
"top_clients": topsCollector(maxClients, func(u *unitDB) (pairs []countPair) { return u.Clients }), | for _, it := range u.Clients {
m[it.Name] += it.Count
}
}
// total counters:
sum := unitDB{}
sum.NResult = make([]uint64, rLast) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request: 2271 handle nolint
Merge in DNS/adguard-home from 2271-handle-nolint to master
Closes #2271.
Squashed commit of the following:
commit fde5c8795ac79e1f7d02ba8c8e369b5a724a000e
Merge: fc2acd898 642dcd647
Author: Eugene Burkov <[email protected]>
Date: Fri Nov 20 17:12:28 2020 +0300
Merge branch 'master' into 2271-handle-nolint
commit fc2acd89871de08c39e80ace9e5bb8a7acb7afba
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 17 11:55:29 2020 +0300
dnsforward: fix test output strings
commit c4ebae6ea9c293bad239519c44ca5a6c576bb921
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 22:43:20 2020 +0300
dnsfilter: make package pass tests
commit f2d98c6acabd8977f3b1b361987eaa31eb6eb9ad
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 20:05:00 2020 +0300
querylog: make decoding pass tests
commit ab5850d24c50d53b8393f2de448cc340241351d7
Merge: 6ed2066bf 8a9c6e8a0
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 19:48:31 2020 +0300
Merge branch 'master' into 2271-handle-nolint
commit 6ed2066bf567e13dd14cfa16fc7b109b59fa39ef
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 18:13:45 2020 +0300
home: fix tests naming
commit af691081fb02b7500a746b16492f01f7f9befe9a
Author: Eugene Burkov <[email protected]>
Date: Mon Nov 16 12:15:49 2020 +0300
home: impove code quality
commit 2914cd3cd23ef2a1964116baab9187d89b377f86
Author: Eugene Burkov <[email protected]>
Date: Wed Nov 11 15:46:39 2020 +0300
* querylog: remove useless check
commit 9996840650e784ccc76d1f29964560435ba27dc7
Author: Eugene Burkov <[email protected]>
Date: Wed Nov 11 13:18:34 2020 +0300
* all: fix noticed defects
commit 2b15293e59337f70302fbc0db81ebb26bee0bed2
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 20:15:53 2020 +0300
* stats: remove last nolint directive
commit b2e1ddf7b58196a2fdbf879f084edb41ca1aa1eb
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 18:35:41 2020 +0300
* all: remove another nolint directive
commit c6fc5cfcc9c95ab9e570a95ab41c3e5c0125e62e
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 18:11:28 2020 +0300
* querylog: remove nolint directive
commit 226ddbf2c92f737f085b44a4ddf6daec7b602153
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 16:35:26 2020 +0300
* home: remove nolint directive
commit 2ea3086ad41e9003282add7e996ae722d72d878b
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 16:13:57 2020 +0300
* home: reduce cyclomatic complexity of run function
commit f479b480c48e0bb832ddef8f57586f56b8a55bab
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 15:35:46 2020 +0300
* home: use crypto/rand instead of math/rand
commit a28d4a53e3b930136b036606fc7e78404f1d208b
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 14:11:07 2020 +0300
* dnsforward: remove gocyclo nolint directive
commit 64a0a324cc2b20614ceec3ccc6505e960fe526e9
Author: Eugene Burkov <[email protected]>
Date: Tue Nov 10 11:45:49 2020 +0300
all *: remove some nolint directives
Updates #2271. | https://github.com/AdguardTeam/AdGuardHome/commit/3045da1742ee0e75392de1623900d7d88b08f0b4 | internal/stats/stats_unit.go |
|
fseeker fileSeeker // file seeker object
fpos uint64 // current file offset
nSeekRequests uint32 // number of Seek() requests made (finding a new line doesn't count)
timecnt uint64
}
type fileSeeker struct {
target uint64 // target value
| </s> remove log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds()))
</s> add log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d",
r.count, elapsed, perunit, r.nSeekRequests)
// timePercent := uint64(0)
// if elapsed.Nanoseconds() != 0 {
// timePercent = r.timecnt * 100 / uint64(elapsed.Nanoseconds())
// }
// log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
// r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, timePercent) </s> remove st := time.Now()
</s> add // st := time.Now() </s> remove r.timecnt += uint64(time.Now().Sub(st).Nanoseconds())
</s> add // r.timecnt += uint64(time.Now().Sub(st).Nanoseconds()) | // timecnt uint64 | fseeker fileSeeker // file seeker object
fpos uint64 // current file offset
nSeekRequests uint32 // number of Seek() requests made (finding a new line doesn't count)
// timecnt uint64
}
type fileSeeker struct {
target uint64 // target value
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - querylog: remove time counter (fix zero div exception) | https://github.com/AdguardTeam/AdGuardHome/commit/305df63054852e760cce16d7ede38a01ef88be3f | querylog/querylog_file.go |
var perunit time.Duration
if r.count > 0 {
perunit = elapsed / time.Duration(r.count)
}
log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds()))
if r.f != nil {
r.f.Close()
}
}
| </s> remove st := time.Now()
</s> add // st := time.Now() </s> remove r.timecnt += uint64(time.Now().Sub(st).Nanoseconds())
</s> add // r.timecnt += uint64(time.Now().Sub(st).Nanoseconds()) </s> remove timecnt uint64
</s> add // timecnt uint64 | log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d",
r.count, elapsed, perunit, r.nSeekRequests)
// timePercent := uint64(0)
// if elapsed.Nanoseconds() != 0 {
// timePercent = r.timecnt * 100 / uint64(elapsed.Nanoseconds())
// }
// log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
// r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, timePercent) | var perunit time.Duration
if r.count > 0 {
perunit = elapsed / time.Duration(r.count)
}
log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d",
r.count, elapsed, perunit, r.nSeekRequests)
// timePercent := uint64(0)
// if elapsed.Nanoseconds() != 0 {
// timePercent = r.timecnt * 100 / uint64(elapsed.Nanoseconds())
// }
// log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
// r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, timePercent)
log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d",
r.count, elapsed, perunit, r.nSeekRequests)
// timePercent := uint64(0)
// if elapsed.Nanoseconds() != 0 {
// timePercent = r.timecnt * 100 / uint64(elapsed.Nanoseconds())
// }
// log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
// r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, timePercent)
if r.f != nil {
r.f.Close()
}
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - querylog: remove time counter (fix zero div exception) | https://github.com/AdguardTeam/AdGuardHome/commit/305df63054852e760cce16d7ede38a01ef88be3f | querylog/querylog_file.go |
if !r.applySearch(str) {
continue
}
st := time.Now()
var ent logEntry
decode(&ent, str)
r.timecnt += uint64(time.Now().Sub(st).Nanoseconds())
return &ent
| </s> remove r.timecnt += uint64(time.Now().Sub(st).Nanoseconds())
</s> add // r.timecnt += uint64(time.Now().Sub(st).Nanoseconds()) </s> remove log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds()))
</s> add log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d",
r.count, elapsed, perunit, r.nSeekRequests)
// timePercent := uint64(0)
// if elapsed.Nanoseconds() != 0 {
// timePercent = r.timecnt * 100 / uint64(elapsed.Nanoseconds())
// }
// log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
// r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, timePercent) </s> remove timecnt uint64
</s> add // timecnt uint64 | // st := time.Now() | if !r.applySearch(str) {
continue
}
// st := time.Now()
var ent logEntry
decode(&ent, str)
r.timecnt += uint64(time.Now().Sub(st).Nanoseconds())
return &ent | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - querylog: remove time counter (fix zero div exception) | https://github.com/AdguardTeam/AdGuardHome/commit/305df63054852e760cce16d7ede38a01ef88be3f | querylog/querylog_file.go |
st := time.Now()
var ent logEntry
decode(&ent, str)
r.timecnt += uint64(time.Now().Sub(st).Nanoseconds())
return &ent
}
}
| </s> remove st := time.Now()
</s> add // st := time.Now() </s> remove log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, r.timecnt*100/uint64(elapsed.Nanoseconds()))
</s> add log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d",
r.count, elapsed, perunit, r.nSeekRequests)
// timePercent := uint64(0)
// if elapsed.Nanoseconds() != 0 {
// timePercent = r.timecnt * 100 / uint64(elapsed.Nanoseconds())
// }
// log.Debug("querylog: read %d entries in %v, %v/entry, seek-reqs:%d time:%dus (%d%%)",
// r.count, elapsed, perunit, r.nSeekRequests, r.timecnt/1000, timePercent) </s> remove timecnt uint64
</s> add // timecnt uint64 | // r.timecnt += uint64(time.Now().Sub(st).Nanoseconds()) |
st := time.Now()
var ent logEntry
decode(&ent, str)
// r.timecnt += uint64(time.Now().Sub(st).Nanoseconds())
return &ent
}
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - querylog: remove time counter (fix zero div exception) | https://github.com/AdguardTeam/AdGuardHome/commit/305df63054852e760cce16d7ede38a01ef88be3f | querylog/querylog_file.go |
EnableEDNSClientSubnet: s.conf.EnableEDNSClientSubnet,
MaxGoroutines: int(s.conf.MaxGoroutines),
}
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
if s.conf.CacheSize != 0 {
proxyConfig.CacheEnabled = true
proxyConfig.CacheSizeBytes = int(s.conf.CacheSize)
}
| </s> remove var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
</s> add }
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0]) </s> remove if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 {
</s> add if len(s.conf.CertificateChainData) == 0 || len(s.conf.PrivateKeyData) == 0 {
return nil
}
if s.conf.TLSListenAddr == nil &&
s.conf.QUICListenAddr == nil {
return nil
}
if s.conf.TLSListenAddr != nil { </s> remove
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
</s> add if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) </s> remove proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
</s> add proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12, | EnableEDNSClientSubnet: s.conf.EnableEDNSClientSubnet,
MaxGoroutines: int(s.conf.MaxGoroutines),
}
if s.conf.CacheSize != 0 {
proxyConfig.CacheEnabled = true
proxyConfig.CacheSizeBytes = int(s.conf.CacheSize)
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | dnsforward/config.go |
|
}
// prepareTLS - prepares TLS configuration for the DNS proxy
func (s *Server) prepareTLS(proxyConfig *proxy.Config) error {
if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 {
proxyConfig.TLSListenAddr = []*net.TCPAddr{s.conf.TLSListenAddr}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
| </s> remove var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
</s> add }
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0]) </s> remove return errorx.Decorate(err, "Failed to parse TLS keypair")
</s> add return errorx.Decorate(err, "x509.ParseCertificate(): %s", err) </s> remove
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
</s> add if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) </s> remove if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
</s> add | if len(s.conf.CertificateChainData) == 0 || len(s.conf.PrivateKeyData) == 0 {
return nil
}
if s.conf.TLSListenAddr == nil &&
s.conf.QUICListenAddr == nil {
return nil
}
if s.conf.TLSListenAddr != nil { | }
// prepareTLS - prepares TLS configuration for the DNS proxy
func (s *Server) prepareTLS(proxyConfig *proxy.Config) error {
if len(s.conf.CertificateChainData) == 0 || len(s.conf.PrivateKeyData) == 0 {
return nil
}
if s.conf.TLSListenAddr == nil &&
s.conf.QUICListenAddr == nil {
return nil
}
if s.conf.TLSListenAddr != nil {
proxyConfig.TLSListenAddr = []*net.TCPAddr{s.conf.TLSListenAddr}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | dnsforward/config.go |
// prepareTLS - prepares TLS configuration for the DNS proxy
func (s *Server) prepareTLS(proxyConfig *proxy.Config) error {
if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 {
proxyConfig.TLSListenAddr = []*net.TCPAddr{s.conf.TLSListenAddr}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
| </s> remove if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 {
</s> add if len(s.conf.CertificateChainData) == 0 || len(s.conf.PrivateKeyData) == 0 {
return nil
}
if s.conf.TLSListenAddr == nil &&
s.conf.QUICListenAddr == nil {
return nil
}
if s.conf.TLSListenAddr != nil { </s> remove return errorx.Decorate(err, "Failed to parse TLS keypair")
</s> add return errorx.Decorate(err, "x509.ParseCertificate(): %s", err) </s> remove
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
</s> add if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) </s> remove if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
</s> add | }
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0]) | // prepareTLS - prepares TLS configuration for the DNS proxy
func (s *Server) prepareTLS(proxyConfig *proxy.Config) error {
if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 {
proxyConfig.TLSListenAddr = []*net.TCPAddr{s.conf.TLSListenAddr}
}
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
}
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | dnsforward/config.go |
proxyConfig.TLSListenAddr = []*net.TCPAddr{s.conf.TLSListenAddr}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
| </s> remove var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
</s> add }
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0]) </s> remove if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 {
</s> add if len(s.conf.CertificateChainData) == 0 || len(s.conf.PrivateKeyData) == 0 {
return nil
}
if s.conf.TLSListenAddr == nil &&
s.conf.QUICListenAddr == nil {
return nil
}
if s.conf.TLSListenAddr != nil { </s> remove
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
</s> add if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) </s> remove if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
</s> add | return errorx.Decorate(err, "x509.ParseCertificate(): %s", err) | proxyConfig.TLSListenAddr = []*net.TCPAddr{s.conf.TLSListenAddr}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | dnsforward/config.go |
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
}
proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
| </s> remove proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
</s> add proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12, </s> remove return errorx.Decorate(err, "Failed to parse TLS keypair")
</s> add return errorx.Decorate(err, "x509.ParseCertificate(): %s", err) </s> remove var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
</s> add }
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0]) </s> remove if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 {
</s> add if len(s.conf.CertificateChainData) == 0 || len(s.conf.PrivateKeyData) == 0 {
return nil
}
if s.conf.TLSListenAddr == nil &&
s.conf.QUICListenAddr == nil {
return nil
}
if s.conf.TLSListenAddr != nil { | if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) | s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | dnsforward/config.go |
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
| </s> remove
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
</s> add if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) </s> remove proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
</s> add proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12, </s> remove if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
</s> add </s> remove var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
</s> add }
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0]) </s> remove return errorx.Decorate(err, "Failed to parse TLS keypair")
</s> add return errorx.Decorate(err, "x509.ParseCertificate(): %s", err) | } | } else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
}
proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
| [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | dnsforward/config.go |
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
}
proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
}
upstream.RootCAs = s.conf.TLSv12Roots
upstream.CipherSuites = s.conf.TLSCiphers
return nil
}
| </s> remove
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
</s> add if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) </s> remove if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
</s> add </s> remove var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
</s> add }
if s.conf.QUICListenAddr != nil {
proxyConfig.QUICListenAddr = []*net.UDPAddr{s.conf.QUICListenAddr}
}
var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0]) </s> remove return errorx.Decorate(err, "Failed to parse TLS keypair")
</s> add return errorx.Decorate(err, "x509.ParseCertificate(): %s", err) | proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12, | log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
}
proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
upstream.RootCAs = s.conf.TLSv12Roots
upstream.CipherSuites = s.conf.TLSCiphers
return nil
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | dnsforward/config.go |
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"math/big"
"net"
"sort"
"sync"
| </s> remove proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
</s> add proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12, </s> remove
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
</s> add if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) | "fmt" | "crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"math/big"
"net"
"sort"
"sync" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | dnsforward/dnsforward_test.go |
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw=
| </s> remove proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
</s> add proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12, </s> remove
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
</s> add if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) | golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= | golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | go.sum |
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
| </s> remove proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12,
}
</s> add proxyConfig.TLSConfig = &tls.Config{
GetCertificate: s.onGetCertificate,
MinVersion: tls.VersionTLS12, </s> remove
if s.conf.StrictSNICheck {
x, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return errorx.Decorate(err, "x509.ParseCertificate(): %s", err)
}
if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName)
}
</s> add if len(x.DNSNames) != 0 {
s.conf.dnsNames = x.DNSNames
log.Debug("DNS: using DNS names from certificate's SAN: %v", x.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, x.Subject.CommonName)
log.Debug("DNS: using DNS name from certificate's CN: %s", x.Subject.CommonName) | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | - (dnsforward): fixed running only quic, added a test
QUIC was not initialized if DOT port is not set. Also, there were no
tests on DoQ functionality. | https://github.com/AdguardTeam/AdGuardHome/commit/314867734ac60e430143a25060ee6e62e027a9cb | go.sum |
</symbol>
<symbol id="question" width="20px" height="20px">
<g transform="translate(-982.000000, -454.000000) translate(416.000000, 440.000000) translate(564.000000, 12.000000)"
fill="none" fillRule="evenodd">
<circle stroke="currentColor" strokeWidth="1.5" cx="12" cy="12" r="9.25" />
| </s> | <symbol id="service_qq" viewBox="0 0 32 32" >
<g fill="none" fillRule="evenodd">
<path d="M0 0h32v32H0z" />
<g fill="currentColor" fillRule="nonzero">
<path d="M11.25 32C8.342 32 6 30.74 6 29.242c0-1.497 2.342-2.757 5.25-2.757s5.25 1.26 5.25 2.757S14.158 32 11.25 32zM27 29.242c0-1.497-2.342-2.757-5.25-2.757s-5.25 1.26-5.25 2.757S18.842 32 21.75 32 27 30.74 27 29.242zM14.885 7.182c0 .63-.323 1.182-.808 1.182-.485 0-.808-.552-.808-1.182 0-.63.323-1.182.808-1.182.485 0 .808.552.808 1.182zM18.923 6c-.485 0-.808.552-.808 1.182 0 .63.323-.394.808-.394.485 0 .808 1.024.808.394S19.408 6 18.923 6z" />
<path d="M6.653 12.638s4.685 2.465 9.926 2.465c5.242 0 9.927-2.465 9.927-2.465.112-.09.217-.161.316-.212-.002-1.088-.078-2.026-.078-2.808C26.744 4.292 22.138 0 16.5 0S6.176 4.292 6.176 9.618v2.78c.146.042.3.113.477.24zm12.626-8.664c1.112 0 1.986 1.272 1.986 2.782s-.874 2.782-1.986 2.782c-1.111 0-1.985-1.271-1.985-2.782 0-1.51.874-2.782 1.985-2.782zm-5.558 0c1.111 0 1.985 1.272 1.985 2.782s-.874 2.782-1.985 2.782c-1.112 0-1.986-1.271-1.986-2.782 0-1.51.874-2.782 1.986-2.782zm2.779 6.624c2.912 0 5.294.464 5.294.994s-2.382 1.656-5.294 1.656c-2.912 0-5.294-1.126-5.294-1.656s2.382-.994 5.294-.994zm11.374 5.182c-.058.038-.108.076-.177.117-.159.08-5.241 3.18-11.038 3.18-1.43 0-2.7-.239-3.97-.477-.239 1.67-.239 3.259-.239 3.974 0 1.272-1.032 1.193-2.303 1.272-1.27 0-2.223.16-2.303-1.033 0-.16-.08-2.782.397-5.564-1.588-.716-2.62-1.272-2.7-1.352a3.293 3.293 0 01-.335-.216C4.012 17.55 3 19.598 3 21.223c0 3.815 1.112 3.418 1.112 3.418.476 0 1.27-.795 1.985-1.67C7.765 27.662 11.735 31 16.5 31c4.765 0 8.735-3.338 10.403-8.028.715.874 1.509 1.669 1.985 1.669 0 0 1.112.397 1.112-3.418 0-1.588-.968-3.631-2.126-5.443z" />
</g>
</g>
</symbol>
| </symbol>
<symbol id="service_qq" viewBox="0 0 32 32" >
<g fill="none" fillRule="evenodd">
<path d="M0 0h32v32H0z" />
<g fill="currentColor" fillRule="nonzero">
<path d="M11.25 32C8.342 32 6 30.74 6 29.242c0-1.497 2.342-2.757 5.25-2.757s5.25 1.26 5.25 2.757S14.158 32 11.25 32zM27 29.242c0-1.497-2.342-2.757-5.25-2.757s-5.25 1.26-5.25 2.757S18.842 32 21.75 32 27 30.74 27 29.242zM14.885 7.182c0 .63-.323 1.182-.808 1.182-.485 0-.808-.552-.808-1.182 0-.63.323-1.182.808-1.182.485 0 .808.552.808 1.182zM18.923 6c-.485 0-.808.552-.808 1.182 0 .63.323-.394.808-.394.485 0 .808 1.024.808.394S19.408 6 18.923 6z" />
<path d="M6.653 12.638s4.685 2.465 9.926 2.465c5.242 0 9.927-2.465 9.927-2.465.112-.09.217-.161.316-.212-.002-1.088-.078-2.026-.078-2.808C26.744 4.292 22.138 0 16.5 0S6.176 4.292 6.176 9.618v2.78c.146.042.3.113.477.24zm12.626-8.664c1.112 0 1.986 1.272 1.986 2.782s-.874 2.782-1.986 2.782c-1.111 0-1.985-1.271-1.985-2.782 0-1.51.874-2.782 1.985-2.782zm-5.558 0c1.111 0 1.985 1.272 1.985 2.782s-.874 2.782-1.985 2.782c-1.112 0-1.986-1.271-1.986-2.782 0-1.51.874-2.782 1.986-2.782zm2.779 6.624c2.912 0 5.294.464 5.294.994s-2.382 1.656-5.294 1.656c-2.912 0-5.294-1.126-5.294-1.656s2.382-.994 5.294-.994zm11.374 5.182c-.058.038-.108.076-.177.117-.159.08-5.241 3.18-11.038 3.18-1.43 0-2.7-.239-3.97-.477-.239 1.67-.239 3.259-.239 3.974 0 1.272-1.032 1.193-2.303 1.272-1.27 0-2.223.16-2.303-1.033 0-.16-.08-2.782.397-5.564-1.588-.716-2.62-1.272-2.7-1.352a3.293 3.293 0 01-.335-.216C4.012 17.55 3 19.598 3 21.223c0 3.815 1.112 3.418 1.112 3.418.476 0 1.27-.795 1.985-1.67C7.765 27.662 11.735 31 16.5 31c4.765 0 8.735-3.338 10.403-8.028.715.874 1.509 1.669 1.985 1.669 0 0 1.112.397 1.112-3.418 0-1.588-.968-3.631-2.126-5.443z" />
</g>
</g>
</symbol>
<symbol id="question" width="20px" height="20px">
<g transform="translate(-982.000000, -454.000000) translate(416.000000, 440.000000) translate(564.000000, 12.000000)"
fill="none" fillRule="evenodd">
<circle stroke="currentColor" strokeWidth="1.5" cx="12" cy="12" r="9.25" /> | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | + dnsfilter, client: Add qq to blocked services
Squashed commit of the following:
commit ffb2a1065fc9edd2b840cccbb96a0a2c1334bf00
Merge: 0f966d5b 3acfaa16
Author: ArtemBaskal <[email protected]>
Date: Tue Oct 20 11:19:39 2020 +0300
Merge branch 'master' into dnsfilter/update_blocked_services
commit 0f966d5b00f96c93bf778e944d68f62ebcdeaa50
Author: ArtemBaskal <[email protected]>
Date: Mon Oct 19 20:47:22 2020 +0300
Add qq icon to blocked services
commit f9c42551bbb442f83c6354314fc42ea174aacf4b
Author: ifurther <[email protected]>
Date: Sun Jun 7 12:19:05 2020 +0000
Add qq to blocked services | https://github.com/AdguardTeam/AdGuardHome/commit/32b24ce0930cbdb9b759f77f2c0773f3e61cb7b3 | client/src/components/ui/Icons.js |
id: 'tiktok',
name: 'TikTok',
},
];
export const SERVICES_ID_NAME_MAP = SERVICES.reduce((acc, { id, name }) => {
acc[id] = name;
return acc;
}, {});
| </s> | {
id: 'qq',
name: 'QQ',
}, | id: 'tiktok',
name: 'TikTok',
},
{
id: 'qq',
name: 'QQ',
},
];
export const SERVICES_ID_NAME_MAP = SERVICES.reduce((acc, { id, name }) => {
acc[id] = name;
return acc;
}, {}); | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + dnsfilter, client: Add qq to blocked services
Squashed commit of the following:
commit ffb2a1065fc9edd2b840cccbb96a0a2c1334bf00
Merge: 0f966d5b 3acfaa16
Author: ArtemBaskal <[email protected]>
Date: Tue Oct 20 11:19:39 2020 +0300
Merge branch 'master' into dnsfilter/update_blocked_services
commit 0f966d5b00f96c93bf778e944d68f62ebcdeaa50
Author: ArtemBaskal <[email protected]>
Date: Mon Oct 19 20:47:22 2020 +0300
Add qq icon to blocked services
commit f9c42551bbb442f83c6354314fc42ea174aacf4b
Author: ifurther <[email protected]>
Date: Sun Jun 7 12:19:05 2020 +0000
Add qq to blocked services | https://github.com/AdguardTeam/AdGuardHome/commit/32b24ce0930cbdb9b759f77f2c0773f3e61cb7b3 | client/src/helpers/constants.js |
"||tiktokv.com^",
}},
}
// convert array to map
func initBlockedServices() {
| </s> | {"qq", []string{"||qq.com^", "||qqzaixian.com^"}}, | "||tiktokv.com^",
}},
{"qq", []string{"||qq.com^", "||qqzaixian.com^"}},
}
// convert array to map
func initBlockedServices() { | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | + dnsfilter, client: Add qq to blocked services
Squashed commit of the following:
commit ffb2a1065fc9edd2b840cccbb96a0a2c1334bf00
Merge: 0f966d5b 3acfaa16
Author: ArtemBaskal <[email protected]>
Date: Tue Oct 20 11:19:39 2020 +0300
Merge branch 'master' into dnsfilter/update_blocked_services
commit 0f966d5b00f96c93bf778e944d68f62ebcdeaa50
Author: ArtemBaskal <[email protected]>
Date: Mon Oct 19 20:47:22 2020 +0300
Add qq icon to blocked services
commit f9c42551bbb442f83c6354314fc42ea174aacf4b
Author: ifurther <[email protected]>
Date: Sun Jun 7 12:19:05 2020 +0000
Add qq to blocked services | https://github.com/AdguardTeam/AdGuardHome/commit/32b24ce0930cbdb9b759f77f2c0773f3e61cb7b3 | dnsfilter/blocked_services.go |
// time interval for statistics (in days)
StatsInterval uint32 `yaml:"statistics_interval"`
QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
dnsforward.FilteringConfig `yaml:",inline"`
FilteringEnabled bool `yaml:"filtering_enabled"` // whether or not use filter lists
FiltersUpdateIntervalHours uint32 `yaml:"filters_update_interval"` // time period to update filters (in hours)
| </s> remove Enabled bool
</s> add Enabled bool // enable the module
FileEnabled bool // write logs to file </s> remove // DiskConfig - configuration settings that are stored on disk
type DiskConfig struct {
Enabled bool
Interval uint32
MemSize uint32
AnonymizeClientIP bool
}
</s> add </s> remove // write to file
// do it in separate goroutine -- we are stalling DNS response this whole time
go l.flushLogBuffer(false) // nolint
</s> add go func() {
_ = l.flushLogBuffer(false)
}() </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, </s> remove WriteDiskConfig(dc *DiskConfig)
</s> add WriteDiskConfig(c *Config) | QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats |
// time interval for statistics (in days)
StatsInterval uint32 `yaml:"statistics_interval"`
QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
dnsforward.FilteringConfig `yaml:",inline"`
FilteringEnabled bool `yaml:"filtering_enabled"` // whether or not use filter lists
FiltersUpdateIntervalHours uint32 `yaml:"filters_update_interval"` // time period to update filters (in hours) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | home/config.go |
func initConfig() {
config.WebSessionTTLHours = 30 * 24
config.DNS.QueryLogEnabled = true
config.DNS.QueryLogInterval = 90
config.DNS.QueryLogMemSize = 1000
config.DNS.CacheSize = 4 * 1024 * 1024
config.DNS.DnsfilterConf.SafeBrowsingCacheSize = 1 * 1024 * 1024
| </s> remove func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval
dc.MemSize = l.conf.MemSize
dc.AnonymizeClientIP = l.conf.AnonymizeClientIP
</s> add func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf </s> remove dc := querylog.DiskConfig{}
</s> add dc := querylog.Config{} </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, | config.DNS.QueryLogFileEnabled = true | func initConfig() {
config.WebSessionTTLHours = 30 * 24
config.DNS.QueryLogEnabled = true
config.DNS.QueryLogFileEnabled = true
config.DNS.QueryLogInterval = 90
config.DNS.QueryLogMemSize = 1000
config.DNS.CacheSize = 4 * 1024 * 1024
config.DNS.DnsfilterConf.SafeBrowsingCacheSize = 1 * 1024 * 1024 | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | home/config.go |
config.DNS.StatsInterval = sdc.Interval
}
if Context.queryLog != nil {
dc := querylog.DiskConfig{}
Context.queryLog.WriteDiskConfig(&dc)
config.DNS.QueryLogEnabled = dc.Enabled
config.DNS.QueryLogInterval = dc.Interval
config.DNS.QueryLogMemSize = dc.MemSize
config.DNS.AnonymizeClientIP = dc.AnonymizeClientIP
| </s> remove func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval
dc.MemSize = l.conf.MemSize
dc.AnonymizeClientIP = l.conf.AnonymizeClientIP
</s> add func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, | dc := querylog.Config{} | config.DNS.StatsInterval = sdc.Interval
}
if Context.queryLog != nil {
dc := querylog.Config{}
Context.queryLog.WriteDiskConfig(&dc)
config.DNS.QueryLogEnabled = dc.Enabled
config.DNS.QueryLogInterval = dc.Interval
config.DNS.QueryLogMemSize = dc.MemSize
config.DNS.AnonymizeClientIP = dc.AnonymizeClientIP | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | home/config.go |
dc := querylog.Config{}
Context.queryLog.WriteDiskConfig(&dc)
config.DNS.QueryLogEnabled = dc.Enabled
config.DNS.QueryLogInterval = dc.Interval
config.DNS.QueryLogMemSize = dc.MemSize
config.DNS.AnonymizeClientIP = dc.AnonymizeClientIP
}
| </s> remove dc := querylog.DiskConfig{}
</s> add dc := querylog.Config{} </s> remove func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval
dc.MemSize = l.conf.MemSize
dc.AnonymizeClientIP = l.conf.AnonymizeClientIP
</s> add func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, | config.DNS.QueryLogFileEnabled = dc.FileEnabled | dc := querylog.Config{}
Context.queryLog.WriteDiskConfig(&dc)
config.DNS.QueryLogEnabled = dc.Enabled
config.DNS.QueryLogFileEnabled = dc.FileEnabled
config.DNS.QueryLogInterval = dc.Interval
config.DNS.QueryLogMemSize = dc.MemSize
config.DNS.AnonymizeClientIP = dc.AnonymizeClientIP
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | home/config.go |
}
conf := querylog.Config{
Enabled: config.DNS.QueryLogEnabled,
BaseDir: baseDir,
Interval: config.DNS.QueryLogInterval,
MemSize: config.DNS.QueryLogMemSize,
AnonymizeClientIP: config.DNS.AnonymizeClientIP,
ConfigModified: onConfigModified,
| </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { </s> remove dc := querylog.DiskConfig{}
</s> add dc := querylog.Config{} | FileEnabled: config.DNS.QueryLogFileEnabled, | }
conf := querylog.Config{
Enabled: config.DNS.QueryLogEnabled,
FileEnabled: config.DNS.QueryLogFileEnabled,
BaseDir: baseDir,
Interval: config.DNS.QueryLogInterval,
MemSize: config.DNS.QueryLogMemSize,
AnonymizeClientIP: config.DNS.AnonymizeClientIP,
ConfigModified: onConfigModified, | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | home/dns.go |
func checkInterval(days uint32) bool {
return days == 1 || days == 7 || days == 30 || days == 90
}
func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval
dc.MemSize = l.conf.MemSize
dc.AnonymizeClientIP = l.conf.AnonymizeClientIP
}
// Clear memory buffer and remove log files
func (l *queryLog) clear() {
l.fileFlushLock.Lock()
| </s> remove dc := querylog.DiskConfig{}
</s> add dc := querylog.Config{} </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, | func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf | func checkInterval(days uint32) bool {
return days == 1 || days == 7 || days == 30 || days == 90
}
func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf
func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf
func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf
func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf
func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf
}
// Clear memory buffer and remove log files
func (l *queryLog) clear() {
l.fileFlushLock.Lock() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | querylog/qlog.go |
l.bufferLock.Lock()
l.buffer = append(l.buffer, &entry)
needFlush := false
if !l.flushPending {
needFlush = len(l.buffer) >= int(l.conf.MemSize)
if needFlush {
l.flushPending = true
}
}
| </s> remove // write to file
// do it in separate goroutine -- we are stalling DNS response this whole time
go l.flushLogBuffer(false) // nolint
</s> add go func() {
_ = l.flushLogBuffer(false)
}() </s> remove dc := querylog.DiskConfig{}
</s> add dc := querylog.Config{} </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, </s> remove func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval
dc.MemSize = l.conf.MemSize
dc.AnonymizeClientIP = l.conf.AnonymizeClientIP
</s> add func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf | if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { |
l.bufferLock.Lock()
l.buffer = append(l.buffer, &entry)
needFlush := false
if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending {
needFlush = len(l.buffer) >= int(l.conf.MemSize)
if needFlush {
l.flushPending = true
}
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | querylog/qlog.go |
l.bufferLock.Unlock()
// if buffer needs to be flushed to disk, do it now
if needFlush {
// write to file
// do it in separate goroutine -- we are stalling DNS response this whole time
go l.flushLogBuffer(false) // nolint
}
}
| </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
</s> add QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> remove Enabled bool
</s> add Enabled bool // enable the module
FileEnabled bool // write logs to file </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { </s> remove WriteDiskConfig(dc *DiskConfig)
</s> add WriteDiskConfig(c *Config) | go func() {
_ = l.flushLogBuffer(false)
}() | l.bufferLock.Unlock()
// if buffer needs to be flushed to disk, do it now
if needFlush {
go func() {
_ = l.flushLogBuffer(false)
}()
go func() {
_ = l.flushLogBuffer(false)
}()
go func() {
_ = l.flushLogBuffer(false)
}()
}
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | querylog/qlog.go |
// Check adding and loading (with filtering) entries from disk and memory
func TestQueryLog(t *testing.T) {
conf := Config{
Enabled: true,
Interval: 1,
MemSize: 100,
}
conf.BaseDir = prepareTestDir()
defer func() { _ = os.RemoveAll(conf.BaseDir) }()
l := newQueryLog(conf)
| </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, </s> remove func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval
dc.MemSize = l.conf.MemSize
dc.AnonymizeClientIP = l.conf.AnonymizeClientIP
</s> add func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf </s> remove // write to file
// do it in separate goroutine -- we are stalling DNS response this whole time
go l.flushLogBuffer(false) // nolint
</s> add go func() {
_ = l.flushLogBuffer(false)
}() </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { | Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, |
// Check adding and loading (with filtering) entries from disk and memory
func TestQueryLog(t *testing.T) {
conf := Config{
Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100,
Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100,
Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100,
}
conf.BaseDir = prepareTestDir()
defer func() { _ = os.RemoveAll(conf.BaseDir) }()
l := newQueryLog(conf)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | querylog/qlog_test.go |
}
func TestQueryLogMaxFileScanEntries(t *testing.T) {
conf := Config{
Enabled: true,
Interval: 1,
MemSize: 100,
}
conf.BaseDir = prepareTestDir()
defer func() { _ = os.RemoveAll(conf.BaseDir) }()
l := newQueryLog(conf)
| </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, </s> remove // write to file
// do it in separate goroutine -- we are stalling DNS response this whole time
go l.flushLogBuffer(false) // nolint
</s> add go func() {
_ = l.flushLogBuffer(false)
}() </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { </s> remove func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval
dc.MemSize = l.conf.MemSize
dc.AnonymizeClientIP = l.conf.AnonymizeClientIP
</s> add func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf | Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, | }
func TestQueryLogMaxFileScanEntries(t *testing.T) {
conf := Config{
Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100,
Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100,
Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100,
}
conf.BaseDir = prepareTestDir()
defer func() { _ = os.RemoveAll(conf.BaseDir) }()
l := newQueryLog(conf)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | querylog/qlog_test.go |
"github.com/AdguardTeam/AdGuardHome/dnsfilter"
"github.com/miekg/dns"
)
// DiskConfig - configuration settings that are stored on disk
type DiskConfig struct {
Enabled bool
Interval uint32
MemSize uint32
AnonymizeClientIP bool
}
// QueryLog - main interface
type QueryLog interface {
Start()
// Close query log object
| </s> remove Enabled bool
</s> add Enabled bool // enable the module
FileEnabled bool // write logs to file </s> remove WriteDiskConfig(dc *DiskConfig)
</s> add WriteDiskConfig(c *Config) </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
</s> add QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { | "github.com/AdguardTeam/AdGuardHome/dnsfilter"
"github.com/miekg/dns"
)
// QueryLog - main interface
type QueryLog interface {
Start()
// Close query log object | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | querylog/querylog.go |
|
// Add a log entry
Add(params AddParams)
// WriteDiskConfig - write configuration
WriteDiskConfig(dc *DiskConfig)
}
// Config - configuration object
type Config struct {
Enabled bool
| </s> remove Enabled bool
</s> add Enabled bool // enable the module
FileEnabled bool // write logs to file </s> remove // DiskConfig - configuration settings that are stored on disk
type DiskConfig struct {
Enabled bool
Interval uint32
MemSize uint32
AnonymizeClientIP bool
}
</s> add </s> remove func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval
dc.MemSize = l.conf.MemSize
dc.AnonymizeClientIP = l.conf.AnonymizeClientIP
</s> add func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
</s> add QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats | WriteDiskConfig(c *Config) | // Add a log entry
Add(params AddParams)
// WriteDiskConfig - write configuration
WriteDiskConfig(c *Config)
}
// Config - configuration object
type Config struct {
Enabled bool | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | querylog/querylog.go |
}
// Config - configuration object
type Config struct {
Enabled bool
BaseDir string // directory where log file is stored
Interval uint32 // interval to rotate logs (in days)
MemSize uint32 // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool // anonymize clients' IP addresses
| </s> remove QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats
</s> add QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
QueryLogInterval uint32 `yaml:"querylog_interval"` // time interval for query log (in days)
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats </s> remove // DiskConfig - configuration settings that are stored on disk
type DiskConfig struct {
Enabled bool
Interval uint32
MemSize uint32
AnonymizeClientIP bool
}
</s> add </s> remove WriteDiskConfig(dc *DiskConfig)
</s> add WriteDiskConfig(c *Config) </s> remove // write to file
// do it in separate goroutine -- we are stalling DNS response this whole time
go l.flushLogBuffer(false) // nolint
</s> add go func() {
_ = l.flushLogBuffer(false)
}() | Enabled bool // enable the module
FileEnabled bool // write logs to file | }
// Config - configuration object
type Config struct {
Enabled bool // enable the module
FileEnabled bool // write logs to file
BaseDir string // directory where log file is stored
Interval uint32 // interval to rotate logs (in days)
MemSize uint32 // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool // anonymize clients' IP addresses
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | querylog/querylog.go |
)
// flushLogBuffer flushes the current buffer to file and resets the current buffer
func (l *queryLog) flushLogBuffer(fullFlush bool) error {
l.fileFlushLock.Lock()
defer l.fileFlushLock.Unlock()
// flush remainder to file
| </s> remove func (l *queryLog) WriteDiskConfig(dc *DiskConfig) {
dc.Enabled = l.conf.Enabled
dc.Interval = l.conf.Interval
dc.MemSize = l.conf.MemSize
dc.AnonymizeClientIP = l.conf.AnonymizeClientIP
</s> add func (l *queryLog) WriteDiskConfig(c *Config) {
*c = *l.conf </s> remove // write to file
// do it in separate goroutine -- we are stalling DNS response this whole time
go l.flushLogBuffer(false) // nolint
</s> add go func() {
_ = l.flushLogBuffer(false)
}() </s> remove Enabled bool
</s> add Enabled bool // enable the module
FileEnabled bool // write logs to file </s> remove if !l.flushPending {
</s> add if !l.conf.FileEnabled {
if len(l.buffer) > int(l.conf.MemSize) {
// writing to file is disabled - just remove the oldest entry from array
l.buffer = l.buffer[1:]
}
} else if !l.flushPending { </s> remove Enabled: true,
Interval: 1,
MemSize: 100,
</s> add Enabled: true,
FileEnabled: true,
Interval: 1,
MemSize: 100, | if !l.conf.FileEnabled {
return nil
}
| )
// flushLogBuffer flushes the current buffer to file and resets the current buffer
func (l *queryLog) flushLogBuffer(fullFlush bool) error {
if !l.conf.FileEnabled {
return nil
}
l.fileFlushLock.Lock()
defer l.fileFlushLock.Unlock()
// flush remainder to file | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | + config: new setting "querylog_file_enabled"
Close #876
Squashed commit of the following:
commit f83f60a7340d8a3f6de7ecfebb426e47d19e83d8
Merge: cfb72869 391e6199
Author: Simon Zolin <[email protected]>
Date: Thu May 28 15:17:21 2020 +0300
Merge remote-tracking branch 'origin/master' into 876-logs
commit cfb72869f7cf0bf59a478ab8c7920c273e2fa5f9
Author: Simon Zolin <[email protected]>
Date: Thu May 28 12:50:02 2020 +0300
tests
commit 35376e4f450cf66507d733c931b7ed27eff1f36c
Author: Simon Zolin <[email protected]>
Date: Wed May 27 18:15:12 2020 +0300
fix
commit 0cfb802d73db52a4b09c459a68a8a18918447b76
Author: Simon Zolin <[email protected]>
Date: Wed May 27 16:49:52 2020 +0300
tests
commit 03ca280b6aed3a4880a9d4f4cd18bf47b1c742f6
Author: Simon Zolin <[email protected]>
Date: Wed May 27 15:32:27 2020 +0300
+ config: new setting "querylog_file_enabled" - query log will be written to a file | https://github.com/AdguardTeam/AdGuardHome/commit/32d1f385ff4252fdda5d81928caaa09052b62451 | querylog/querylog_file.go |
/AdGuardHome
/AdGuardHome.yaml
/build/
/client/node_modules/
/coredns
/Corefile
/dnsfilter.txt
/querylog.json
| </s> remove temporaryConfig.FilterFile = filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
</s> add // fill the list of filters
filters := make([]coreDnsFilter, 0)
// first of all, append the user filter
userFilter := getUserFilter()
// TODO: Don't add if empty
//if len(userFilter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: userFilter.ID, Path: userFilter.getFilterFilePath()})
//}
// then go through other filters
for i := range config.Filters {
filter := &config.Filters[i]
if filter.Enabled && len(filter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: filter.ID, Path: filter.getFilterFilePath()})
}
}
temporaryConfig.Filters = filters
</s> remove log.Printf("Couldn't write YAML config: %s", err)
</s> add log.Printf("Couldn't save YAML config: %s", err) </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove log.Printf("Couldn't rename YAML config: %s", err)
</s> add log.Printf("Couldn't save the user filter: %s", err) </s> remove err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
</s> add err = writeFileSafe(corefile, []byte(configtext)) | /data/ | /AdGuardHome
/AdGuardHome.yaml
/data/
/build/
/client/node_modules/
/coredns
/Corefile
/dnsfilter.txt
/querylog.json | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | .gitignore |
executable, err := os.Executable()
if err != nil {
panic(err)
}
config.ourBinaryDir = filepath.Dir(executable)
}
doConfigRename := true
// config can be specified, which reads options from there, but other command line flags have to override config values
// therefore, we must do it manually instead of using a lib
| </s> remove doConfigRename := true
</s> add executableName := filepath.Base(executable)
if executableName == "AdGuardHome" {
// Binary build
config.ourBinaryDir = filepath.Dir(executable)
} else {
// Most likely we're debugging -- using current working directory in this case
workDir, _ := os.Getwd()
config.ourBinaryDir = workDir
}
log.Printf("Current working directory is %s", config.ourBinaryDir)
} </s> remove // config was manually specified, don't do anything
doConfigRename = false
</s> add </s> remove if doConfigRename {
err := renameOldConfigIfNeccessary()
if err != nil {
panic(err)
}
}
</s> add </s> remove newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
_, err = os.Stat(newConfigFile)
if !os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s already exists, will not overwrite", newConfigFile)
return nil
</s> add if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion) </s> remove err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
</s> add // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} | executable, err := os.Executable()
if err != nil {
panic(err)
}
doConfigRename := true
// config can be specified, which reads options from there, but other command line flags have to override config values
// therefore, we must do it manually instead of using a lib | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
|
}
config.ourBinaryDir = filepath.Dir(executable)
}
doConfigRename := true
// config can be specified, which reads options from there, but other command line flags have to override config values
// therefore, we must do it manually instead of using a lib
{
var configFilename *string
| </s> remove config.ourBinaryDir = filepath.Dir(executable)
}
</s> add </s> remove // config was manually specified, don't do anything
doConfigRename = false
</s> add </s> remove newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
_, err = os.Stat(newConfigFile)
if !os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s already exists, will not overwrite", newConfigFile)
return nil
</s> add if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion) </s> remove err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
</s> add // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} | executableName := filepath.Base(executable)
if executableName == "AdGuardHome" {
// Binary build
config.ourBinaryDir = filepath.Dir(executable)
} else {
// Most likely we're debugging -- using current working directory in this case
workDir, _ := os.Getwd()
config.ourBinaryDir = workDir
}
log.Printf("Current working directory is %s", config.ourBinaryDir)
} | }
config.ourBinaryDir = filepath.Dir(executable)
}
executableName := filepath.Base(executable)
if executableName == "AdGuardHome" {
// Binary build
config.ourBinaryDir = filepath.Dir(executable)
} else {
// Most likely we're debugging -- using current working directory in this case
workDir, _ := os.Getwd()
config.ourBinaryDir = workDir
}
log.Printf("Current working directory is %s", config.ourBinaryDir)
}
// config can be specified, which reads options from there, but other command line flags have to override config values
// therefore, we must do it manually instead of using a lib
{
var configFilename *string | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
os.Exit(64)
}
}
if configFilename != nil {
// config was manually specified, don't do anything
doConfigRename = false
config.ourConfigFilename = *configFilename
}
if doConfigRename {
err := renameOldConfigIfNeccessary()
| </s> remove if doConfigRename {
err := renameOldConfigIfNeccessary()
if err != nil {
panic(err)
}
}
</s> add </s> remove config.ourBinaryDir = filepath.Dir(executable)
}
</s> add </s> remove doConfigRename := true
</s> add executableName := filepath.Base(executable)
if executableName == "AdGuardHome" {
// Binary build
config.ourBinaryDir = filepath.Dir(executable)
} else {
// Most likely we're debugging -- using current working directory in this case
workDir, _ := os.Getwd()
config.ourBinaryDir = workDir
}
log.Printf("Current working directory is %s", config.ourBinaryDir)
} </s> remove err := writeConfig()
</s> add // Do the upgrade if necessary
err := upgradeConfig()
if err != nil {
log.Fatal(err)
}
// Save the updated config
err = writeConfig() </s> remove func renameOldConfigIfNeccessary() error {
oldConfigFile := filepath.Join(config.ourBinaryDir, "AdguardDNS.yaml")
_, err := os.Stat(oldConfigFile)
if os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s doesn't exist, nothing to do", oldConfigFile)
</s> add // Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing | os.Exit(64)
}
}
if configFilename != nil {
config.ourConfigFilename = *configFilename
}
if doConfigRename {
err := renameOldConfigIfNeccessary() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
|
doConfigRename = false
config.ourConfigFilename = *configFilename
}
if doConfigRename {
err := renameOldConfigIfNeccessary()
if err != nil {
panic(err)
}
}
err := askUsernamePasswordIfPossible()
if err != nil {
log.Fatal(err)
}
| </s> remove // config was manually specified, don't do anything
doConfigRename = false
</s> add </s> remove err := writeConfig()
</s> add // Do the upgrade if necessary
err := upgradeConfig()
if err != nil {
log.Fatal(err)
}
// Save the updated config
err = writeConfig() </s> remove return err
</s> add return nil </s> remove config.ourBinaryDir = filepath.Dir(executable)
}
</s> add </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() | doConfigRename = false
config.ourConfigFilename = *configFilename
}
err := askUsernamePasswordIfPossible()
if err != nil {
log.Fatal(err)
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
|
config.BindPort = *bindPort
}
}
// eat all args so that coredns can start happily
if len(os.Args) > 1 {
os.Args = os.Args[:1]
}
err := writeConfig()
| </s> remove err := writeConfig()
</s> add // Do the upgrade if necessary
err := upgradeConfig()
if err != nil {
log.Fatal(err)
}
// Save the updated config
err = writeConfig() </s> remove args := c.RemainingArgs()
if len(args) > 0 {
filterFileNames = append(filterFileNames, args...)
}
</s> add </s> remove filterFileNames := []string{}
</s> add log.Println("Initializing the CoreDNS plugin")
</s> remove return err
</s> add return nil </s> remove for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
</s> add return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil | // Eat all args so that coredns can start happily | config.BindPort = *bindPort
}
}
// Eat all args so that coredns can start happily
if len(os.Args) > 1 {
os.Args = os.Args[:1]
}
err := writeConfig() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
if len(os.Args) > 1 {
os.Args = os.Args[:1]
}
err := writeConfig()
if err != nil {
log.Fatal(err)
}
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort))
| </s> remove // eat all args so that coredns can start happily
</s> add // Eat all args so that coredns can start happily </s> remove if doConfigRename {
err := renameOldConfigIfNeccessary()
if err != nil {
panic(err)
}
}
</s> add </s> remove return err
</s> add return nil </s> remove err := writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
}
</s> add | // Do the upgrade if necessary
err := upgradeConfig()
if err != nil {
log.Fatal(err)
}
// Save the updated config
err = writeConfig() | if len(os.Args) > 1 {
os.Args = os.Args[:1]
}
// Do the upgrade if necessary
err := upgradeConfig()
if err != nil {
log.Fatal(err)
}
// Save the updated config
err = writeConfig()
if err != nil {
log.Fatal(err)
}
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort)) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
log.Fatal(err)
}
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort))
runFilterRefreshers()
http.Handle("/", optionalAuthHandler(http.FileServer(box)))
| </s> remove err := writeConfig()
</s> add // Do the upgrade if necessary
err := upgradeConfig()
if err != nil {
log.Fatal(err)
}
// Save the updated config
err = writeConfig() </s> remove if doConfigRename {
err := renameOldConfigIfNeccessary()
if err != nil {
panic(err)
}
}
</s> add </s> remove err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
</s> add // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} </s> remove err := writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
}
</s> add </s> remove log.Printf("filterFileNames = %+v", filterFileNames)
</s> add for _, filter := range p.settings.Filters {
log.Printf("Loading rules from %s", filter.Path) | // Load filters from the disk
for i := range config.Filters {
filter := &config.Filters[i]
err = filter.load()
if err != nil {
log.Printf("Couldn't load filter %d contents due to %s", filter.ID, err)
}
}
| log.Fatal(err)
}
// Load filters from the disk
for i := range config.Filters {
filter := &config.Filters[i]
err = filter.load()
if err != nil {
log.Printf("Couldn't load filter %d contents due to %s", filter.ID, err)
}
}
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort))
runFilterRefreshers()
http.Handle("/", optionalAuthHandler(http.FileServer(box))) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
config.AuthPass = password
return nil
}
func renameOldConfigIfNeccessary() error {
oldConfigFile := filepath.Join(config.ourBinaryDir, "AdguardDNS.yaml")
_, err := os.Stat(oldConfigFile)
if os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s doesn't exist, nothing to do", oldConfigFile)
return nil
}
newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
_, err = os.Stat(newConfigFile)
| </s> remove newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
_, err = os.Stat(newConfigFile)
if !os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s already exists, will not overwrite", newConfigFile)
return nil
</s> add if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion) </s> remove config.RUnlock()
err := ioutil.WriteFile(filterpath+".tmp", data, 0644)
if err != nil {
log.Printf("Couldn't write filter file: %s", err)
</s> add filterFilePath := filter.getFilterFilePath()
log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath)
if _, err := os.Stat(filterFilePath); os.IsNotExist(err) {
// do nothing, file doesn't exist </s> remove // write filter file
func writeFilterFile() error {
filterpath := filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
log.Printf("Writing filter file: %s", filterpath)
// TODO: check if file contents have modified
data := []byte{}
config.RLock()
filters := config.Filters
for _, filter := range filters {
if !filter.Enabled {
continue
}
data = append(data, filter.contents...)
data = append(data, '\n')
</s> add // saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err </s> remove err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
</s> add // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} </s> remove for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
</s> add return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil | // Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing | config.AuthPass = password
return nil
}
// Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing
// Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing
// Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing
// Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing
// Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing
// Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing
return nil
}
newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
_, err = os.Stat(newConfigFile) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
trace("File %s doesn't exist, nothing to do", oldConfigFile)
return nil
}
newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
_, err = os.Stat(newConfigFile)
if !os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s already exists, will not overwrite", newConfigFile)
return nil
}
err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
| </s> remove func renameOldConfigIfNeccessary() error {
oldConfigFile := filepath.Join(config.ourBinaryDir, "AdguardDNS.yaml")
_, err := os.Stat(oldConfigFile)
if os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s doesn't exist, nothing to do", oldConfigFile)
</s> add // Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing </s> remove err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
</s> add // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} </s> remove config.RUnlock()
err := ioutil.WriteFile(filterpath+".tmp", data, 0644)
if err != nil {
log.Printf("Couldn't write filter file: %s", err)
</s> add filterFilePath := filter.getFilterFilePath()
log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath)
if _, err := os.Stat(filterFilePath); os.IsNotExist(err) {
// do nothing, file doesn't exist </s> remove err = d.AddRule(line, 0)
if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax {
continue
}
if err != nil {
log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err)
// Just ignore invalid rules
continue
}
</s> add | if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion) | trace("File %s doesn't exist, nothing to do", oldConfigFile)
return nil
}
if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion)
if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion)
if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion)
if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion)
if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion)
if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion)
}
err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
trace("File %s already exists, will not overwrite", newConfigFile)
return nil
}
err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
}
return nil
}
| </s> remove newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
_, err = os.Stat(newConfigFile)
if !os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s already exists, will not overwrite", newConfigFile)
return nil
</s> add if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion) </s> remove err = d.AddRule(line, 0)
if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax {
continue
}
if err != nil {
log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err)
// Just ignore invalid rules
continue
}
</s> add </s> remove log.Printf("Couldn't rename filter file: %s", err)
</s> add </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove return err
</s> add return nil | // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} | trace("File %s already exists, will not overwrite", newConfigFile)
return nil
}
// Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
}
// Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
}
// Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
}
// Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
}
}
return nil
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | app.go |
import (
"bytes"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
| </s> remove
"gopkg.in/yaml.v2"
</s> add </s> remove func _Func() string {
pc := make([]uintptr, 10) // at least 1 entry needed
runtime.Callers(2, pc)
f := runtime.FuncForPC(pc[0])
return path.Base(f.Name())
}
</s> add | "gopkg.in/yaml.v2" |
import (
"bytes"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
"regexp"
"sync"
"text/template"
"time"
"gopkg.in/yaml.v2"
)
// configuration is loaded from YAML
type configuration struct {
ourConfigFilename string
| </s> remove BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
</s> add // Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"` | "regexp"
"sync"
"text/template"
"time"
)
// configuration is loaded from YAML
type configuration struct {
ourConfigFilename string | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
|
"text/template"
"time"
)
// configuration is loaded from YAML
type configuration struct {
ourConfigFilename string
ourBinaryDir string
// Directory to store data (i.e. filters contents)
| </s> remove
"gopkg.in/yaml.v2"
</s> add </s> remove BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
</s> add // Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"` | // Current schema version. We compare it with the value from
// the configuration file and perform necessary upgrade operations if needed
const SchemaVersion = 1
// Directory where we'll store all downloaded filters contents
const FiltersDir = "filters"
| "text/template"
"time"
)
// Current schema version. We compare it with the value from
// the configuration file and perform necessary upgrade operations if needed
const SchemaVersion = 1
// Directory where we'll store all downloaded filters contents
const FiltersDir = "filters"
// configuration is loaded from YAML
type configuration struct {
ourConfigFilename string
ourBinaryDir string
// Directory to store data (i.e. filters contents) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
// configuration is loaded from YAML
type configuration struct {
ourConfigFilename string
ourBinaryDir string
// Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
| </s> remove BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
</s> add // Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"` </s> remove
"gopkg.in/yaml.v2"
</s> add | // Directory to store data (i.e. filters contents)
ourDataDir string | // configuration is loaded from YAML
type configuration struct {
ourConfigFilename string
ourBinaryDir string
// Directory to store data (i.e. filters contents)
ourDataDir string
// Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"` | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
type configuration struct {
ourConfigFilename string
ourBinaryDir string
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
sync.RWMutex `yaml:"-"`
}
type coreDNSConfig struct {
| </s> remove FilterFile string `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
</s> add Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"` </s> remove
"gopkg.in/yaml.v2"
</s> add | // Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"` | type configuration struct {
ourConfigFilename string
ourBinaryDir string
// Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
// Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
// Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
// Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
// Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
// Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
// Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
sync.RWMutex `yaml:"-"`
}
type coreDNSConfig struct { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
sync.RWMutex `yaml:"-"`
}
type coreDNSConfig struct {
binaryFile string
coreFile string
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
| </s> remove FilterFile string `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
</s> add Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"` </s> remove BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
</s> add // Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"` | type coreDnsFilter struct {
ID int `yaml:"-"`
Path string `yaml:"-"`
}
|
sync.RWMutex `yaml:"-"`
}
type coreDnsFilter struct {
ID int `yaml:"-"`
Path string `yaml:"-"`
}
type coreDNSConfig struct {
binaryFile string
coreFile string
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"` | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
type coreDNSConfig struct {
binaryFile string
coreFile string
FilterFile string `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
}
type filter struct {
URL string `json:"url"`
Name string `json:"name" yaml:"name"`
| </s> remove BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
</s> add // Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"` | Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"` |
type coreDNSConfig struct {
binaryFile string
coreFile string
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
}
type filter struct {
URL string `json:"url"`
Name string `json:"name" yaml:"name"` | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
UpstreamDNS []string `yaml:"upstream_dns"`
}
type filter struct {
URL string `json:"url"`
Name string `json:"name" yaml:"name"`
Enabled bool `json:"enabled"`
RulesCount int `json:"rules_count" yaml:"-"`
contents []byte
| </s> remove FilterFile string `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
</s> add Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"` </s> remove BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
</s> add // Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"` | ID int `json:"ID"` // auto-assigned when filter is added | UpstreamDNS []string `yaml:"upstream_dns"`
}
type filter struct {
ID int `json:"ID"` // auto-assigned when filter is added
URL string `json:"url"`
Name string `json:"name" yaml:"name"`
Enabled bool `json:"enabled"`
RulesCount int `json:"rules_count" yaml:"-"`
contents []byte | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
// initialize to default values, will be changed later when reading config or parsing command line
var config = configuration{
ourConfigFilename: "AdGuardHome.yaml",
BindPort: 3000,
BindHost: "127.0.0.1",
CoreDNS: coreDNSConfig{
Port: 53,
binaryFile: "coredns", // only filename, no path
| </s> remove binaryFile: "coredns", // only filename, no path
coreFile: "Corefile", // only filename, no path
FilterFile: "dnsfilter.txt", // only filename, no path
</s> add binaryFile: "coredns", // only filename, no path
coreFile: "Corefile", // only filename, no path </s> remove config.ourBinaryDir = filepath.Dir(executable)
}
</s> add </s> remove doConfigRename := true
</s> add executableName := filepath.Base(executable)
if executableName == "AdGuardHome" {
// Binary build
config.ourBinaryDir = filepath.Dir(executable)
} else {
// Most likely we're debugging -- using current working directory in this case
workDir, _ := os.Getwd()
config.ourBinaryDir = workDir
}
log.Printf("Current working directory is %s", config.ourBinaryDir)
} </s> remove newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
_, err = os.Stat(newConfigFile)
if !os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s already exists, will not overwrite", newConfigFile)
return nil
</s> add if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion) | ourDataDir: "data", | // initialize to default values, will be changed later when reading config or parsing command line
var config = configuration{
ourConfigFilename: "AdGuardHome.yaml",
ourDataDir: "data",
BindPort: 3000,
BindHost: "127.0.0.1",
CoreDNS: coreDNSConfig{
Port: 53,
binaryFile: "coredns", // only filename, no path | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
BindPort: 3000,
BindHost: "127.0.0.1",
CoreDNS: coreDNSConfig{
Port: 53,
binaryFile: "coredns", // only filename, no path
coreFile: "Corefile", // only filename, no path
FilterFile: "dnsfilter.txt", // only filename, no path
ProtectionEnabled: true,
FilteringEnabled: true,
SafeBrowsingEnabled: false,
BlockedResponseTTL: 10, // in seconds
QueryLogEnabled: true,
| </s> remove func clamp(value, low, high int) int {
if value < low {
return low
</s> add // ----------------------------------
// helper functions for working with files
// ----------------------------------
// Writes data first to a temporary file and then renames it to what's specified in path
func writeFileSafe(path string, data []byte) error {
dir := filepath.Dir(path)
err := os.MkdirAll(dir, 0755)
if err != nil {
return err
}
tmpPath := path + ".tmp"
err = ioutil.WriteFile(tmpPath, data, 0644)
if err != nil {
return err </s> remove {Enabled: true, URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt"},
{Enabled: false, URL: "https://adaway.org/hosts.txt", Name: "AdAway"},
{Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"},
{Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"},
</s> add {ID: 1, Enabled: true, URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", Name: "AdGuard Simplified Domain Names filter"},
{ID: 2, Enabled: false, URL: "https://adaway.org/hosts.txt", Name: "AdAway"},
{ID: 3, Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"},
{ID: 4, Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"}, | binaryFile: "coredns", // only filename, no path
coreFile: "Corefile", // only filename, no path | BindPort: 3000,
BindHost: "127.0.0.1",
CoreDNS: coreDNSConfig{
Port: 53,
binaryFile: "coredns", // only filename, no path
coreFile: "Corefile", // only filename, no path
binaryFile: "coredns", // only filename, no path
coreFile: "Corefile", // only filename, no path
binaryFile: "coredns", // only filename, no path
coreFile: "Corefile", // only filename, no path
ProtectionEnabled: true,
FilteringEnabled: true,
SafeBrowsingEnabled: false,
BlockedResponseTTL: 10, // in seconds
QueryLogEnabled: true, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
Cache: "cache",
Prometheus: "prometheus :9153",
},
Filters: []filter{
{Enabled: true, URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt"},
{Enabled: false, URL: "https://adaway.org/hosts.txt", Name: "AdAway"},
{Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"},
{Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"},
},
}
func parseConfig() error {
configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
| </s> remove func renameOldConfigIfNeccessary() error {
oldConfigFile := filepath.Join(config.ourBinaryDir, "AdguardDNS.yaml")
_, err := os.Stat(oldConfigFile)
if os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s doesn't exist, nothing to do", oldConfigFile)
</s> add // Performs necessary upgrade operations if needed
func upgradeConfig() error {
if config.SchemaVersion == SchemaVersion {
// No upgrade, do nothing </s> remove elapsed := time.Since(filter.LastUpdated)
if elapsed <= updatePeriod {
</s> add if !force && time.Since(filter.LastUpdated) <= updatePeriod { </s> remove // extract filter name and count number of rules
</s> add // Extract filter name and count number of rules </s> remove return false, fmt.Errorf("Got status code >= 400: %d", resp.StatusCode)
</s> add return false, fmt.Errorf("got status code != 200: %d", resp.StatusCode)
}
contentType := strings.ToLower(resp.Header.Get("content-type"))
if !strings.HasPrefix(contentType, "text/plain") {
log.Printf("Non-text response %s from %s, skipping", contentType, filter.URL)
return false, fmt.Errorf("non-text response %s", contentType) </s> remove if resp.StatusCode >= 400 {
</s> add if resp.StatusCode != 200 { | {ID: 1, Enabled: true, URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", Name: "AdGuard Simplified Domain Names filter"},
{ID: 2, Enabled: false, URL: "https://adaway.org/hosts.txt", Name: "AdAway"},
{ID: 3, Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"},
{ID: 4, Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"}, | Cache: "cache",
Prometheus: "prometheus :9153",
},
Filters: []filter{
{ID: 1, Enabled: true, URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", Name: "AdGuard Simplified Domain Names filter"},
{ID: 2, Enabled: false, URL: "https://adaway.org/hosts.txt", Name: "AdAway"},
{ID: 3, Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"},
{ID: 4, Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"},
{ID: 1, Enabled: true, URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", Name: "AdGuard Simplified Domain Names filter"},
{ID: 2, Enabled: false, URL: "https://adaway.org/hosts.txt", Name: "AdAway"},
{ID: 3, Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"},
{ID: 4, Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"},
{ID: 1, Enabled: true, URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", Name: "AdGuard Simplified Domain Names filter"},
{ID: 2, Enabled: false, URL: "https://adaway.org/hosts.txt", Name: "AdAway"},
{ID: 3, Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"},
{ID: 4, Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"},
{ID: 1, Enabled: true, URL: "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", Name: "AdGuard Simplified Domain Names filter"},
{ID: 2, Enabled: false, URL: "https://adaway.org/hosts.txt", Name: "AdAway"},
{ID: 3, Enabled: false, URL: "https://hosts-file.net/ad_servers.txt", Name: "hpHosts - Ad and Tracking servers only"},
{ID: 4, Enabled: false, URL: "http://www.malwaredomainlist.com/hostslist/hosts.txt", Name: "MalwareDomainList.com Hosts List"},
},
}
func parseConfig() error {
configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
if err != nil {
log.Printf("Couldn't generate YAML file: %s", err)
return err
}
err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
if err != nil {
log.Printf("Couldn't write YAML config: %s", err)
return err
}
err = os.Rename(configfile+".tmp", configfile)
| </s> remove log.Printf("Couldn't write YAML config: %s", err)
</s> add log.Printf("Couldn't save YAML config: %s", err) </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove log.Printf("Couldn't rename YAML config: %s", err)
</s> add log.Printf("Couldn't save the user filter: %s", err) </s> remove err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
</s> add err = writeFileSafe(corefile, []byte(configtext)) </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err | err = writeFileSafe(configfile, yamlText) | if err != nil {
log.Printf("Couldn't generate YAML file: %s", err)
return err
}
err = writeFileSafe(configfile, yamlText)
if err != nil {
log.Printf("Couldn't write YAML config: %s", err)
return err
}
err = os.Rename(configfile+".tmp", configfile) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
return err
}
err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
if err != nil {
log.Printf("Couldn't write YAML config: %s", err)
return err
}
err = os.Rename(configfile+".tmp", configfile)
if err != nil {
log.Printf("Couldn't rename YAML config: %s", err)
| </s> remove err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
</s> add err = writeFileSafe(configfile, yamlText) </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove log.Printf("Couldn't rename YAML config: %s", err)
</s> add log.Printf("Couldn't save the user filter: %s", err) </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err </s> remove err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
</s> add err = writeFileSafe(corefile, []byte(configtext)) | log.Printf("Couldn't save YAML config: %s", err) | return err
}
err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
if err != nil {
log.Printf("Couldn't save YAML config: %s", err)
return err
}
err = os.Rename(configfile+".tmp", configfile)
if err != nil {
log.Printf("Couldn't rename YAML config: %s", err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
if err != nil {
log.Printf("Couldn't write YAML config: %s", err)
return err
}
err = os.Rename(configfile+".tmp", configfile)
if err != nil {
log.Printf("Couldn't rename YAML config: %s", err)
return err
}
return nil
| </s> remove log.Printf("Couldn't write YAML config: %s", err)
</s> add log.Printf("Couldn't save YAML config: %s", err) </s> remove log.Printf("Couldn't rename YAML config: %s", err)
</s> add log.Printf("Couldn't save the user filter: %s", err) </s> remove err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
</s> add err = writeFileSafe(configfile, yamlText) </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err </s> remove err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
</s> add err = writeFileSafe(corefile, []byte(configtext)) | userFilter := getUserFilter()
err = userFilter.save() | if err != nil {
log.Printf("Couldn't write YAML config: %s", err)
return err
}
userFilter := getUserFilter()
err = userFilter.save()
if err != nil {
log.Printf("Couldn't rename YAML config: %s", err)
return err
}
return nil | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
return err
}
err = os.Rename(configfile+".tmp", configfile)
if err != nil {
log.Printf("Couldn't rename YAML config: %s", err)
return err
}
return nil
}
| </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove log.Printf("Couldn't write YAML config: %s", err)
</s> add log.Printf("Couldn't save YAML config: %s", err) </s> remove err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
</s> add err = writeFileSafe(configfile, yamlText) </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err </s> remove return err
</s> add return nil | log.Printf("Couldn't save the user filter: %s", err) | return err
}
err = os.Rename(configfile+".tmp", configfile)
if err != nil {
log.Printf("Couldn't save the user filter: %s", err)
return err
}
return nil
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
if err != nil {
log.Printf("Couldn't generate DNS config: %s", err)
return err
}
err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
if err != nil {
log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
| </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err </s> remove return err
</s> add return nil </s> remove err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
</s> add err = writeFileSafe(configfile, yamlText) </s> remove log.Printf("Couldn't write YAML config: %s", err)
</s> add log.Printf("Couldn't save YAML config: %s", err) </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() | err = writeFileSafe(corefile, []byte(configtext)) | if err != nil {
log.Printf("Couldn't generate DNS config: %s", err)
return err
}
err = writeFileSafe(corefile, []byte(configtext))
if err != nil {
log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
return err
}
err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
if err != nil {
log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
}
return err
}
func writeAllConfigs() error {
| </s> remove err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
</s> add err = writeFileSafe(corefile, []byte(configtext)) </s> remove return err
</s> add return nil </s> remove log.Printf("Couldn't write YAML config: %s", err)
</s> add log.Printf("Couldn't save YAML config: %s", err) </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
</s> add err = writeFileSafe(configfile, yamlText) | log.Printf("Couldn't save DNS config: %s", err)
return err | return err
}
err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
if err != nil {
log.Printf("Couldn't save DNS config: %s", err)
return err
log.Printf("Couldn't save DNS config: %s", err)
return err
log.Printf("Couldn't save DNS config: %s", err)
return err
log.Printf("Couldn't save DNS config: %s", err)
return err
log.Printf("Couldn't save DNS config: %s", err)
return err
}
return err
}
func writeAllConfigs() error { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
}
return err
}
func writeAllConfigs() error {
err := writeConfig()
if err != nil {
| </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err </s> remove err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
</s> add err = writeFileSafe(corefile, []byte(configtext)) </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove log.Printf("Couldn't write YAML config: %s", err)
</s> add log.Printf("Couldn't save YAML config: %s", err) </s> remove log.Printf("Couldn't rename YAML config: %s", err)
</s> add log.Printf("Couldn't save the user filter: %s", err) | return nil | err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
}
return nil
}
func writeAllConfigs() error {
err := writeConfig()
if err != nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
return nil
}
const coreDNSConfigTemplate = `.:{{.Port}} {
{{if .ProtectionEnabled}}dnsfilter {{if .FilteringEnabled}}{{.FilterFile}}{{end}} {
{{if .SafeBrowsingEnabled}}safebrowsing{{end}}
{{if .ParentalEnabled}}parental {{.ParentalSensitivity}}{{end}}
{{if .SafeSearchEnabled}}safesearch{{end}}
{{if .QueryLogEnabled}}querylog{{end}}
blocked_ttl {{.BlockedResponseTTL}}
| </s> remove return err
</s> add return nil </s> remove if value > high {
return high
</s> add err = os.Rename(tmpPath, path)
if err != nil {
return err </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err | {{if .ProtectionEnabled}}dnsfilter { | return nil
}
const coreDNSConfigTemplate = `.:{{.Port}} {
{{if .ProtectionEnabled}}dnsfilter {
{{if .SafeBrowsingEnabled}}safebrowsing{{end}}
{{if .ParentalEnabled}}parental {{.ParentalSensitivity}}{{end}}
{{if .SafeSearchEnabled}}safesearch{{end}}
{{if .QueryLogEnabled}}querylog{{end}}
blocked_ttl {{.BlockedResponseTTL}} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
{{if .ParentalEnabled}}parental {{.ParentalSensitivity}}{{end}}
{{if .SafeSearchEnabled}}safesearch{{end}}
{{if .QueryLogEnabled}}querylog{{end}}
blocked_ttl {{.BlockedResponseTTL}}
}{{end}}
{{.Pprof}}
hosts {
fallthrough
}
| </s> remove {{if .ProtectionEnabled}}dnsfilter {{if .FilteringEnabled}}{{.FilterFile}}{{end}} {
</s> add {{if .ProtectionEnabled}}dnsfilter { </s> remove if doConfigRename {
err := renameOldConfigIfNeccessary()
if err != nil {
panic(err)
}
}
</s> add </s> remove args := c.RemainingArgs()
if len(args) > 0 {
filterFileNames = append(filterFileNames, args...)
}
</s> add </s> remove err = d.AddRule(line, 0)
if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax {
continue
}
if err != nil {
log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err)
// Just ignore invalid rules
continue
}
</s> add </s> remove if value > high {
return high
</s> add err = os.Rename(tmpPath, path)
if err != nil {
return err | {{if .FilteringEnabled}}
{{range .Filters}}
filter {{.ID}} "{{.Path}}"
{{end}}
{{end}} | {{if .ParentalEnabled}}parental {{.ParentalSensitivity}}{{end}}
{{if .SafeSearchEnabled}}safesearch{{end}}
{{if .QueryLogEnabled}}querylog{{end}}
blocked_ttl {{.BlockedResponseTTL}}
{{if .FilteringEnabled}}
{{range .Filters}}
filter {{.ID}} "{{.Path}}"
{{end}}
{{end}}
}{{end}}
{{.Pprof}}
hosts {
fallthrough
} | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
}
var configBytes bytes.Buffer
temporaryConfig := config.CoreDNS
temporaryConfig.FilterFile = filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
// run the template
err = t.Execute(&configBytes, &temporaryConfig)
if err != nil {
log.Printf("Couldn't generate DNS config: %s", err)
return "", err
| </s> remove err = ioutil.WriteFile(corefile+".tmp", []byte(configtext), 0644)
</s> add err = writeFileSafe(corefile, []byte(configtext)) </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err </s> remove err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
</s> add err = writeFileSafe(configfile, yamlText) </s> remove return err
</s> add return nil </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() | // fill the list of filters
filters := make([]coreDnsFilter, 0)
// first of all, append the user filter
userFilter := getUserFilter()
// TODO: Don't add if empty
//if len(userFilter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: userFilter.ID, Path: userFilter.getFilterFilePath()})
//}
// then go through other filters
for i := range config.Filters {
filter := &config.Filters[i]
if filter.Enabled && len(filter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: filter.ID, Path: filter.getFilterFilePath()})
}
}
temporaryConfig.Filters = filters
| }
var configBytes bytes.Buffer
temporaryConfig := config.CoreDNS
// fill the list of filters
filters := make([]coreDnsFilter, 0)
// first of all, append the user filter
userFilter := getUserFilter()
// TODO: Don't add if empty
//if len(userFilter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: userFilter.ID, Path: userFilter.getFilterFilePath()})
//}
// then go through other filters
for i := range config.Filters {
filter := &config.Filters[i]
if filter.Enabled && len(filter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: filter.ID, Path: filter.getFilterFilePath()})
}
}
temporaryConfig.Filters = filters
// run the template
err = t.Execute(&configBytes, &temporaryConfig)
if err != nil {
log.Printf("Couldn't generate DNS config: %s", err)
return "", err | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | config.go |
"strings"
"time"
coredns_plugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin"
"github.com/AdguardTeam/AdGuardHome/dnsfilter"
"github.com/miekg/dns"
"gopkg.in/asaskevich/govalidator.v4"
)
const updatePeriod = time.Minute * 30
| </s> remove
"gopkg.in/yaml.v2"
</s> add </s> remove elapsed := time.Since(filter.LastUpdated)
if elapsed <= updatePeriod {
</s> add if !force && time.Since(filter.LastUpdated) <= updatePeriod { </s> remove {{if .ProtectionEnabled}}dnsfilter {{if .FilteringEnabled}}{{.FilterFile}}{{end}} {
</s> add {{if .ProtectionEnabled}}dnsfilter { | "strings"
"time"
coredns_plugin "github.com/AdguardTeam/AdGuardHome/coredns_plugin"
"github.com/miekg/dns"
"gopkg.in/asaskevich/govalidator.v4"
)
const updatePeriod = time.Minute * 30 | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
return
}
}
ok, err := filter.update(time.Now())
if err != nil {
errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err)
log.Println(errortext)
http.Error(w, errortext, http.StatusBadRequest)
return
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | ok, err := filter.update(true) | return
}
}
ok, err := filter.update(true)
if err != nil {
errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err)
log.Println(errortext)
http.Error(w, errortext, http.StatusBadRequest)
return | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
tellCoreDNSToReload()
_, err = fmt.Fprintf(w, "OK %d rules\n", filter.RulesCount)
if err != nil {
errortext := fmt.Sprintf("Couldn't write body: %s", err)
log.Println(errortext)
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err := writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
}
</s> add | log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
tellCoreDNSToReload()
_, err = fmt.Fprintf(w, "OK %d rules\n", filter.RulesCount)
if err != nil {
errortext := fmt.Sprintf("Couldn't write body: %s", err)
log.Println(errortext) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
http.Error(w, errortext, http.StatusInternalServerError)
}
}
func handleFilteringRemoveURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body)
if err != nil {
errortext := fmt.Sprintf("failed to parse parameters from body: %s", err)
log.Println(errortext)
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | // TODO: Start using filter ID | http.Error(w, errortext, http.StatusInternalServerError)
}
}
// TODO: Start using filter ID
func handleFilteringRemoveURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body)
if err != nil {
errortext := fmt.Sprintf("failed to parse parameters from body: %s", err)
log.Println(errortext) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
for _, filter := range config.Filters {
if filter.URL != url {
newFilters = append(newFilters, filter)
}
}
// Update the configuration after removing filter files
config.Filters = newFilters
httpUpdateConfigReloadDNSReturnOK(w, r)
}
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove // write filter file
func writeFilterFile() error {
filterpath := filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
log.Printf("Writing filter file: %s", filterpath)
// TODO: check if file contents have modified
data := []byte{}
config.RLock()
filters := config.Filters
for _, filter := range filters {
if !filter.Enabled {
continue
}
data = append(data, filter.contents...)
data = append(data, '\n')
</s> add // saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err </s> remove log.Printf("filterFileNames = %+v", filterFileNames)
</s> add for _, filter := range p.settings.Filters {
log.Printf("Loading rules from %s", filter.Path) | } else {
// Remove the filter file
err := os.Remove(filter.getFilterFilePath())
if err != nil {
errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err)
http.Error(w, errortext, http.StatusInternalServerError)
return
} | for _, filter := range config.Filters {
if filter.URL != url {
newFilters = append(newFilters, filter)
} else {
// Remove the filter file
err := os.Remove(filter.getFilterFilePath())
if err != nil {
errortext := fmt.Sprintf("Couldn't remove the filter file: %s", err)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
}
}
// Update the configuration after removing filter files
config.Filters = newFilters
httpUpdateConfigReloadDNSReturnOK(w, r)
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
return
}
}
}
config.Filters = newFilters
httpUpdateConfigReloadDNSReturnOK(w, r)
}
// TODO: Start using filter ID
func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) {
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | // Update the configuration after removing filter files | return
}
}
}
// Update the configuration after removing filter files
config.Filters = newFilters
httpUpdateConfigReloadDNSReturnOK(w, r)
}
// TODO: Start using filter ID
func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) { | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
newFilters = append(newFilters, filter)
}
}
config.Filters = newFilters
err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body)
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | newFilters = append(newFilters, filter)
}
}
config.Filters = newFilters
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body)
if err != nil {
errortext := fmt.Sprintf("failed to parse parameters from body: %s", err)
log.Println(errortext)
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | // TODO: Start using filter ID | httpUpdateConfigReloadDNSReturnOK(w, r)
}
// TODO: Start using filter ID
func handleFilteringEnableURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body)
if err != nil {
errortext := fmt.Sprintf("failed to parse parameters from body: %s", err)
log.Println(errortext) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
}
// kick off refresh of rules from new URLs
refreshFiltersIfNeccessary()
err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringDisableURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body)
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | }
// kick off refresh of rules from new URLs
refreshFiltersIfNeccessary()
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringDisableURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringDisableURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body)
if err != nil {
errortext := fmt.Sprintf("failed to parse parameters from body: %s", err)
log.Println(errortext)
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | // TODO: Start using filter ID | httpUpdateConfigReloadDNSReturnOK(w, r)
}
// TODO: Start using filter ID
func handleFilteringDisableURL(w http.ResponseWriter, r *http.Request) {
parameters, err := parseParametersFromBody(r.Body)
if err != nil {
errortext := fmt.Sprintf("failed to parse parameters from body: %s", err)
log.Println(errortext) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
http.Error(w, "URL parameter was not previously added", http.StatusBadRequest)
return
}
err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringSetRules(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body)
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove ok, err := filter.update(time.Now())
</s> add ok, err := filter.update(true) | http.Error(w, "URL parameter was not previously added", http.StatusBadRequest)
return
}
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringSetRules(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
return
}
config.UserRules = strings.Split(string(body), "\n")
err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringRefresh(w http.ResponseWriter, r *http.Request) {
force := r.URL.Query().Get("force")
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | return
}
config.UserRules = strings.Split(string(body), "\n")
httpUpdateConfigReloadDNSReturnOK(w, r)
}
func handleFilteringRefresh(w http.ResponseWriter, r *http.Request) {
force := r.URL.Query().Get("force") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
}()
}
func refreshFiltersIfNeccessary() int {
now := time.Now()
config.Lock()
// deduplicate
// TODO: move it somewhere else
{
| </s> remove filter.LastUpdated = now
</s> add filter.LastUpdated = time.Now() </s> remove func clamp(value, low, high int) int {
if value < low {
return low
</s> add // ----------------------------------
// helper functions for working with files
// ----------------------------------
// Writes data first to a temporary file and then renames it to what's specified in path
func writeFileSafe(path string, data []byte) error {
dir := filepath.Dir(path)
err := os.MkdirAll(dir, 0755)
if err != nil {
return err
}
tmpPath := path + ".tmp"
err = ioutil.WriteFile(tmpPath, data, 0644)
if err != nil {
return err </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove doConfigRename := true
</s> add executableName := filepath.Base(executable)
if executableName == "AdGuardHome" {
// Binary build
config.ourBinaryDir = filepath.Dir(executable)
} else {
// Most likely we're debugging -- using current working directory in this case
workDir, _ := os.Getwd()
config.ourBinaryDir = workDir
}
log.Printf("Current working directory is %s", config.ourBinaryDir)
} | }()
}
func refreshFiltersIfNeccessary() int {
config.Lock()
// deduplicate
// TODO: move it somewhere else
{ | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
// fetch URLs
updateCount := 0
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
updated, err := filter.update(now)
if err != nil {
log.Printf("Failed to update filter %s: %s\n", filter.URL, err)
continue
}
if updated {
| </s> remove err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
</s> add // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} </s> remove ok, err := filter.update(time.Now())
</s> add ok, err := filter.update(true) </s> remove temporaryConfig.FilterFile = filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
</s> add // fill the list of filters
filters := make([]coreDnsFilter, 0)
// first of all, append the user filter
userFilter := getUserFilter()
// TODO: Don't add if empty
//if len(userFilter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: userFilter.ID, Path: userFilter.getFilterFilePath()})
//}
// then go through other filters
for i := range config.Filters {
filter := &config.Filters[i]
if filter.Enabled && len(filter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: filter.ID, Path: filter.getFilterFilePath()})
}
}
temporaryConfig.Filters = filters
</s> remove err := writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
}
</s> add | updated, err := filter.update(false) | // fetch URLs
updateCount := 0
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
updated, err := filter.update(false)
if err != nil {
log.Printf("Failed to update filter %s: %s\n", filter.URL, err)
continue
}
if updated { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
}
config.Unlock()
if updateCount > 0 {
err := writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
}
tellCoreDNSToReload()
}
return updateCount
}
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Errorf("Couldn't write filter file: %s", err)
log.Println(errortext)
return errortext
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | }
config.Unlock()
if updateCount > 0 {
tellCoreDNSToReload()
}
return updateCount
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
}
return updateCount
}
func (filter *filter) update(now time.Time) (bool, error) {
if !filter.Enabled {
return false, nil
}
elapsed := time.Since(filter.LastUpdated)
if elapsed <= updatePeriod {
| </s> remove elapsed := time.Since(filter.LastUpdated)
if elapsed <= updatePeriod {
</s> add if !force && time.Since(filter.LastUpdated) <= updatePeriod { </s> remove err := writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
}
</s> add </s> remove for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
</s> add return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil </s> remove // write filter file
func writeFilterFile() error {
filterpath := filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
log.Printf("Writing filter file: %s", filterpath)
// TODO: check if file contents have modified
data := []byte{}
config.RLock()
filters := config.Filters
for _, filter := range filters {
if !filter.Enabled {
continue
}
data = append(data, filter.contents...)
data = append(data, '\n')
</s> add // saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err | // Checks for filters updates
// If "force" is true -- does not check the filter's LastUpdated field
func (filter *filter) update(force bool) (bool, error) { | }
return updateCount
}
// Checks for filters updates
// If "force" is true -- does not check the filter's LastUpdated field
func (filter *filter) update(force bool) (bool, error) {
if !filter.Enabled {
return false, nil
}
elapsed := time.Since(filter.LastUpdated)
if elapsed <= updatePeriod { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
func (filter *filter) update(now time.Time) (bool, error) {
if !filter.Enabled {
return false, nil
}
elapsed := time.Since(filter.LastUpdated)
if elapsed <= updatePeriod {
return false, nil
}
// use same update period for failed filter downloads to avoid flooding with requests
filter.LastUpdated = now
| </s> remove func (filter *filter) update(now time.Time) (bool, error) {
</s> add // Checks for filters updates
// If "force" is true -- does not check the filter's LastUpdated field
func (filter *filter) update(force bool) (bool, error) { </s> remove filter.LastUpdated = now
</s> add filter.LastUpdated = time.Now() </s> remove for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
</s> add return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil </s> remove // write filter file
func writeFilterFile() error {
filterpath := filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
log.Printf("Writing filter file: %s", filterpath)
// TODO: check if file contents have modified
data := []byte{}
config.RLock()
filters := config.Filters
for _, filter := range filters {
if !filter.Enabled {
continue
}
data = append(data, filter.contents...)
data = append(data, '\n')
</s> add // saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err | if !force && time.Since(filter.LastUpdated) <= updatePeriod { | func (filter *filter) update(now time.Time) (bool, error) {
if !filter.Enabled {
return false, nil
}
if !force && time.Since(filter.LastUpdated) <= updatePeriod {
if !force && time.Since(filter.LastUpdated) <= updatePeriod {
return false, nil
}
// use same update period for failed filter downloads to avoid flooding with requests
filter.LastUpdated = now | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
}
// use same update period for failed filter downloads to avoid flooding with requests
filter.LastUpdated = time.Now()
resp, err := client.Get(filter.URL)
if resp != nil && resp.Body != nil {
| </s> remove filter.LastUpdated = now
</s> add filter.LastUpdated = time.Now() </s> remove elapsed := time.Since(filter.LastUpdated)
if elapsed <= updatePeriod {
</s> add if !force && time.Since(filter.LastUpdated) <= updatePeriod { </s> remove err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
</s> add // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} </s> remove updated, err := filter.update(now)
</s> add updated, err := filter.update(false) </s> remove func clamp(value, low, high int) int {
if value < low {
return low
</s> add // ----------------------------------
// helper functions for working with files
// ----------------------------------
// Writes data first to a temporary file and then renames it to what's specified in path
func writeFileSafe(path string, data []byte) error {
dir := filepath.Dir(path)
err := os.MkdirAll(dir, 0755)
if err != nil {
return err
}
tmpPath := path + ".tmp"
err = ioutil.WriteFile(tmpPath, data, 0644)
if err != nil {
return err | log.Printf("Downloading update for filter %d", filter.ID)
| }
log.Printf("Downloading update for filter %d", filter.ID)
// use same update period for failed filter downloads to avoid flooding with requests
filter.LastUpdated = time.Now()
resp, err := client.Get(filter.URL)
if resp != nil && resp.Body != nil { | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
return false, nil
}
// use same update period for failed filter downloads to avoid flooding with requests
filter.LastUpdated = now
resp, err := client.Get(filter.URL)
if resp != nil && resp.Body != nil {
defer resp.Body.Close()
}
| </s> remove elapsed := time.Since(filter.LastUpdated)
if elapsed <= updatePeriod {
</s> add if !force && time.Since(filter.LastUpdated) <= updatePeriod { </s> remove err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
</s> add // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} </s> remove for i, filterFileName := range filterFileNames {
file, err := os.Open(filterFileName)
</s> add file, err := os.Open(filter.Path) | filter.LastUpdated = time.Now() | return false, nil
}
// use same update period for failed filter downloads to avoid flooding with requests
filter.LastUpdated = time.Now()
resp, err := client.Get(filter.URL)
if resp != nil && resp.Body != nil {
defer resp.Body.Close()
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
log.Printf("Couldn't request filter from URL %s, skipping: %s", filter.URL, err)
return false, err
}
if resp.StatusCode >= 400 {
log.Printf("Got status code %d from URL %s, skipping", resp.StatusCode, filter.URL)
return false, fmt.Errorf("Got status code >= 400: %d", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
| </s> remove return false, fmt.Errorf("Got status code >= 400: %d", resp.StatusCode)
</s> add return false, fmt.Errorf("got status code != 200: %d", resp.StatusCode)
}
contentType := strings.ToLower(resp.Header.Get("content-type"))
if !strings.HasPrefix(contentType, "text/plain") {
log.Printf("Non-text response %s from %s, skipping", contentType, filter.URL)
return false, fmt.Errorf("non-text response %s", contentType) </s> remove // extract filter name and count number of rules
</s> add // Extract filter name and count number of rules </s> remove log.Printf("Added %d rules from %s", count, filterFileName)
</s> add log.Printf("Added %d rules from %d", count, filter.ID) </s> remove ok, err := filter.update(time.Now())
</s> add ok, err := filter.update(true) </s> remove err = d.AddRule(line, 0)
if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax {
continue
}
if err != nil {
log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err)
// Just ignore invalid rules
continue
}
</s> add | if resp.StatusCode != 200 { | log.Printf("Couldn't request filter from URL %s, skipping: %s", filter.URL, err)
return false, err
}
if resp.StatusCode != 200 {
log.Printf("Got status code %d from URL %s, skipping", resp.StatusCode, filter.URL)
return false, fmt.Errorf("Got status code >= 400: %d", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
}
if resp.StatusCode >= 400 {
log.Printf("Got status code %d from URL %s, skipping", resp.StatusCode, filter.URL)
return false, fmt.Errorf("Got status code >= 400: %d", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Printf("Couldn't fetch filter contents from URL %s, skipping: %s", filter.URL, err)
| </s> remove if resp.StatusCode >= 400 {
</s> add if resp.StatusCode != 200 { </s> remove // extract filter name and count number of rules
</s> add // Extract filter name and count number of rules </s> remove ok, err := filter.update(time.Now())
</s> add ok, err := filter.update(true) </s> remove log.Printf("Added %d rules from %s", count, filterFileName)
</s> add log.Printf("Added %d rules from %d", count, filter.ID) | return false, fmt.Errorf("got status code != 200: %d", resp.StatusCode)
}
contentType := strings.ToLower(resp.Header.Get("content-type"))
if !strings.HasPrefix(contentType, "text/plain") {
log.Printf("Non-text response %s from %s, skipping", contentType, filter.URL)
return false, fmt.Errorf("non-text response %s", contentType) | }
if resp.StatusCode >= 400 {
log.Printf("Got status code %d from URL %s, skipping", resp.StatusCode, filter.URL)
return false, fmt.Errorf("got status code != 200: %d", resp.StatusCode)
}
contentType := strings.ToLower(resp.Header.Get("content-type"))
if !strings.HasPrefix(contentType, "text/plain") {
log.Printf("Non-text response %s from %s, skipping", contentType, filter.URL)
return false, fmt.Errorf("non-text response %s", contentType)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Printf("Couldn't fetch filter contents from URL %s, skipping: %s", filter.URL, err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
log.Printf("Couldn't fetch filter contents from URL %s, skipping: %s", filter.URL, err)
return false, err
}
// extract filter name and count number of rules
lines := strings.Split(string(body), "\n")
rulesCount := 0
seenTitle := false
d := dnsfilter.New()
for _, line := range lines {
| </s> remove d := dnsfilter.New()
</s> add // Count lines in the filter </s> remove return false, fmt.Errorf("Got status code >= 400: %d", resp.StatusCode)
</s> add return false, fmt.Errorf("got status code != 200: %d", resp.StatusCode)
}
contentType := strings.ToLower(resp.Header.Get("content-type"))
if !strings.HasPrefix(contentType, "text/plain") {
log.Printf("Non-text response %s from %s, skipping", contentType, filter.URL)
return false, fmt.Errorf("non-text response %s", contentType) </s> remove if resp.StatusCode >= 400 {
</s> add if resp.StatusCode != 200 { </s> remove log.Printf("filterFileNames = %+v", filterFileNames)
</s> add for _, filter := range p.settings.Filters {
log.Printf("Loading rules from %s", filter.Path) </s> remove updated, err := filter.update(now)
</s> add updated, err := filter.update(false) | // Extract filter name and count number of rules | log.Printf("Couldn't fetch filter contents from URL %s, skipping: %s", filter.URL, err)
return false, err
}
// Extract filter name and count number of rules
lines := strings.Split(string(body), "\n")
rulesCount := 0
seenTitle := false
d := dnsfilter.New()
for _, line := range lines { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
// extract filter name and count number of rules
lines := strings.Split(string(body), "\n")
rulesCount := 0
seenTitle := false
d := dnsfilter.New()
for _, line := range lines {
line = strings.TrimSpace(line)
if len(line) > 0 && line[0] == '!' {
if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle {
filter.Name = m[0][1]
| </s> remove // extract filter name and count number of rules
</s> add // Extract filter name and count number of rules </s> remove temporaryConfig.FilterFile = filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
</s> add // fill the list of filters
filters := make([]coreDnsFilter, 0)
// first of all, append the user filter
userFilter := getUserFilter()
// TODO: Don't add if empty
//if len(userFilter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: userFilter.ID, Path: userFilter.getFilterFilePath()})
//}
// then go through other filters
for i := range config.Filters {
filter := &config.Filters[i]
if filter.Enabled && len(filter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: filter.ID, Path: filter.getFilterFilePath()})
}
}
temporaryConfig.Filters = filters
</s> remove err = d.AddRule(line, 0)
if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax {
continue
}
if err != nil {
log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err)
// Just ignore invalid rules
continue
}
</s> add </s> remove switch c.Val() {
</s> add blockValue := c.Val()
switch blockValue { </s> remove args := c.RemainingArgs()
if len(args) > 0 {
filterFileNames = append(filterFileNames, args...)
}
</s> add | // Count lines in the filter | // extract filter name and count number of rules
lines := strings.Split(string(body), "\n")
rulesCount := 0
seenTitle := false
// Count lines in the filter
for _, line := range lines {
line = strings.TrimSpace(line)
if len(line) > 0 && line[0] == '!' {
if m := filterTitle.FindAllStringSubmatch(line, -1); len(m) > 0 && len(m[0]) >= 2 && !seenTitle {
filter.Name = m[0][1] | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
filter.Name = m[0][1]
seenTitle = true
}
} else if len(line) != 0 {
err = d.AddRule(line, 0)
if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax {
continue
}
if err != nil {
log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err)
// Just ignore invalid rules
continue
}
rulesCount++
}
}
if bytes.Equal(filter.contents, body) {
return false, nil
| </s> remove err = p.d.AddRule(text, uint32(i))
</s> add err = p.d.AddRule(text, filter.ID) </s> remove log.Printf("Added %d rules from %s", count, filterFileName)
</s> add log.Printf("Added %d rules from %d", count, filter.ID) </s> remove err = os.Rename(oldConfigFile, newConfigFile)
if err != nil {
log.Printf("Failed to rename %s to %s: %s", oldConfigFile, newConfigFile, err)
return err
</s> add // Perform upgrade operations for each consecutive version upgrade
for oldVersion, newVersion := config.SchemaVersion, config.SchemaVersion+1; newVersion <= SchemaVersion; {
err := upgradeConfigSchema(oldVersion, newVersion)
if err != nil {
log.Fatal(err)
}
// Increment old and new versions
oldVersion++
newVersion++
}
// Save the current schema version
config.SchemaVersion = SchemaVersion
return nil
}
// Upgrade from oldVersion to newVersion
func upgradeConfigSchema(oldVersion int, newVersion int) error {
if oldVersion == 0 && newVersion == 1 {
log.Printf("Updating schema from %d to %d", oldVersion, newVersion)
// The first schema upgrade:
// Added "ID" field to "filter" -- we need to populate this field now
// Added "config.ourDataDir" -- where we will now store filters contents
for i := range config.Filters {
filter := &config.Filters[i] // otherwise we will be operating on a copy
log.Printf("Seting ID=%d for filter %s", i, filter.URL)
filter.ID = i + 1 // start with ID=1
// Forcibly update the filter
_, err := filter.update(true)
if err != nil {
log.Fatal(err)
}
}
// No more "dnsfilter.txt", filters are now loaded from config.ourDataDir/filters/
dnsFilterPath := filepath.Join(config.ourBinaryDir, "dnsfilter.txt")
_, err := os.Stat(dnsFilterPath)
if !os.IsNotExist(err) {
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
err = os.Remove(dnsFilterPath)
if err != nil {
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
}
} </s> remove if doConfigRename {
err := renameOldConfigIfNeccessary()
if err != nil {
panic(err)
}
}
</s> add | filter.Name = m[0][1]
seenTitle = true
}
} else if len(line) != 0 {
rulesCount++
}
}
if bytes.Equal(filter.contents, body) {
return false, nil | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
} else if len(line) != 0 {
rulesCount++
}
}
if bytes.Equal(filter.contents, body) {
return false, nil
}
log.Printf("Filter %s updated: %d bytes, %d rules", filter.URL, len(body), rulesCount)
filter.RulesCount = rulesCount
| </s> remove err = d.AddRule(line, 0)
if err == dnsfilter.ErrAlreadyExists || err == dnsfilter.ErrInvalidSyntax {
continue
}
if err != nil {
log.Printf("Cannot add rule %s from %s: %s", line, filter.URL, err)
// Just ignore invalid rules
continue
}
</s> add </s> remove return false, fmt.Errorf("Got status code >= 400: %d", resp.StatusCode)
</s> add return false, fmt.Errorf("got status code != 200: %d", resp.StatusCode)
}
contentType := strings.ToLower(resp.Header.Get("content-type"))
if !strings.HasPrefix(contentType, "text/plain") {
log.Printf("Non-text response %s from %s, skipping", contentType, filter.URL)
return false, fmt.Errorf("non-text response %s", contentType) </s> remove log.Printf("Added %d rules from %s", count, filterFileName)
</s> add log.Printf("Added %d rules from %d", count, filter.ID) | // Check if the filter was really changed | } else if len(line) != 0 {
rulesCount++
}
}
// Check if the filter was really changed
if bytes.Equal(filter.contents, body) {
return false, nil
}
log.Printf("Filter %s updated: %d bytes, %d rules", filter.URL, len(body), rulesCount)
filter.RulesCount = rulesCount | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
log.Printf("Filter %s updated: %d bytes, %d rules", filter.URL, len(body), rulesCount)
filter.RulesCount = rulesCount
filter.contents = body
return true, nil
}
// saves filter contents to the file in config.ourDataDir
| </s> remove // write filter file
func writeFilterFile() error {
filterpath := filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
log.Printf("Writing filter file: %s", filterpath)
// TODO: check if file contents have modified
data := []byte{}
config.RLock()
filters := config.Filters
for _, filter := range filters {
if !filter.Enabled {
continue
}
data = append(data, filter.contents...)
data = append(data, '\n')
</s> add // saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err </s> remove for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
</s> add return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil </s> remove newConfigFile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
_, err = os.Stat(newConfigFile)
if !os.IsNotExist(err) {
// do nothing, file doesn't exist
trace("File %s already exists, will not overwrite", newConfigFile)
return nil
</s> add if config.SchemaVersion > SchemaVersion {
// Unexpected -- config file is newer than the
return fmt.Errorf("configuration file is supposed to be used with a newer version of AdGuard Home, schema=%d", config.SchemaVersion) | // Saving it to the filters dir now
err = filter.save()
if err != nil {
return false, nil
}
|
log.Printf("Filter %s updated: %d bytes, %d rules", filter.URL, len(body), rulesCount)
filter.RulesCount = rulesCount
filter.contents = body
// Saving it to the filters dir now
err = filter.save()
if err != nil {
return false, nil
}
return true, nil
}
// saves filter contents to the file in config.ourDataDir | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
filter.contents = body
return true, nil
}
// write filter file
func writeFilterFile() error {
filterpath := filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
log.Printf("Writing filter file: %s", filterpath)
// TODO: check if file contents have modified
data := []byte{}
config.RLock()
filters := config.Filters
for _, filter := range filters {
if !filter.Enabled {
continue
}
data = append(data, filter.contents...)
data = append(data, '\n')
}
for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
}
| </s> remove for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
</s> add return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil </s> remove config.RUnlock()
err := ioutil.WriteFile(filterpath+".tmp", data, 0644)
if err != nil {
log.Printf("Couldn't write filter file: %s", err)
</s> add filterFilePath := filter.getFilterFilePath()
log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath)
if _, err := os.Stat(filterFilePath); os.IsNotExist(err) {
// do nothing, file doesn't exist </s> remove temporaryConfig.FilterFile = filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
</s> add // fill the list of filters
filters := make([]coreDnsFilter, 0)
// first of all, append the user filter
userFilter := getUserFilter()
// TODO: Don't add if empty
//if len(userFilter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: userFilter.ID, Path: userFilter.getFilterFilePath()})
//}
// then go through other filters
for i := range config.Filters {
filter := &config.Filters[i]
if filter.Enabled && len(filter.contents) > 0 {
filters = append(filters, coreDnsFilter{ID: filter.ID, Path: filter.getFilterFilePath()})
}
}
temporaryConfig.Filters = filters
</s> remove func clamp(value, low, high int) int {
if value < low {
return low
</s> add // ----------------------------------
// helper functions for working with files
// ----------------------------------
// Writes data first to a temporary file and then renames it to what's specified in path
func writeFileSafe(path string, data []byte) error {
dir := filepath.Dir(path)
err := os.MkdirAll(dir, 0755)
if err != nil {
return err
}
tmpPath := path + ".tmp"
err = ioutil.WriteFile(tmpPath, data, 0644)
if err != nil {
return err | // saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err | filter.contents = body
return true, nil
}
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
// saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err
}
for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
}
data = append(data, filter.contents...)
data = append(data, '\n')
}
for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
}
config.RUnlock()
err := ioutil.WriteFile(filterpath+".tmp", data, 0644)
if err != nil {
log.Printf("Couldn't write filter file: %s", err)
| </s> remove config.RUnlock()
err := ioutil.WriteFile(filterpath+".tmp", data, 0644)
if err != nil {
log.Printf("Couldn't write filter file: %s", err)
</s> add filterFilePath := filter.getFilterFilePath()
log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath)
if _, err := os.Stat(filterFilePath); os.IsNotExist(err) {
// do nothing, file doesn't exist </s> remove // write filter file
func writeFilterFile() error {
filterpath := filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
log.Printf("Writing filter file: %s", filterpath)
// TODO: check if file contents have modified
data := []byte{}
config.RLock()
filters := config.Filters
for _, filter := range filters {
if !filter.Enabled {
continue
}
data = append(data, filter.contents...)
data = append(data, '\n')
</s> add // saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err </s> remove func clamp(value, low, high int) int {
if value < low {
return low
</s> add // ----------------------------------
// helper functions for working with files
// ----------------------------------
// Writes data first to a temporary file and then renames it to what's specified in path
func writeFileSafe(path string, data []byte) error {
dir := filepath.Dir(path)
err := os.MkdirAll(dir, 0755)
if err != nil {
return err
}
tmpPath := path + ".tmp"
err = ioutil.WriteFile(tmpPath, data, 0644)
if err != nil {
return err </s> remove err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
</s> add err = writeFileSafe(configfile, yamlText) </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil | }
data = append(data, filter.contents...)
data = append(data, '\n')
}
return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil
return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil
return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil
}
config.RUnlock()
err := ioutil.WriteFile(filterpath+".tmp", data, 0644)
if err != nil {
log.Printf("Couldn't write filter file: %s", err) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
}
config.RUnlock()
err := ioutil.WriteFile(filterpath+".tmp", data, 0644)
if err != nil {
log.Printf("Couldn't write filter file: %s", err)
return err
}
err = os.Rename(filterpath+".tmp", filterpath)
if err != nil {
| </s> remove for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
</s> add return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil </s> remove // write filter file
func writeFilterFile() error {
filterpath := filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
log.Printf("Writing filter file: %s", filterpath)
// TODO: check if file contents have modified
data := []byte{}
config.RLock()
filters := config.Filters
for _, filter := range filters {
if !filter.Enabled {
continue
}
data = append(data, filter.contents...)
data = append(data, '\n')
</s> add // saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err </s> remove err = os.Rename(filterpath+".tmp", filterpath)
</s> add filterFile, err := ioutil.ReadFile(filterFilePath) </s> remove log.Printf("Couldn't rename filter file: %s", err)
</s> add </s> remove err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
</s> add err = writeFileSafe(configfile, yamlText) | filterFilePath := filter.getFilterFilePath()
log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath)
if _, err := os.Stat(filterFilePath); os.IsNotExist(err) {
// do nothing, file doesn't exist | for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
}
filterFilePath := filter.getFilterFilePath()
log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath)
if _, err := os.Stat(filterFilePath); os.IsNotExist(err) {
// do nothing, file doesn't exist
filterFilePath := filter.getFilterFilePath()
log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath)
if _, err := os.Stat(filterFilePath); os.IsNotExist(err) {
// do nothing, file doesn't exist
filterFilePath := filter.getFilterFilePath()
log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath)
if _, err := os.Stat(filterFilePath); os.IsNotExist(err) {
// do nothing, file doesn't exist
filterFilePath := filter.getFilterFilePath()
log.Printf("Loading filter %d contents to: %s", filter.ID, filterFilePath)
if _, err := os.Stat(filterFilePath); os.IsNotExist(err) {
// do nothing, file doesn't exist
return err
}
err = os.Rename(filterpath+".tmp", filterpath)
if err != nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
log.Printf("Couldn't write filter file: %s", err)
return err
}
err = os.Rename(filterpath+".tmp", filterpath)
if err != nil {
log.Printf("Couldn't rename filter file: %s", err)
return err
}
return nil
| </s> remove log.Printf("Couldn't rename filter file: %s", err)
</s> add </s> remove err = ioutil.WriteFile(configfile+".tmp", yamlText, 0644)
</s> add err = writeFileSafe(configfile, yamlText) </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err </s> remove log.Printf("Couldn't write YAML config: %s", err)
</s> add log.Printf("Couldn't save YAML config: %s", err) | filterFile, err := ioutil.ReadFile(filterFilePath) | log.Printf("Couldn't write filter file: %s", err)
return err
}
filterFile, err := ioutil.ReadFile(filterFilePath)
if err != nil {
log.Printf("Couldn't rename filter file: %s", err)
return err
}
return nil | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
}
err = os.Rename(filterpath+".tmp", filterpath)
if err != nil {
log.Printf("Couldn't rename filter file: %s", err)
return err
}
return nil
}
| </s> remove err = os.Rename(filterpath+".tmp", filterpath)
</s> add filterFile, err := ioutil.ReadFile(filterFilePath) </s> remove err = os.Rename(configfile+".tmp", configfile)
</s> add userFilter := getUserFilter()
err = userFilter.save() </s> remove log.Printf("Couldn't rename YAML config: %s", err)
</s> add log.Printf("Couldn't save the user filter: %s", err) </s> remove log.Printf("Couldn't write DNS config: %s", err)
}
err = os.Rename(corefile+".tmp", corefile)
if err != nil {
log.Printf("Couldn't rename DNS config: %s", err)
</s> add log.Printf("Couldn't save DNS config: %s", err)
return err </s> remove return err
</s> add return nil | }
err = os.Rename(filterpath+".tmp", filterpath)
if err != nil {
return err
}
return nil
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
|
if err != nil {
return err
}
return nil
}
// Path to the filter contents
func (filter *filter) getFilterFilePath() string {
return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID) + ".txt")
| </s> remove // write filter file
func writeFilterFile() error {
filterpath := filepath.Join(config.ourBinaryDir, config.CoreDNS.FilterFile)
log.Printf("Writing filter file: %s", filterpath)
// TODO: check if file contents have modified
data := []byte{}
config.RLock()
filters := config.Filters
for _, filter := range filters {
if !filter.Enabled {
continue
}
data = append(data, filter.contents...)
data = append(data, '\n')
</s> add // saves filter contents to the file in config.ourDataDir
func (filter *filter) save() error {
filterFilePath := filter.getFilterFilePath()
log.Printf("Saving filter %d contents to: %s", filter.ID, filterFilePath)
err := writeFileSafe(filterFilePath, filter.contents)
if err != nil {
return err </s> remove for _, rule := range config.UserRules {
data = append(data, []byte(rule)...)
data = append(data, '\n')
</s> add return nil;
}
// loads filter contents from the file in config.ourDataDir
func (filter *filter) load() error {
if !filter.Enabled {
// No need to load a filter that is not enabled
return nil </s> remove func (filter *filter) update(now time.Time) (bool, error) {
</s> add // Checks for filters updates
// If "force" is true -- does not check the filter's LastUpdated field
func (filter *filter) update(force bool) (bool, error) { </s> remove func clamp(value, low, high int) int {
if value < low {
return low
</s> add // ----------------------------------
// helper functions for working with files
// ----------------------------------
// Writes data first to a temporary file and then renames it to what's specified in path
func writeFileSafe(path string, data []byte) error {
dir := filepath.Dir(path)
err := os.MkdirAll(dir, 0755)
if err != nil {
return err
}
tmpPath := path + ".tmp"
err = ioutil.WriteFile(tmpPath, data, 0644)
if err != nil {
return err | log.Printf("Filter %d length is %d", filter.ID, len(filterFile))
filter.contents = filterFile | if err != nil {
return err
}
log.Printf("Filter %d length is %d", filter.ID, len(filterFile))
filter.contents = filterFile
return nil
}
// Path to the filter contents
func (filter *filter) getFilterFilePath() string {
return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID) + ".txt") | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
return nil
}
// ------------
// safebrowsing
// ------------
func handleSafeBrowsingEnable(w http.ResponseWriter, r *http.Request) {
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | // Path to the filter contents
func (filter *filter) getFilterFilePath() string {
return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID) + ".txt")
}
| return nil
}
// Path to the filter contents
func (filter *filter) getFilterFilePath() string {
return filepath.Join(config.ourBinaryDir, config.ourDataDir, FiltersDir, strconv.Itoa(filter.ID) + ".txt")
}
// ------------
// safebrowsing
// ------------
func handleSafeBrowsingEnable(w http.ResponseWriter, r *http.Request) { | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | control.go |
errortext := fmt.Errorf("Unable to write coredns config: %s", err)
log.Println(errortext)
return errortext
}
err = writeFilterFile()
if err != nil {
errortext := fmt.Errorf("Couldn't write filter file: %s", err)
log.Println(errortext)
return errortext
}
go coremain.Run()
return nil
}
| </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err := writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add </s> remove err = writeFilterFile()
if err != nil {
errortext := fmt.Sprintf("Couldn't write filter file: %s", err)
log.Println(errortext)
http.Error(w, errortext, http.StatusInternalServerError)
return
}
</s> add | errortext := fmt.Errorf("Unable to write coredns config: %s", err)
log.Println(errortext)
return errortext
}
go coremain.Run()
return nil
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | coredns.go |
|
)
type plugSettings struct {
SafeBrowsingBlockHost string
ParentalBlockHost string
QueryLogEnabled bool
BlockedTTL uint32 // in seconds, default 3600
Filters []plugFilter
| </s> remove FilterFile string `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"`
</s> add Filters []coreDnsFilter `yaml:"-"`
Port int `yaml:"port"`
ProtectionEnabled bool `yaml:"protection_enabled"`
FilteringEnabled bool `yaml:"filtering_enabled"`
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
SafeSearchEnabled bool `yaml:"safesearch_enabled"`
ParentalEnabled bool `yaml:"parental_enabled"`
ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"`
Pprof string `yaml:"-"`
Cache string `yaml:"-"`
Prometheus string `yaml:"-"`
UpstreamDNS []string `yaml:"upstream_dns"` </s> remove BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"`
</s> add // Schema version of the config file. This value is used when performing the app updates.
SchemaVersion int `yaml:"schema_version"`
BindHost string `yaml:"bind_host"`
BindPort int `yaml:"bind_port"`
AuthName string `yaml:"auth_name"`
AuthPass string `yaml:"auth_pass"`
CoreDNS coreDNSConfig `yaml:"coredns"`
Filters []filter `yaml:"filters"`
UserRules []string `yaml:"user_rules"` </s> remove
"gopkg.in/yaml.v2"
</s> add | type plugFilter struct {
ID uint32
Path string
}
| )
type plugFilter struct {
ID uint32
Path string
}
type plugSettings struct {
SafeBrowsingBlockHost string
ParentalBlockHost string
QueryLogEnabled bool
BlockedTTL uint32 // in seconds, default 3600
Filters []plugFilter | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix #371 #421
Filters are now saved to a file
Also, they're loaded from the file on startup
Filter ID is not passed to the CoreDNS plugin config (server-side AG DNS must be changed accordingly)
Some minor refactoring, unused functions removed | https://github.com/AdguardTeam/AdGuardHome/commit/32d4e80c93cba5b3ef4bb96c79f7256b5cb4d913 | coredns_plugin/coredns_plugin.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.