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
|
---|---|---|---|---|---|---|---|
return rcode, dnsfilter.Result{Reason: dnsfilter.FilteredSafeSearch}, err
}
// needs to be filtered instead
result, err := p.d.CheckHost(host)
if err != nil {
log.Printf("plugin/dnsfilter: %s\n", err)
p.RUnlock()
return dns.RcodeServerFailure, dnsfilter.Result{}, fmt.Errorf("plugin/dnsfilter: %s", err)
| </s> | p.RLock() | return rcode, dnsfilter.Result{Reason: dnsfilter.FilteredSafeSearch}, err
}
// needs to be filtered instead
p.RLock()
result, err := p.d.CheckHost(host)
if err != nil {
log.Printf("plugin/dnsfilter: %s\n", err)
p.RUnlock()
return dns.RcodeServerFailure, dnsfilter.Result{}, fmt.Errorf("plugin/dnsfilter: %s", err) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | coredns_plugin/coredns_plugin.go |
if err != nil {
log.Printf("plugin/dnsfilter: %s\n", err)
return dns.RcodeServerFailure, dnsfilter.Result{}, fmt.Errorf("plugin/dnsfilter: %s", err)
}
p.RUnlock()
if result.IsFiltered {
switch result.Reason {
| </s> | p.RUnlock() | if err != nil {
log.Printf("plugin/dnsfilter: %s\n", err)
p.RUnlock()
return dns.RcodeServerFailure, dnsfilter.Result{}, fmt.Errorf("plugin/dnsfilter: %s", err)
}
p.RUnlock()
if result.IsFiltered {
switch result.Reason { | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | coredns_plugin/coredns_plugin.go |
log.Printf("plugin/dnsfilter: %s\n", err)
p.RUnlock()
return dns.RcodeServerFailure, dnsfilter.Result{}, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result.IsFiltered {
switch result.Reason {
case dnsfilter.FilteredSafeBrowsing:
// return cname safebrowsing.block.dns.adguard.com
| </s> | p.RUnlock() | log.Printf("plugin/dnsfilter: %s\n", err)
p.RUnlock()
return dns.RcodeServerFailure, dnsfilter.Result{}, fmt.Errorf("plugin/dnsfilter: %s", err)
}
p.RUnlock()
if result.IsFiltered {
switch result.Reason {
case dnsfilter.FilteredSafeBrowsing:
// return cname safebrowsing.block.dns.adguard.com | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | coredns_plugin/coredns_plugin.go |
"runtime"
"strconv"
"strings"
"time"
"github.com/AdguardTeam/AdguardDNS/dnsfilter"
"github.com/coredns/coredns/plugin/pkg/response"
"github.com/miekg/dns"
)
| </s> remove soa.Serial = uint32(time.Now().Unix())
return []dns.RR{soa}
</s> add soa.Serial = 100500 // faster than uint32(time.Now().Unix())
return []dns.RR{&soa} | "sync" | "runtime"
"strconv"
"strings"
"sync"
"time"
"github.com/AdguardTeam/AdguardDNS/dnsfilter"
"github.com/coredns/coredns/plugin/pkg/response"
"github.com/miekg/dns"
) | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | coredns_plugin/querylog.go |
queryLogAPI = 1000 // maximum API response for /querylog
)
var (
logBuffer []logEntry
)
type logEntry struct {
| </s> remove sync.Mutex `yaml:"-"`
</s> add sync.RWMutex `yaml:"-"` | logBufferLock sync.RWMutex | queryLogAPI = 1000 // maximum API response for /querylog
)
var (
logBufferLock sync.RWMutex
logBuffer []logEntry
)
type logEntry struct { | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | coredns_plugin/querylog.go |
IP: ip,
}
var flushBuffer []logEntry
logBuffer = append(logBuffer, entry)
if len(logBuffer) >= logBufferCap {
flushBuffer = logBuffer
logBuffer = nil
}
| </s> | logBufferLock.Lock() | IP: ip,
}
var flushBuffer []logEntry
logBufferLock.Lock()
logBuffer = append(logBuffer, entry)
if len(logBuffer) >= logBufferCap {
flushBuffer = logBuffer
logBuffer = nil
} | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | coredns_plugin/querylog.go |
logBuffer = nil
}
if len(flushBuffer) > 0 {
// write to file
// do it in separate goroutine -- we are stalling DNS response this whole time
go flushToFile(flushBuffer)
}
return
| </s> | logBufferLock.Unlock() | logBuffer = nil
}
logBufferLock.Unlock()
if len(flushBuffer) > 0 {
// write to file
// do it in separate goroutine -- we are stalling DNS response this whole time
go flushToFile(flushBuffer)
}
return | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | coredns_plugin/querylog.go |
// TODO: fetch values from disk if len(logBuffer) < queryLogSize
// TODO: cache output
values := logBuffer
logBufferLock.RUnlock()
var data = []map[string]interface{}{}
for _, entry := range values {
var q *dns.Msg
var a *dns.Msg
| </s> remove defer config.Unlock()
</s> add | logBufferLock.RLock() | // TODO: fetch values from disk if len(logBuffer) < queryLogSize
// TODO: cache output
logBufferLock.RLock()
values := logBuffer
logBufferLock.RUnlock()
var data = []map[string]interface{}{}
for _, entry := range values {
var q *dns.Msg
var a *dns.Msg | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | coredns_plugin/querylog.go |
// TODO: fetch values from disk if len(logBuffer) < queryLogSize
// TODO: cache output
logBufferLock.RLock()
values := logBuffer
var data = []map[string]interface{}{}
for _, entry := range values {
var q *dns.Msg
var a *dns.Msg
| </s> remove defer config.Unlock()
</s> add | logBufferLock.RUnlock() | // TODO: fetch values from disk if len(logBuffer) < queryLogSize
// TODO: cache output
logBufferLock.RLock()
values := logBuffer
logBufferLock.RUnlock()
var data = []map[string]interface{}{}
for _, entry := range values {
var q *dns.Msg
var a *dns.Msg
| [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | coredns_plugin/querylog.go |
"path/filepath"
"strconv"
"strings"
"syscall"
"time"
)
var client = &http.Client{
| </s> | "sync" | "path/filepath"
"strconv"
"strings"
"sync"
"syscall"
"time"
)
var client = &http.Client{ | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
PerHour periodicStats
PerDay periodicStats
LastSeen statsEntry
}
var statistics stats
| </s> | sync.RWMutex | PerHour periodicStats
PerDay periodicStats
LastSeen statsEntry
sync.RWMutex
}
var statistics stats
| [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
}
func purgeStats() {
initPeriodicStats(&statistics.PerSecond)
initPeriodicStats(&statistics.PerMinute)
initPeriodicStats(&statistics.PerHour)
initPeriodicStats(&statistics.PerDay)
statistics.Unlock()
}
| </s> | statistics.Lock() | }
func purgeStats() {
statistics.Lock()
initPeriodicStats(&statistics.PerSecond)
initPeriodicStats(&statistics.PerMinute)
initPeriodicStats(&statistics.PerHour)
initPeriodicStats(&statistics.PerDay)
statistics.Unlock()
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
initPeriodicStats(&statistics.PerMinute)
initPeriodicStats(&statistics.PerHour)
initPeriodicStats(&statistics.PerDay)
}
func runStatsCollectors() {
go statsCollector(time.Second)
}
| </s> | statistics.Unlock() | initPeriodicStats(&statistics.PerMinute)
initPeriodicStats(&statistics.PerHour)
initPeriodicStats(&statistics.PerDay)
statistics.Unlock()
}
func runStatsCollectors() {
go statsCollector(time.Second)
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
func collectStats() {
now := time.Now()
statsRotate(&statistics.PerSecond, now, int64(now.Sub(statistics.PerSecond.LastRotate)/time.Second))
statsRotate(&statistics.PerMinute, now, int64(now.Sub(statistics.PerMinute.LastRotate)/time.Minute))
statsRotate(&statistics.PerHour, now, int64(now.Sub(statistics.PerHour.LastRotate)/time.Hour))
statsRotate(&statistics.PerDay, now, int64(now.Sub(statistics.PerDay.LastRotate)/time.Hour/24))
statistics.Unlock()
| </s> remove defer config.Unlock()
</s> add | statistics.Lock() | func collectStats() {
now := time.Now()
statistics.Lock()
statsRotate(&statistics.PerSecond, now, int64(now.Sub(statistics.PerSecond.LastRotate)/time.Second))
statsRotate(&statistics.PerMinute, now, int64(now.Sub(statistics.PerMinute.LastRotate)/time.Minute))
statsRotate(&statistics.PerHour, now, int64(now.Sub(statistics.PerHour.LastRotate)/time.Hour))
statsRotate(&statistics.PerDay, now, int64(now.Sub(statistics.PerDay.LastRotate)/time.Hour/24))
statistics.Unlock() | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
statsRotate(&statistics.PerHour, now, int64(now.Sub(statistics.PerHour.LastRotate)/time.Hour))
statsRotate(&statistics.PerDay, now, int64(now.Sub(statistics.PerDay.LastRotate)/time.Hour/24))
// grab HTTP from prometheus
resp, err := client.Get("http://127.0.0.1:9153/metrics")
if resp != nil && resp.Body != nil {
| </s> | statistics.Unlock() | statsRotate(&statistics.PerHour, now, int64(now.Sub(statistics.PerHour.LastRotate)/time.Hour))
statsRotate(&statistics.PerDay, now, int64(now.Sub(statistics.PerDay.LastRotate)/time.Hour/24))
statistics.Unlock()
// grab HTTP from prometheus
resp, err := client.Get("http://127.0.0.1:9153/metrics")
if resp != nil && resp.Body != nil { | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
entry[key] = value
}
// calculate delta
delta := calcDelta(entry, statistics.LastSeen)
// apply delta to second/minute/hour/day
applyDelta(&statistics.PerSecond, delta)
applyDelta(&statistics.PerMinute, delta)
applyDelta(&statistics.PerHour, delta)
| </s> | statistics.Lock() | entry[key] = value
}
// calculate delta
statistics.Lock()
delta := calcDelta(entry, statistics.LastSeen)
// apply delta to second/minute/hour/day
applyDelta(&statistics.PerSecond, delta)
applyDelta(&statistics.PerMinute, delta)
applyDelta(&statistics.PerHour, delta) | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
// save last seen
statistics.LastSeen = entry
}
func calcDelta(current, seen statsEntry) statsEntry {
delta := statsEntry{}
for key, currentValue := range current {
| </s> | statistics.Unlock() | // save last seen
statistics.LastSeen = entry
statistics.Unlock()
}
func calcDelta(current, seen statsEntry) statsEntry {
delta := statsEntry{}
for key, currentValue := range current { | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
func writeStats() error {
statsFile := filepath.Join(config.ourBinaryDir, "stats.json")
log.Printf("Writing JSON file: %s", statsFile)
json, err := json.MarshalIndent(statistics, "", " ")
statistics.RUnlock()
if err != nil {
log.Printf("Couldn't generate JSON: %s", err)
return err
| </s> | statistics.RLock() | func writeStats() error {
statsFile := filepath.Join(config.ourBinaryDir, "stats.json")
log.Printf("Writing JSON file: %s", statsFile)
statistics.RLock()
json, err := json.MarshalIndent(statistics, "", " ")
statistics.RUnlock()
if err != nil {
log.Printf("Couldn't generate JSON: %s", err)
return err | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
statistics.RLock()
json, err := json.MarshalIndent(statistics, "", " ")
if err != nil {
log.Printf("Couldn't generate JSON: %s", err)
return err
}
err = ioutil.WriteFile(statsFile+".tmp", json, 0644)
| </s> | statistics.RUnlock() | statistics.RLock()
json, err := json.MarshalIndent(statistics, "", " ")
statistics.RUnlock()
if err != nil {
log.Printf("Couldn't generate JSON: %s", err)
return err
}
err = ioutil.WriteFile(statsFile+".tmp", json, 0644) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Fix race conditions found by go's race detector | https://github.com/AdguardTeam/AdGuardHome/commit/2244c21b765e089e49fede0cc27af7f9f76bae4d | stats.go |
package home
import (
"fmt"
"strings"
"time"
"github.com/AdguardTeam/dnsproxy/upstream"
"github.com/AdguardTeam/golibs/cache"
| </s> remove "sync"
</s> add </s> remove "sync"
</s> add | "encoding/binary" | package home
import (
"encoding/binary"
"fmt"
"strings"
"time"
"github.com/AdguardTeam/dnsproxy/upstream"
"github.com/AdguardTeam/golibs/cache" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
import (
"fmt"
"strings"
"sync"
"time"
"github.com/AdguardTeam/dnsproxy/upstream"
"github.com/AdguardTeam/golibs/log"
"github.com/miekg/dns"
| </s> remove "sync"
</s> add |
import (
"fmt"
"strings"
"time"
"github.com/AdguardTeam/dnsproxy/upstream"
"github.com/AdguardTeam/golibs/log"
"github.com/miekg/dns" | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
|
"strings"
"time"
"github.com/AdguardTeam/dnsproxy/upstream"
"github.com/AdguardTeam/golibs/log"
"github.com/miekg/dns"
)
const (
rdnsTimeout = 3 * time.Second // max time to wait for rDNS response
| </s> remove "sync"
</s> add </s> remove "sync"
</s> add | "github.com/AdguardTeam/golibs/cache" | "strings"
"time"
"github.com/AdguardTeam/dnsproxy/upstream"
"github.com/AdguardTeam/golibs/cache"
"github.com/AdguardTeam/golibs/log"
"github.com/miekg/dns"
)
const (
rdnsTimeout = 3 * time.Second // max time to wait for rDNS response | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
// RDNS - module context
type RDNS struct {
clients *clientsContainer
ipChannel chan string // pass data from DNS request handling thread to rDNS thread
// contains IP addresses of clients to be resolved by rDNS
// if IP address couldn't be resolved, it stays here forever to prevent further attempts to resolve the same IP
ips map[string]bool
lock sync.Mutex // synchronize access to 'ips'
upstream upstream.Upstream // Upstream object for our own DNS server
}
// InitRDNS - create module context
func InitRDNS(clients *clientsContainer) *RDNS {
r := RDNS{}
| </s> remove ips map[string]bool
lock sync.Mutex
</s> add </s> remove if r.clients.Exists(ip, ClientSourceRDNS) {
return
</s> add now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove log.Tracef("rDNS queue is full")
</s> add log.Tracef("rDNS: queue is full") </s> remove // add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
_, ok := r.ips[ip]
if ok {
</s> add if r.clients.Exists(ip, ClientSourceRDNS) { | ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache |
// RDNS - module context
type RDNS struct {
clients *clientsContainer
ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache
ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache
ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache
ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache
ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache
ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache
}
// InitRDNS - create module context
func InitRDNS(clients *clientsContainer) *RDNS {
r := RDNS{} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
log.Error("upstream.AddressToUpstream: %s", err)
return nil
}
r.ips = make(map[string]bool)
r.ipChannel = make(chan string, 256)
go r.workerLoop()
return &r
}
| </s> remove w.ips = make(map[string]bool)
</s> add cconf := cache.Config{}
cconf.EnableLRU = true
cconf.MaxCount = 10000
w.ipAddrs = cache.New(cconf)
</s> remove log.Tracef("Adding %s for rDNS resolve", ip)
</s> add log.Tracef("rDNS: adding %s", ip) </s> remove w.ips[ip] = true
w.lock.Unlock()
</s> add expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = w.ipAddrs.Set([]byte(ip), expire) </s> remove r.ips[ip] = true
</s> add | cconf := cache.Config{}
cconf.EnableLRU = true
cconf.MaxCount = 10000
r.ipAddrs = cache.New(cconf)
| log.Error("upstream.AddressToUpstream: %s", err)
return nil
}
cconf := cache.Config{}
cconf.EnableLRU = true
cconf.MaxCount = 10000
r.ipAddrs = cache.New(cconf)
r.ipChannel = make(chan string, 256)
go r.workerLoop()
return &r
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
}
// Begin - add IP address to rDNS queue
func (r *RDNS) Begin(ip string) {
if r.clients.Exists(ip, ClientSourceRDNS) {
return
}
// add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
| </s> remove // add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
_, ok := r.ips[ip]
if ok {
</s> add if r.clients.Exists(ip, ClientSourceRDNS) { </s> remove log.Tracef("rDNS queue is full")
</s> add log.Tracef("rDNS: queue is full") </s> remove w.lock.Lock()
_, found := w.ips[ip]
if found {
w.lock.Unlock()
return
</s> add now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove ipChannel chan string // pass data from DNS request handling thread to rDNS thread
// contains IP addresses of clients to be resolved by rDNS
// if IP address couldn't be resolved, it stays here forever to prevent further attempts to resolve the same IP
ips map[string]bool
lock sync.Mutex // synchronize access to 'ips'
upstream upstream.Upstream // Upstream object for our own DNS server
</s> add ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache </s> remove r.lock.Lock()
delete(r.ips, ip)
r.lock.Unlock()
</s> add | now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired | }
// Begin - add IP address to rDNS queue
func (r *RDNS) Begin(ip string) {
now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired
now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired
}
// add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
return
}
// TTL expired
}
if r.clients.Exists(ip, ClientSourceRDNS) {
return
}
| </s> remove if r.clients.Exists(ip, ClientSourceRDNS) {
return
</s> add now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove // add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
_, ok := r.ips[ip]
if ok {
</s> add if r.clients.Exists(ip, ClientSourceRDNS) { </s> remove w.lock.Lock()
_, found := w.ips[ip]
if found {
w.lock.Unlock()
return
</s> add now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove r.lock.Lock()
delete(r.ips, ip)
r.lock.Unlock()
</s> add </s> remove r.ips[ip] = true
</s> add | expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = r.ipAddrs.Set([]byte(ip), expire) | return
}
// TTL expired
}
expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = r.ipAddrs.Set([]byte(ip), expire)
if r.clients.Exists(ip, ClientSourceRDNS) {
return
}
| [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
if r.clients.Exists(ip, ClientSourceRDNS) {
return
}
// add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
_, ok := r.ips[ip]
if ok {
return
}
r.ips[ip] = true
log.Tracef("Adding %s for rDNS resolve", ip)
| </s> remove r.ips[ip] = true
</s> add </s> remove if r.clients.Exists(ip, ClientSourceRDNS) {
return
</s> add now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove log.Tracef("Adding %s for rDNS resolve", ip)
</s> add log.Tracef("rDNS: adding %s", ip) </s> remove r.lock.Lock()
delete(r.ips, ip)
r.lock.Unlock()
</s> add | if r.clients.Exists(ip, ClientSourceRDNS) { | if r.clients.Exists(ip, ClientSourceRDNS) {
return
}
if r.clients.Exists(ip, ClientSourceRDNS) {
if r.clients.Exists(ip, ClientSourceRDNS) {
if r.clients.Exists(ip, ClientSourceRDNS) {
if r.clients.Exists(ip, ClientSourceRDNS) {
if r.clients.Exists(ip, ClientSourceRDNS) {
return
}
r.ips[ip] = true
log.Tracef("Adding %s for rDNS resolve", ip) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
_, ok := r.ips[ip]
if ok {
return
}
r.ips[ip] = true
log.Tracef("Adding %s for rDNS resolve", ip)
select {
case r.ipChannel <- ip:
//
| </s> remove // add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
_, ok := r.ips[ip]
if ok {
</s> add if r.clients.Exists(ip, ClientSourceRDNS) { </s> remove log.Tracef("Adding %s for rDNS resolve", ip)
</s> add log.Tracef("rDNS: adding %s", ip) </s> remove log.Tracef("rDNS queue is full")
</s> add log.Tracef("rDNS: queue is full") </s> remove w.ips[ip] = true
w.lock.Unlock()
</s> add expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = w.ipAddrs.Set([]byte(ip), expire) </s> remove w.lock.Lock()
_, found := w.ips[ip]
if found {
w.lock.Unlock()
return
</s> add now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired | _, ok := r.ips[ip]
if ok {
return
}
log.Tracef("Adding %s for rDNS resolve", ip)
select {
case r.ipChannel <- ip:
// | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
|
return
}
r.ips[ip] = true
log.Tracef("Adding %s for rDNS resolve", ip)
select {
case r.ipChannel <- ip:
//
default:
log.Tracef("rDNS queue is full")
| </s> remove r.ips[ip] = true
</s> add </s> remove log.Tracef("rDNS queue is full")
</s> add log.Tracef("rDNS: queue is full") </s> remove // add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
_, ok := r.ips[ip]
if ok {
</s> add if r.clients.Exists(ip, ClientSourceRDNS) { </s> remove w.ips[ip] = true
w.lock.Unlock()
</s> add expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = w.ipAddrs.Set([]byte(ip), expire) </s> remove if r.clients.Exists(ip, ClientSourceRDNS) {
return
</s> add now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired | log.Tracef("rDNS: adding %s", ip) | return
}
r.ips[ip] = true
log.Tracef("rDNS: adding %s", ip)
select {
case r.ipChannel <- ip:
//
default:
log.Tracef("rDNS queue is full") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
select {
case r.ipChannel <- ip:
//
default:
log.Tracef("rDNS queue is full")
}
}
// Use rDNS to get hostname by IP address
func (r *RDNS) resolve(ip string) string {
| </s> remove log.Tracef("Adding %s for rDNS resolve", ip)
</s> add log.Tracef("rDNS: adding %s", ip) </s> remove if r.clients.Exists(ip, ClientSourceRDNS) {
return
</s> add now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove r.ips[ip] = true
</s> add </s> remove ipChannel chan string // pass data from DNS request handling thread to rDNS thread
// contains IP addresses of clients to be resolved by rDNS
// if IP address couldn't be resolved, it stays here forever to prevent further attempts to resolve the same IP
ips map[string]bool
lock sync.Mutex // synchronize access to 'ips'
upstream upstream.Upstream // Upstream object for our own DNS server
</s> add ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache | log.Tracef("rDNS: queue is full") | select {
case r.ipChannel <- ip:
//
default:
log.Tracef("rDNS: queue is full")
}
}
// Use rDNS to get hostname by IP address
func (r *RDNS) resolve(ip string) string { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
if len(host) == 0 {
continue
}
r.lock.Lock()
delete(r.ips, ip)
r.lock.Unlock()
_, _ = config.clients.AddHost(ip, host, ClientSourceRDNS)
}
}
| </s> remove // add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
_, ok := r.ips[ip]
if ok {
</s> add if r.clients.Exists(ip, ClientSourceRDNS) { </s> remove if r.clients.Exists(ip, ClientSourceRDNS) {
return
</s> add now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove w.lock.Lock()
_, found := w.ips[ip]
if found {
w.lock.Unlock()
return
</s> add now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove r.ips[ip] = true
</s> add | if len(host) == 0 {
continue
}
_, _ = config.clients.AddHost(ip, host, ClientSourceRDNS)
}
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/rdns.go |
|
package home
import (
"fmt"
"io/ioutil"
"net"
"strings"
| </s> remove "sync"
</s> add </s> remove "sync"
</s> add | "encoding/binary" | package home
import (
"encoding/binary"
"fmt"
"io/ioutil"
"net"
"strings" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/whois.go |
"fmt"
"io/ioutil"
"net"
"strings"
"sync"
"time"
"github.com/AdguardTeam/golibs/log"
)
| </s> remove "sync"
</s> add | "fmt"
"io/ioutil"
"net"
"strings"
"time"
"github.com/AdguardTeam/golibs/log"
)
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/whois.go |
|
"strings"
"time"
"github.com/AdguardTeam/golibs/log"
)
const (
defaultServer = "whois.arin.net"
| </s> remove "sync"
</s> add </s> remove "sync"
</s> add | "github.com/AdguardTeam/golibs/cache" | "strings"
"time"
"github.com/AdguardTeam/golibs/cache"
"github.com/AdguardTeam/golibs/log"
)
const (
defaultServer = "whois.arin.net" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/whois.go |
// Whois - module context
type Whois struct {
clients *clientsContainer
ips map[string]bool
lock sync.Mutex
ipChan chan string
timeoutMsec uint
}
// Create module context
| </s> remove ipChannel chan string // pass data from DNS request handling thread to rDNS thread
// contains IP addresses of clients to be resolved by rDNS
// if IP address couldn't be resolved, it stays here forever to prevent further attempts to resolve the same IP
ips map[string]bool
lock sync.Mutex // synchronize access to 'ips'
upstream upstream.Upstream // Upstream object for our own DNS server
</s> add ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache </s> remove log.Tracef("rDNS queue is full")
</s> add log.Tracef("rDNS: queue is full") </s> remove if r.clients.Exists(ip, ClientSourceRDNS) {
return
</s> add now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove w.lock.Lock()
_, found := w.ips[ip]
if found {
w.lock.Unlock()
return
</s> add now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired |
// Whois - module context
type Whois struct {
clients *clientsContainer
ipChan chan string
timeoutMsec uint
}
// Create module context | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/whois.go |
|
clients *clientsContainer
ipChan chan string
timeoutMsec uint
}
// Create module context
func initWhois(clients *clientsContainer) *Whois {
w := Whois{}
w.timeoutMsec = 5000
| </s> remove ips map[string]bool
lock sync.Mutex
</s> add </s> remove w.ips = make(map[string]bool)
</s> add cconf := cache.Config{}
cconf.EnableLRU = true
cconf.MaxCount = 10000
w.ipAddrs = cache.New(cconf)
</s> remove ipChannel chan string // pass data from DNS request handling thread to rDNS thread
// contains IP addresses of clients to be resolved by rDNS
// if IP address couldn't be resolved, it stays here forever to prevent further attempts to resolve the same IP
ips map[string]bool
lock sync.Mutex // synchronize access to 'ips'
upstream upstream.Upstream // Upstream object for our own DNS server
</s> add ipChannel chan string // pass data from DNS request handling thread to rDNS thread
upstream upstream.Upstream // Upstream object for our own DNS server
// Contains IP addresses of clients to be resolved by rDNS
// If IP address is resolved, it stays here while it's inside Clients.
// If it's removed from Clients, this IP address will be resolved once again.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache </s> remove log.Tracef("rDNS queue is full")
</s> add log.Tracef("rDNS: queue is full") </s> remove w.lock.Lock()
_, found := w.ips[ip]
if found {
w.lock.Unlock()
return
</s> add now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired | // Contains IP addresses of clients
// An active IP address is resolved once again after it expires.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache | clients *clientsContainer
ipChan chan string
timeoutMsec uint
// Contains IP addresses of clients
// An active IP address is resolved once again after it expires.
// If IP address couldn't be resolved, it stays here for some time to prevent further attempts to resolve the same IP.
ipAddrs cache.Cache
}
// Create module context
func initWhois(clients *clientsContainer) *Whois {
w := Whois{}
w.timeoutMsec = 5000 | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/whois.go |
func initWhois(clients *clientsContainer) *Whois {
w := Whois{}
w.timeoutMsec = 5000
w.clients = clients
w.ips = make(map[string]bool)
w.ipChan = make(chan string, 255)
go w.workerLoop()
return &w
}
| </s> remove r.ips = make(map[string]bool)
</s> add cconf := cache.Config{}
cconf.EnableLRU = true
cconf.MaxCount = 10000
r.ipAddrs = cache.New(cconf)
</s> remove w.ips[ip] = true
w.lock.Unlock()
</s> add expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = w.ipAddrs.Set([]byte(ip), expire) </s> remove w.lock.Lock()
_, found := w.ips[ip]
if found {
w.lock.Unlock()
return
</s> add now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired | cconf := cache.Config{}
cconf.EnableLRU = true
cconf.MaxCount = 10000
w.ipAddrs = cache.New(cconf)
| func initWhois(clients *clientsContainer) *Whois {
w := Whois{}
w.timeoutMsec = 5000
w.clients = clients
cconf := cache.Config{}
cconf.EnableLRU = true
cconf.MaxCount = 10000
w.ipAddrs = cache.New(cconf)
w.ipChan = make(chan string, 255)
go w.workerLoop()
return &w
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/whois.go |
}
// Begin - begin requesting WHOIS info
func (w *Whois) Begin(ip string) {
w.lock.Lock()
_, found := w.ips[ip]
if found {
w.lock.Unlock()
return
}
w.ips[ip] = true
w.lock.Unlock()
log.Debug("Whois: adding %s", ip)
| </s> remove w.ips[ip] = true
w.lock.Unlock()
</s> add expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = w.ipAddrs.Set([]byte(ip), expire) </s> remove if r.clients.Exists(ip, ClientSourceRDNS) {
return
</s> add now := uint64(time.Now().Unix())
expire := r.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove log.Tracef("Adding %s for rDNS resolve", ip)
</s> add log.Tracef("rDNS: adding %s", ip) </s> remove r.ips[ip] = true
</s> add </s> remove // add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
_, ok := r.ips[ip]
if ok {
</s> add if r.clients.Exists(ip, ClientSourceRDNS) { | now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired | }
// Begin - begin requesting WHOIS info
func (w *Whois) Begin(ip string) {
now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired
now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired
now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired
now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired
now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired
}
w.ips[ip] = true
w.lock.Unlock()
log.Debug("Whois: adding %s", ip) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/whois.go |
if found {
w.lock.Unlock()
return
}
w.ips[ip] = true
w.lock.Unlock()
log.Debug("Whois: adding %s", ip)
select {
case w.ipChan <- ip:
//
| </s> remove w.lock.Lock()
_, found := w.ips[ip]
if found {
w.lock.Unlock()
return
</s> add now := uint64(time.Now().Unix())
expire := w.ipAddrs.Get([]byte(ip))
if len(expire) != 0 {
exp := binary.BigEndian.Uint64(expire)
if exp > now {
return
}
// TTL expired </s> remove log.Tracef("Adding %s for rDNS resolve", ip)
</s> add log.Tracef("rDNS: adding %s", ip) </s> remove r.ips[ip] = true
</s> add </s> remove log.Tracef("rDNS queue is full")
</s> add log.Tracef("rDNS: queue is full") </s> remove // add IP to ips, if not exists
r.lock.Lock()
defer r.lock.Unlock()
_, ok := r.ips[ip]
if ok {
</s> add if r.clients.Exists(ip, ClientSourceRDNS) { | expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = w.ipAddrs.Set([]byte(ip), expire) | if found {
w.lock.Unlock()
return
}
expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = w.ipAddrs.Set([]byte(ip), expire)
expire = make([]byte, 8)
const ttl = 12 * 60 * 60
binary.BigEndian.PutUint64(expire, now+ttl)
_ = w.ipAddrs.Set([]byte(ip), expire)
log.Debug("Whois: adding %s", ip)
select {
case w.ipChan <- ip:
// | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * rdns,whois: recheck IP addresses after some time | https://github.com/AdguardTeam/AdGuardHome/commit/235b198ef97d7a46ab6d76a4074ec589fc0148eb | home/whois.go |
"fmt"
"net"
"os"
"time"
"github.com/AdguardTeam/golibs/log"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/dhcpv4/nclient4"
"github.com/insomniacslk/dhcp/iana"
| </s> remove "golang.org/x/net/ipv4"
</s> add </s> remove n, _, _, err := c.ReadFrom(b)
</s> add n, _, err := c.ReadFrom(b) </s> remove cm := ipv4.ControlMessage{}
_, err = c.WriteTo(req.ToBytes(), &cm, dstAddr)
</s> add _, err = c.WriteTo(req.ToBytes(), dstAddr) | "runtime" | "fmt"
"net"
"os"
"runtime"
"time"
"github.com/AdguardTeam/golibs/log"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/dhcpv4/nclient4"
"github.com/insomniacslk/dhcp/iana" | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - dhcp: CheckIfOtherDHCPServersPresent: fix
Sometimes request from DHCP server couldn't be received
because we were bound to a specific IP address. | https://github.com/AdguardTeam/AdGuardHome/commit/23752377b76895dbcd78f25ed6df58e1bbcae153 | dhcpd/check_other_dhcp.go |
"time"
"github.com/AdguardTeam/golibs/log"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/iana"
)
// CheckIfOtherDHCPServersPresent sends a DHCP request to the specified network interface,
// and waits for a response for a period defined by defaultDiscoverTime
func CheckIfOtherDHCPServersPresent(ifaceName string) (bool, error) {
| </s> remove "golang.org/x/net/ipv4"
</s> add </s> remove cm := ipv4.ControlMessage{}
_, err = c.WriteTo(req.ToBytes(), &cm, dstAddr)
</s> add _, err = c.WriteTo(req.ToBytes(), dstAddr) </s> remove n, _, _, err := c.ReadFrom(b)
</s> add n, _, err := c.ReadFrom(b) | "github.com/insomniacslk/dhcp/dhcpv4/nclient4" | "time"
"github.com/AdguardTeam/golibs/log"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/dhcpv4/nclient4"
"github.com/insomniacslk/dhcp/iana"
)
// CheckIfOtherDHCPServersPresent sends a DHCP request to the specified network interface,
// and waits for a response for a period defined by defaultDiscoverTime
func CheckIfOtherDHCPServersPresent(ifaceName string) (bool, error) { | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - dhcp: CheckIfOtherDHCPServersPresent: fix
Sometimes request from DHCP server couldn't be received
because we were bound to a specific IP address. | https://github.com/AdguardTeam/AdGuardHome/commit/23752377b76895dbcd78f25ed6df58e1bbcae153 | dhcpd/check_other_dhcp.go |
"github.com/AdguardTeam/golibs/log"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/iana"
"golang.org/x/net/ipv4"
)
// CheckIfOtherDHCPServersPresent sends a DHCP request to the specified network interface,
// and waits for a response for a period defined by defaultDiscoverTime
func CheckIfOtherDHCPServersPresent(ifaceName string) (bool, error) {
| </s> remove cm := ipv4.ControlMessage{}
_, err = c.WriteTo(req.ToBytes(), &cm, dstAddr)
</s> add _, err = c.WriteTo(req.ToBytes(), dstAddr) </s> remove n, _, _, err := c.ReadFrom(b)
</s> add n, _, err := c.ReadFrom(b) |
"github.com/AdguardTeam/golibs/log"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/iana"
)
// CheckIfOtherDHCPServersPresent sends a DHCP request to the specified network interface,
// and waits for a response for a period defined by defaultDiscoverTime
func CheckIfOtherDHCPServersPresent(ifaceName string) (bool, error) { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - dhcp: CheckIfOtherDHCPServersPresent: fix
Sometimes request from DHCP server couldn't be received
because we were bound to a specific IP address. | https://github.com/AdguardTeam/AdGuardHome/commit/23752377b76895dbcd78f25ed6df58e1bbcae153 | dhcpd/check_other_dhcp.go |
|
}
srcIP := ifaceIPNet[0]
src := net.JoinHostPort(srcIP.String(), "68")
dst := "255.255.255.255:67"
hostname, _ := os.Hostname()
| </s> remove n, _, _, err := c.ReadFrom(b)
</s> add n, _, err := c.ReadFrom(b) </s> remove c, err := newBroadcastPacketConn(net.IPv4(0, 0, 0, 0), 68, ifaceName)
</s> add c, err := nclient4.NewRawUDPConn(ifaceName, 68) </s> remove cm := ipv4.ControlMessage{}
_, err = c.WriteTo(req.ToBytes(), &cm, dstAddr)
</s> add _, err = c.WriteTo(req.ToBytes(), dstAddr) </s> remove "golang.org/x/net/ipv4"
</s> add | if runtime.GOOS == "darwin" {
return false, fmt.Errorf("Can't find DHCP server: not supported on macOS")
}
| }
if runtime.GOOS == "darwin" {
return false, fmt.Errorf("Can't find DHCP server: not supported on macOS")
}
srcIP := ifaceIPNet[0]
src := net.JoinHostPort(srcIP.String(), "68")
dst := "255.255.255.255:67"
hostname, _ := os.Hostname() | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - dhcp: CheckIfOtherDHCPServersPresent: fix
Sometimes request from DHCP server couldn't be received
because we were bound to a specific IP address. | https://github.com/AdguardTeam/AdGuardHome/commit/23752377b76895dbcd78f25ed6df58e1bbcae153 | dhcpd/check_other_dhcp.go |
}
// bind to 0.0.0.0:68
log.Tracef("Listening to udp4 %+v", udpAddr)
c, err := newBroadcastPacketConn(net.IPv4(0, 0, 0, 0), 68, ifaceName)
if c != nil {
defer c.Close()
}
if err != nil {
return false, wrapErrPrint(err, "Couldn't listen on :68")
| </s> remove cm := ipv4.ControlMessage{}
_, err = c.WriteTo(req.ToBytes(), &cm, dstAddr)
</s> add _, err = c.WriteTo(req.ToBytes(), dstAddr) </s> remove n, _, _, err := c.ReadFrom(b)
</s> add n, _, err := c.ReadFrom(b) </s> remove "golang.org/x/net/ipv4"
</s> add | c, err := nclient4.NewRawUDPConn(ifaceName, 68) | }
// bind to 0.0.0.0:68
log.Tracef("Listening to udp4 %+v", udpAddr)
c, err := nclient4.NewRawUDPConn(ifaceName, 68)
if c != nil {
defer c.Close()
}
if err != nil {
return false, wrapErrPrint(err, "Couldn't listen on :68") | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - dhcp: CheckIfOtherDHCPServersPresent: fix
Sometimes request from DHCP server couldn't be received
because we were bound to a specific IP address. | https://github.com/AdguardTeam/AdGuardHome/commit/23752377b76895dbcd78f25ed6df58e1bbcae153 | dhcpd/check_other_dhcp.go |
return false, wrapErrPrint(err, "Couldn't listen on :68")
}
// send to 255.255.255.255:67
cm := ipv4.ControlMessage{}
_, err = c.WriteTo(req.ToBytes(), &cm, dstAddr)
if err != nil {
return false, wrapErrPrint(err, "Couldn't send a packet to %s", dst)
}
for {
| </s> remove c, err := newBroadcastPacketConn(net.IPv4(0, 0, 0, 0), 68, ifaceName)
</s> add c, err := nclient4.NewRawUDPConn(ifaceName, 68) </s> remove n, _, _, err := c.ReadFrom(b)
</s> add n, _, err := c.ReadFrom(b) </s> remove "golang.org/x/net/ipv4"
</s> add | _, err = c.WriteTo(req.ToBytes(), dstAddr) | return false, wrapErrPrint(err, "Couldn't listen on :68")
}
// send to 255.255.255.255:67
_, err = c.WriteTo(req.ToBytes(), dstAddr)
_, err = c.WriteTo(req.ToBytes(), dstAddr)
if err != nil {
return false, wrapErrPrint(err, "Couldn't send a packet to %s", dst)
}
for { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - dhcp: CheckIfOtherDHCPServersPresent: fix
Sometimes request from DHCP server couldn't be received
because we were bound to a specific IP address. | https://github.com/AdguardTeam/AdGuardHome/commit/23752377b76895dbcd78f25ed6df58e1bbcae153 | dhcpd/check_other_dhcp.go |
log.Tracef("Waiting %v for an answer", defaultDiscoverTime)
// TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts
b := make([]byte, 1500)
_ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime))
n, _, _, err := c.ReadFrom(b)
if isTimeout(err) {
// timed out -- no DHCP servers
return false, nil
}
if err != nil {
| </s> remove cm := ipv4.ControlMessage{}
_, err = c.WriteTo(req.ToBytes(), &cm, dstAddr)
</s> add _, err = c.WriteTo(req.ToBytes(), dstAddr) </s> remove c, err := newBroadcastPacketConn(net.IPv4(0, 0, 0, 0), 68, ifaceName)
</s> add c, err := nclient4.NewRawUDPConn(ifaceName, 68) </s> remove "golang.org/x/net/ipv4"
</s> add | n, _, err := c.ReadFrom(b) | log.Tracef("Waiting %v for an answer", defaultDiscoverTime)
// TODO: replicate dhclient's behaviour of retrying several times with progressively bigger timeouts
b := make([]byte, 1500)
_ = c.SetReadDeadline(time.Now().Add(defaultDiscoverTime))
n, _, err := c.ReadFrom(b)
if isTimeout(err) {
// timed out -- no DHCP servers
return false, nil
}
if err != nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - dhcp: CheckIfOtherDHCPServersPresent: fix
Sometimes request from DHCP server couldn't be received
because we were bound to a specific IP address. | https://github.com/AdguardTeam/AdGuardHome/commit/23752377b76895dbcd78f25ed6df58e1bbcae153 | dhcpd/check_other_dhcp.go |
n, _, err := c.ReadFrom(b)
if isTimeout(err) {
// timed out -- no DHCP servers
return false, nil
}
if err != nil {
return false, wrapErrPrint(err, "Couldn't receive packet")
}
| </s> remove n, _, _, err := c.ReadFrom(b)
</s> add n, _, err := c.ReadFrom(b) </s> remove cm := ipv4.ControlMessage{}
_, err = c.WriteTo(req.ToBytes(), &cm, dstAddr)
</s> add _, err = c.WriteTo(req.ToBytes(), dstAddr) </s> remove c, err := newBroadcastPacketConn(net.IPv4(0, 0, 0, 0), 68, ifaceName)
</s> add c, err := nclient4.NewRawUDPConn(ifaceName, 68) </s> remove "golang.org/x/net/ipv4"
</s> add | log.Debug("DHCPv4: didn't receive DHCP response") | n, _, err := c.ReadFrom(b)
if isTimeout(err) {
// timed out -- no DHCP servers
log.Debug("DHCPv4: didn't receive DHCP response")
return false, nil
}
if err != nil {
return false, wrapErrPrint(err, "Couldn't receive packet")
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - dhcp: CheckIfOtherDHCPServersPresent: fix
Sometimes request from DHCP server couldn't be received
because we were bound to a specific IP address. | https://github.com/AdguardTeam/AdGuardHome/commit/23752377b76895dbcd78f25ed6df58e1bbcae153 | dhcpd/check_other_dhcp.go |
)}
<LoadingBar className="loading-bar" updateTime={1000} />
<Route component={Header} />
<div className="container container--wrap">
{dashboard.processing && !dashboard.isCoreRunning && (
<div className="row row-cards">
<div className="col-lg-12">
<Status reloadPage={this.reloadPage}
message="dns_start"
/>
| </s> remove />
</s> add /> </s> remove isCoreRunning: false,
</s> add isCoreRunning: true, | {dashboard.processing && <Loading />}
{!dashboard.isCoreRunning && ( | )}
<LoadingBar className="loading-bar" updateTime={1000} />
<Route component={Header} />
<div className="container container--wrap">
{dashboard.processing && <Loading />}
{!dashboard.isCoreRunning && (
<div className="row row-cards">
<div className="col-lg-12">
<Status reloadPage={this.reloadPage}
message="dns_start"
/> | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - client: hide dns is starting message by default | https://github.com/AdguardTeam/AdGuardHome/commit/242e5e136f60c024c167b6fc096fa5595c5ba9bd | client/src/components/App/index.js |
<div className="row row-cards">
<div className="col-lg-12">
<Status reloadPage={this.reloadPage}
message="dns_start"
/>
<Loading />
</div>
</div>
)}
{!dashboard.processing && dashboard.isCoreRunning && (
| </s> remove {dashboard.processing && !dashboard.isCoreRunning && (
</s> add {dashboard.processing && <Loading />}
{!dashboard.isCoreRunning && ( </s> remove isCoreRunning: false,
</s> add isCoreRunning: true, | /> | <div className="row row-cards">
<div className="col-lg-12">
<Status reloadPage={this.reloadPage}
message="dns_start"
/>
<Loading />
</div>
</div>
)}
{!dashboard.processing && dashboard.isCoreRunning && ( | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - client: hide dns is starting message by default | https://github.com/AdguardTeam/AdGuardHome/commit/242e5e136f60c024c167b6fc096fa5595c5ba9bd | client/src/components/App/index.js |
}),
},
{
processing: true,
isCoreRunning: false,
processingVersion: true,
processingFiltering: true,
processingClients: true,
processingUpdate: false,
processingDnsSettings: true,
| </s> remove />
</s> add /> </s> remove {dashboard.processing && !dashboard.isCoreRunning && (
</s> add {dashboard.processing && <Loading />}
{!dashboard.isCoreRunning && ( | isCoreRunning: true, | }),
},
{
processing: true,
isCoreRunning: true,
processingVersion: true,
processingFiltering: true,
processingClients: true,
processingUpdate: false,
processingDnsSettings: true, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | - client: hide dns is starting message by default | https://github.com/AdguardTeam/AdGuardHome/commit/242e5e136f60c024c167b6fc096fa5595c5ba9bd | client/src/reducers/index.js |
Action: setup,
})
}
type cacheEntry struct {
answer []dns.RR
lastUpdated time.Time
}
var (
lookupCacheTime = time.Minute * 30
lookupCache = map[string]cacheEntry{}
)
type plugFilter struct {
ID int64
Path string
}
| </s> remove cacheentry := lookupCache[val]
if time.Since(cacheentry.lastUpdated) > lookupCacheTime {
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
}
records = result.Answer
cacheentry.answer = result.Answer
cacheentry.lastUpdated = time.Now()
lookupCache[val] = cacheentry
</s> add req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name </s> remove } else {
// get from cache
records = cacheentry.answer
</s> add records = result.Answer </s> remove _ "github.com/benburkert/dns/init"
</s> add | Action: setup,
})
}
type plugFilter struct {
ID int64
Path string
}
| [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Revert "Cache DNS lookups when resolving safebrowsing or parental servers, also cache replacement hostnames as well."
This reverts commit a5d105352057bf24a59a08a2695f1d48f033cb17.
This cache had unintended side effects. | https://github.com/AdguardTeam/AdGuardHome/commit/2449075bca9e12bf052a2d217e05a9196817d5bd | coredns_plugin/coredns_plugin.go |
|
}
records = append(records, result)
} else {
// this is a domain name, need to look it up
cacheentry := lookupCache[val]
if time.Since(cacheentry.lastUpdated) > lookupCacheTime {
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
}
records = result.Answer
cacheentry.answer = result.Answer
cacheentry.lastUpdated = time.Now()
lookupCache[val] = cacheentry
}
} else {
// get from cache
records = cacheentry.answer
}
| </s> remove } else {
// get from cache
records = cacheentry.answer
</s> add records = result.Answer </s> remove type cacheEntry struct {
answer []dns.RR
lastUpdated time.Time
}
var (
lookupCacheTime = time.Minute * 30
lookupCache = map[string]cacheEntry{}
)
</s> add </s> remove _ "github.com/benburkert/dns/init"
</s> add | req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name | }
records = append(records, result)
} else {
// this is a domain name, need to look it up
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
}
} else {
// get from cache
records = cacheentry.answer
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Revert "Cache DNS lookups when resolving safebrowsing or parental servers, also cache replacement hostnames as well."
This reverts commit a5d105352057bf24a59a08a2695f1d48f033cb17.
This cache had unintended side effects. | https://github.com/AdguardTeam/AdGuardHome/commit/2449075bca9e12bf052a2d217e05a9196817d5bd | coredns_plugin/coredns_plugin.go |
cacheentry.answer = result.Answer
cacheentry.lastUpdated = time.Now()
lookupCache[val] = cacheentry
}
} else {
// get from cache
records = cacheentry.answer
}
}
m := new(dns.Msg)
m.SetReply(r)
m.Authoritative, m.RecursionAvailable, m.Compress = true, true, true
| </s> remove cacheentry := lookupCache[val]
if time.Since(cacheentry.lastUpdated) > lookupCacheTime {
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
}
records = result.Answer
cacheentry.answer = result.Answer
cacheentry.lastUpdated = time.Now()
lookupCache[val] = cacheentry
</s> add req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name </s> remove type cacheEntry struct {
answer []dns.RR
lastUpdated time.Time
}
var (
lookupCacheTime = time.Minute * 30
lookupCache = map[string]cacheEntry{}
)
</s> add </s> remove _ "github.com/benburkert/dns/init"
</s> add | records = result.Answer | cacheentry.answer = result.Answer
cacheentry.lastUpdated = time.Now()
lookupCache[val] = cacheentry
}
records = result.Answer
records = result.Answer
records = result.Answer
}
}
m := new(dns.Msg)
m.SetReply(r)
m.Authoritative, m.RecursionAvailable, m.Compress = true, true, true | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Revert "Cache DNS lookups when resolving safebrowsing or parental servers, also cache replacement hostnames as well."
This reverts commit a5d105352057bf24a59a08a2695f1d48f033cb17.
This cache had unintended side effects. | https://github.com/AdguardTeam/AdGuardHome/commit/2449075bca9e12bf052a2d217e05a9196817d5bd | coredns_plugin/coredns_plugin.go |
"sync"
"sync/atomic"
"time"
_ "github.com/benburkert/dns/init"
"github.com/bluele/gcache"
"golang.org/x/net/publicsuffix"
)
const defaultCacheSize = 64 * 1024 // in number of elements
| </s> remove } else {
// get from cache
records = cacheentry.answer
</s> add records = result.Answer </s> remove cacheentry := lookupCache[val]
if time.Since(cacheentry.lastUpdated) > lookupCacheTime {
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name
}
records = result.Answer
cacheentry.answer = result.Answer
cacheentry.lastUpdated = time.Now()
lookupCache[val] = cacheentry
</s> add req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(val), question.Qtype)
req.RecursionDesired = true
reqstate := request.Request{W: w, Req: req, Context: ctx}
result, err := p.upstream.Lookup(reqstate, dns.Fqdn(val), reqstate.QType())
if err != nil {
log.Printf("Got error %s\n", err)
return dns.RcodeServerFailure, fmt.Errorf("plugin/dnsfilter: %s", err)
}
if result != nil {
for _, answer := range result.Answer {
answer.Header().Name = question.Name </s> remove type cacheEntry struct {
answer []dns.RR
lastUpdated time.Time
}
var (
lookupCacheTime = time.Minute * 30
lookupCache = map[string]cacheEntry{}
)
</s> add | "sync"
"sync/atomic"
"time"
"github.com/bluele/gcache"
"golang.org/x/net/publicsuffix"
)
const defaultCacheSize = 64 * 1024 // in number of elements | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Revert "Cache DNS lookups when resolving safebrowsing or parental servers, also cache replacement hostnames as well."
This reverts commit a5d105352057bf24a59a08a2695f1d48f033cb17.
This cache had unintended side effects. | https://github.com/AdguardTeam/AdGuardHome/commit/2449075bca9e12bf052a2d217e05a9196817d5bd | dnsfilter/dnsfilter.go |
|
var (
stats Stats
safebrowsingCache gcache.Cache
parentalCache gcache.Cache
safeSearchCache gcache.Cache
)
| </s> remove d.transport.DialContext = createCustomDialContext(c.ResolverAddress)
</s> add securityCache = gcache.New(2).LRU().Expiration(defaultCacheTime).Build()
d.transport.DialContext = d.createCustomDialContext(c.ResolverAddress) </s> remove func createCustomDialContext(resolverAddr string) dialFunctionType {
</s> add func (d *Dnsfilter) createCustomDialContext(resolverAddr string) dialFunctionType { | securityCache gcache.Cache // "host" -> "IP" cache for safebrowsing and parental control servers | var (
stats Stats
securityCache gcache.Cache // "host" -> "IP" cache for safebrowsing and parental control servers
safebrowsingCache gcache.Cache
parentalCache gcache.Cache
safeSearchCache gcache.Cache
) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | + dnsfilter: cache IP addresses of safebrowsing and parental control servers | https://github.com/AdguardTeam/AdGuardHome/commit/24ae61de3ed99a7b21dd6d4598e296df0b3e952d | dnsfilter/dnsfilter.go |
type dialFunctionType func(ctx context.Context, network, addr string) (net.Conn, error)
// Connect to a remote server resolving hostname using our own DNS server
func createCustomDialContext(resolverAddr string) dialFunctionType {
return func(ctx context.Context, network, addr string) (net.Conn, error) {
log.Tracef("network:%v addr:%v", network, addr)
host, port, err := net.SplitHostPort(addr)
if err != nil {
| </s> remove d.transport.DialContext = createCustomDialContext(c.ResolverAddress)
</s> add securityCache = gcache.New(2).LRU().Expiration(defaultCacheTime).Build()
d.transport.DialContext = d.createCustomDialContext(c.ResolverAddress) | func (d *Dnsfilter) createCustomDialContext(resolverAddr string) dialFunctionType { |
type dialFunctionType func(ctx context.Context, network, addr string) (net.Conn, error)
// Connect to a remote server resolving hostname using our own DNS server
func (d *Dnsfilter) createCustomDialContext(resolverAddr string) dialFunctionType {
return func(ctx context.Context, network, addr string) (net.Conn, error) {
log.Tracef("network:%v addr:%v", network, addr)
host, port, err := net.SplitHostPort(addr)
if err != nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + dnsfilter: cache IP addresses of safebrowsing and parental control servers | https://github.com/AdguardTeam/AdGuardHome/commit/24ae61de3ed99a7b21dd6d4598e296df0b3e952d | dnsfilter/dnsfilter.go |
return con, err
}
r := upstream.NewResolver(resolverAddr, 30*time.Second)
addrs, e := r.LookupIPAddr(ctx, host)
log.Tracef("LookupIPAddr: %s: %v", host, addrs)
if e != nil {
return nil, e
}
| </s> remove func createCustomDialContext(resolverAddr string) dialFunctionType {
</s> add func (d *Dnsfilter) createCustomDialContext(resolverAddr string) dialFunctionType { </s> remove d.transport.DialContext = createCustomDialContext(c.ResolverAddress)
</s> add securityCache = gcache.New(2).LRU().Expiration(defaultCacheTime).Build()
d.transport.DialContext = d.createCustomDialContext(c.ResolverAddress) | cache := d.shouldCache(host)
if cache {
ip := searchInCache(host)
if len(ip) != 0 {
addr = fmt.Sprintf("%s:%s", ip, port)
return dialer.DialContext(ctx, network, addr)
}
}
| return con, err
}
cache := d.shouldCache(host)
if cache {
ip := searchInCache(host)
if len(ip) != 0 {
addr = fmt.Sprintf("%s:%s", ip, port)
return dialer.DialContext(ctx, network, addr)
}
}
r := upstream.NewResolver(resolverAddr, 30*time.Second)
addrs, e := r.LookupIPAddr(ctx, host)
log.Tracef("LookupIPAddr: %s: %v", host, addrs)
if e != nil {
return nil, e
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + dnsfilter: cache IP addresses of safebrowsing and parental control servers | https://github.com/AdguardTeam/AdGuardHome/commit/24ae61de3ed99a7b21dd6d4598e296df0b3e952d | dnsfilter/dnsfilter.go |
}
continue
}
return con, err
}
return nil, firstErr
}
}
| </s> remove d.transport.DialContext = createCustomDialContext(c.ResolverAddress)
</s> add securityCache = gcache.New(2).LRU().Expiration(defaultCacheTime).Build()
d.transport.DialContext = d.createCustomDialContext(c.ResolverAddress) </s> remove func createCustomDialContext(resolverAddr string) dialFunctionType {
</s> add func (d *Dnsfilter) createCustomDialContext(resolverAddr string) dialFunctionType { | if cache {
addToCache(host, a.String())
}
| }
continue
}
if cache {
addToCache(host, a.String())
}
return con, err
}
return nil, firstErr
}
} | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + dnsfilter: cache IP addresses of safebrowsing and parental control servers | https://github.com/AdguardTeam/AdGuardHome/commit/24ae61de3ed99a7b21dd6d4598e296df0b3e952d | dnsfilter/dnsfilter.go |
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
if c != nil && len(c.ResolverAddress) != 0 {
d.transport.DialContext = createCustomDialContext(c.ResolverAddress)
}
d.client = http.Client{
Transport: d.transport,
Timeout: defaultHTTPTimeout,
}
| </s> remove func createCustomDialContext(resolverAddr string) dialFunctionType {
</s> add func (d *Dnsfilter) createCustomDialContext(resolverAddr string) dialFunctionType { | securityCache = gcache.New(2).LRU().Expiration(defaultCacheTime).Build()
d.transport.DialContext = d.createCustomDialContext(c.ResolverAddress) | TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
if c != nil && len(c.ResolverAddress) != 0 {
securityCache = gcache.New(2).LRU().Expiration(defaultCacheTime).Build()
d.transport.DialContext = d.createCustomDialContext(c.ResolverAddress)
}
d.client = http.Client{
Transport: d.transport,
Timeout: defaultHTTPTimeout,
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + dnsfilter: cache IP addresses of safebrowsing and parental control servers | https://github.com/AdguardTeam/AdGuardHome/commit/24ae61de3ed99a7b21dd6d4598e296df0b3e952d | dnsfilter/dnsfilter.go |
case "$channel"
in
('release')
snapchannel='candidate'
;;
('beta')
snapchannel='beta'
;;
('edge')
snapchannel='edge'
| </s> remove snapchannel='beta'
;;
</s> add snapchannel='beta'
;; </s> remove snapchannel='edge'
;;
</s> add snapchannel='edge'
;; </s> remove echo "invalid channel '$channel'"
exit 1
;;
</s> add echo "invalid channel '$channel'"
exit 1
;; </s> remove exit 0
</s> add exit 0 </s> remove echo "don't publish to GitHub Releases for this channel"
</s> add echo "don't publish to GitHub Releases for this channel" | snapchannel='candidate'
;; |
case "$channel"
in
('release')
snapchannel='candidate'
;;
snapchannel='candidate'
;;
('beta')
snapchannel='beta'
;;
('edge')
snapchannel='edge' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1848: fix-snap
Merge in DNS/adguard-home from fix-snap to master
Squashed commit of the following:
commit 4a12b2709229150e1b896b71b2b0a99249f94fde
Author: Ainar Garipov <[email protected]>
Date: Sat May 20 11:51:25 2023 +0300
bamboo-specs: upd snap script | https://github.com/AdguardTeam/AdGuardHome/commit/24b41100c3337822acaf5c118854a66267c5ea81 | bamboo-specs/release.yaml |
('release')
snapchannel='candidate'
;;
('beta')
snapchannel='beta'
;;
('edge')
snapchannel='edge'
;;
(*)
echo "invalid channel '$channel'"
| </s> remove snapchannel='candidate'
;;
</s> add snapchannel='candidate'
;; </s> remove snapchannel='edge'
;;
</s> add snapchannel='edge'
;; </s> remove echo "invalid channel '$channel'"
exit 1
;;
</s> add echo "invalid channel '$channel'"
exit 1
;; </s> remove echo "don't publish to GitHub Releases for this channel"
</s> add echo "don't publish to GitHub Releases for this channel" </s> remove exit 0
</s> add exit 0 | snapchannel='beta'
;; | ('release')
snapchannel='candidate'
;;
('beta')
snapchannel='beta'
;;
snapchannel='beta'
;;
('edge')
snapchannel='edge'
;;
(*)
echo "invalid channel '$channel'" | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1848: fix-snap
Merge in DNS/adguard-home from fix-snap to master
Squashed commit of the following:
commit 4a12b2709229150e1b896b71b2b0a99249f94fde
Author: Ainar Garipov <[email protected]>
Date: Sat May 20 11:51:25 2023 +0300
bamboo-specs: upd snap script | https://github.com/AdguardTeam/AdGuardHome/commit/24b41100c3337822acaf5c118854a66267c5ea81 | bamboo-specs/release.yaml |
('beta')
snapchannel='beta'
;;
('edge')
snapchannel='edge'
;;
(*)
echo "invalid channel '$channel'"
exit 1
;;
esac
| </s> remove echo "invalid channel '$channel'"
exit 1
;;
</s> add echo "invalid channel '$channel'"
exit 1
;; </s> remove snapchannel='beta'
;;
</s> add snapchannel='beta'
;; </s> remove snapchannel='candidate'
;;
</s> add snapchannel='candidate'
;; </s> remove echo "don't publish to GitHub Releases for this channel"
</s> add echo "don't publish to GitHub Releases for this channel" </s> remove exit 0
</s> add exit 0 | snapchannel='edge'
;; | ('beta')
snapchannel='beta'
;;
('edge')
snapchannel='edge'
;;
snapchannel='edge'
;;
(*)
echo "invalid channel '$channel'"
exit 1
;;
esac | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1848: fix-snap
Merge in DNS/adguard-home from fix-snap to master
Squashed commit of the following:
commit 4a12b2709229150e1b896b71b2b0a99249f94fde
Author: Ainar Garipov <[email protected]>
Date: Sat May 20 11:51:25 2023 +0300
bamboo-specs: upd snap script | https://github.com/AdguardTeam/AdGuardHome/commit/24b41100c3337822acaf5c118854a66267c5ea81 | bamboo-specs/release.yaml |
('edge')
snapchannel='edge'
;;
(*)
echo "invalid channel '$channel'"
exit 1
;;
esac
env\
SNAPCRAFT_CHANNEL="$snapchannel"\
SNAPCRAFT_EMAIL="${bamboo.snapcraftEmail}"\
| </s> remove snapchannel='edge'
;;
</s> add snapchannel='edge'
;; </s> remove snapchannel='beta'
;;
</s> add snapchannel='beta'
;; </s> remove SNAPCRAFT_MACAROON="${bamboo.snapcraftMacaroonPassword}"\
SNAPCRAFT_UBUNTU_DISCHARGE="${bamboo.snapcraftUbuntuDischargePassword}"\
</s> add SNAPCRAFT_STORE_CREDENTIALS="${bamboo.snapcraftMacaroonPassword}"\ </s> remove snapchannel='candidate'
;;
</s> add snapchannel='candidate'
;; </s> remove exit 0
</s> add exit 0 | echo "invalid channel '$channel'"
exit 1
;; | ('edge')
snapchannel='edge'
;;
(*)
echo "invalid channel '$channel'"
exit 1
;;
echo "invalid channel '$channel'"
exit 1
;;
echo "invalid channel '$channel'"
exit 1
;;
esac
env\
SNAPCRAFT_CHANNEL="$snapchannel"\
SNAPCRAFT_EMAIL="${bamboo.snapcraftEmail}"\ | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1848: fix-snap
Merge in DNS/adguard-home from fix-snap to master
Squashed commit of the following:
commit 4a12b2709229150e1b896b71b2b0a99249f94fde
Author: Ainar Garipov <[email protected]>
Date: Sat May 20 11:51:25 2023 +0300
bamboo-specs: upd snap script | https://github.com/AdguardTeam/AdGuardHome/commit/24b41100c3337822acaf5c118854a66267c5ea81 | bamboo-specs/release.yaml |
env\
SNAPCRAFT_CHANNEL="$snapchannel"\
SNAPCRAFT_EMAIL="${bamboo.snapcraftEmail}"\
SNAPCRAFT_MACAROON="${bamboo.snapcraftMacaroonPassword}"\
SNAPCRAFT_UBUNTU_DISCHARGE="${bamboo.snapcraftUbuntuDischargePassword}"\
../bamboo-deploy-publisher/deploy.sh adguard-home-snap
'final-tasks':
- 'clean'
'requirements':
- 'adg-docker': 'true'
| </s> remove echo "invalid channel '$channel'"
exit 1
;;
</s> add echo "invalid channel '$channel'"
exit 1
;; </s> remove exit 0
</s> add exit 0 </s> remove echo "don't publish to GitHub Releases for this channel"
</s> add echo "don't publish to GitHub Releases for this channel" </s> remove snapchannel='edge'
;;
</s> add snapchannel='edge'
;; </s> remove snapchannel='beta'
;;
</s> add snapchannel='beta'
;; | SNAPCRAFT_STORE_CREDENTIALS="${bamboo.snapcraftMacaroonPassword}"\ |
env\
SNAPCRAFT_CHANNEL="$snapchannel"\
SNAPCRAFT_EMAIL="${bamboo.snapcraftEmail}"\
SNAPCRAFT_STORE_CREDENTIALS="${bamboo.snapcraftMacaroonPassword}"\
SNAPCRAFT_STORE_CREDENTIALS="${bamboo.snapcraftMacaroonPassword}"\
../bamboo-deploy-publisher/deploy.sh adguard-home-snap
'final-tasks':
- 'clean'
'requirements':
- 'adg-docker': 'true' | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1848: fix-snap
Merge in DNS/adguard-home from fix-snap to master
Squashed commit of the following:
commit 4a12b2709229150e1b896b71b2b0a99249f94fde
Author: Ainar Garipov <[email protected]>
Date: Sat May 20 11:51:25 2023 +0300
bamboo-specs: upd snap script | https://github.com/AdguardTeam/AdGuardHome/commit/24b41100c3337822acaf5c118854a66267c5ea81 | bamboo-specs/release.yaml |
readonly channel
if [ "$channel" != 'release' ] && [ "${channel}" != 'beta' ]
then
echo "don't publish to GitHub Releases for this channel"
exit 0
fi
cd ./dist/
| </s> remove exit 0
</s> add exit 0 </s> remove echo "invalid channel '$channel'"
exit 1
;;
</s> add echo "invalid channel '$channel'"
exit 1
;; </s> remove snapchannel='edge'
;;
</s> add snapchannel='edge'
;; </s> remove snapchannel='beta'
;;
</s> add snapchannel='beta'
;; </s> remove snapchannel='candidate'
;;
</s> add snapchannel='candidate'
;; | echo "don't publish to GitHub Releases for this channel" | readonly channel
if [ "$channel" != 'release' ] && [ "${channel}" != 'beta' ]
then
echo "don't publish to GitHub Releases for this channel"
exit 0
fi
cd ./dist/ | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1848: fix-snap
Merge in DNS/adguard-home from fix-snap to master
Squashed commit of the following:
commit 4a12b2709229150e1b896b71b2b0a99249f94fde
Author: Ainar Garipov <[email protected]>
Date: Sat May 20 11:51:25 2023 +0300
bamboo-specs: upd snap script | https://github.com/AdguardTeam/AdGuardHome/commit/24b41100c3337822acaf5c118854a66267c5ea81 | bamboo-specs/release.yaml |
if [ "$channel" != 'release' ] && [ "${channel}" != 'beta' ]
then
echo "don't publish to GitHub Releases for this channel"
exit 0
fi
cd ./dist/
env\
| </s> remove echo "don't publish to GitHub Releases for this channel"
</s> add echo "don't publish to GitHub Releases for this channel" </s> remove echo "invalid channel '$channel'"
exit 1
;;
</s> add echo "invalid channel '$channel'"
exit 1
;; </s> remove snapchannel='edge'
;;
</s> add snapchannel='edge'
;; </s> remove snapchannel='candidate'
;;
</s> add snapchannel='candidate'
;; </s> remove SNAPCRAFT_MACAROON="${bamboo.snapcraftMacaroonPassword}"\
SNAPCRAFT_UBUNTU_DISCHARGE="${bamboo.snapcraftUbuntuDischargePassword}"\
</s> add SNAPCRAFT_STORE_CREDENTIALS="${bamboo.snapcraftMacaroonPassword}"\ | exit 0 | if [ "$channel" != 'release' ] && [ "${channel}" != 'beta' ]
then
echo "don't publish to GitHub Releases for this channel"
exit 0
fi
cd ./dist/
env\ | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | Pull request 1848: fix-snap
Merge in DNS/adguard-home from fix-snap to master
Squashed commit of the following:
commit 4a12b2709229150e1b896b71b2b0a99249f94fde
Author: Ainar Garipov <[email protected]>
Date: Sat May 20 11:51:25 2023 +0300
bamboo-specs: upd snap script | https://github.com/AdguardTeam/AdGuardHome/commit/24b41100c3337822acaf5c118854a66267c5ea81 | bamboo-specs/release.yaml |
type TLSConfig struct {
TLSListenAddr *net.TCPAddr `yaml:"-" json:"-"`
CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain
PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key
}
// ServerConfig represents server configuration.
// The zero ServerConfig is empty and ready for use.
| </s> remove config.TLS.PrivateKey == "" ||
config.TLS.CertificateChain == "" { // sleep until necessary data is supplied
</s> add len(config.TLS.PrivateKeyData) == 0 ||
len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied </s> remove certchain := make([]byte, len(config.TLS.CertificateChain))
copy(certchain, []byte(config.TLS.CertificateChain))
privatekey := make([]byte, len(config.TLS.PrivateKey))
copy(privatekey, []byte(config.TLS.PrivateKey))
</s> add certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData) </s> remove TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChain: string(certPem),
PrivateKey: string(keyPem),
</s> add TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChainData: certPem,
PrivateKeyData: keyPem, </s> remove data := validateCertificates(config.TLS.CertificateChain, config.TLS.PrivateKey, config.TLS.ServerName)
</s> add data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) | CertificatePath string `yaml:"certificate_path" json:"certificate_path"` // certificate file name
PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` // private key file name
CertificateChainData []byte `yaml:"-" json:"-"`
PrivateKeyData []byte `yaml:"-" json:"-"` | type TLSConfig struct {
TLSListenAddr *net.TCPAddr `yaml:"-" json:"-"`
CertificateChain string `yaml:"certificate_chain" json:"certificate_chain"` // PEM-encoded certificates chain
PrivateKey string `yaml:"private_key" json:"private_key"` // PEM-encoded private key
CertificatePath string `yaml:"certificate_path" json:"certificate_path"` // certificate file name
PrivateKeyPath string `yaml:"private_key_path" json:"private_key_path"` // private key file name
CertificateChainData []byte `yaml:"-" json:"-"`
PrivateKeyData []byte `yaml:"-" json:"-"`
}
// ServerConfig represents server configuration.
// The zero ServerConfig is empty and ready for use. | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | dnsforward/dnsforward.go |
}
convertArrayToMap(&s.BlockedHosts, s.conf.BlockedHosts)
if s.conf.TLSListenAddr != nil && s.conf.CertificateChain != "" && s.conf.PrivateKey != "" {
proxyConfig.TLSListenAddr = s.conf.TLSListenAddr
keypair, err := tls.X509KeyPair([]byte(s.conf.CertificateChain), []byte(s.conf.PrivateKey))
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
| </s> remove keypair, err := tls.X509KeyPair([]byte(s.conf.CertificateChain), []byte(s.conf.PrivateKey))
</s> add keypair, err := tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData) </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
| if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 { | }
convertArrayToMap(&s.BlockedHosts, s.conf.BlockedHosts)
if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 {
proxyConfig.TLSListenAddr = s.conf.TLSListenAddr
keypair, err := tls.X509KeyPair([]byte(s.conf.CertificateChain), []byte(s.conf.PrivateKey))
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | dnsforward/dnsforward.go |
convertArrayToMap(&s.BlockedHosts, s.conf.BlockedHosts)
if s.conf.TLSListenAddr != nil && s.conf.CertificateChain != "" && s.conf.PrivateKey != "" {
proxyConfig.TLSListenAddr = s.conf.TLSListenAddr
keypair, err := tls.X509KeyPair([]byte(s.conf.CertificateChain), []byte(s.conf.PrivateKey))
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
proxyConfig.TLSConfig = &tls.Config{
Certificates: []tls.Certificate{keypair},
| </s> remove if s.conf.TLSListenAddr != nil && s.conf.CertificateChain != "" && s.conf.PrivateKey != "" {
</s> add if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 { </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
| keypair, err := tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData) | convertArrayToMap(&s.BlockedHosts, s.conf.BlockedHosts)
if s.conf.TLSListenAddr != nil && s.conf.CertificateChain != "" && s.conf.PrivateKey != "" {
proxyConfig.TLSListenAddr = s.conf.TLSListenAddr
keypair, err := tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return errorx.Decorate(err, "Failed to parse TLS keypair")
}
proxyConfig.TLSConfig = &tls.Config{
Certificates: []tls.Certificate{keypair}, | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | dnsforward/dnsforward.go |
s := createTestServer(t)
defer removeDataDir(t)
s.conf.TLSConfig = TLSConfig{
TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChain: string(certPem),
PrivateKey: string(keyPem),
}
// Starting the server
err := s.Start(nil)
if err != nil {
| </s> remove certchain := make([]byte, len(config.TLS.CertificateChain))
copy(certchain, []byte(config.TLS.CertificateChain))
privatekey := make([]byte, len(config.TLS.PrivateKey))
copy(privatekey, []byte(config.TLS.PrivateKey))
</s> add certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData) </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
</s> remove keypair, err := tls.X509KeyPair([]byte(s.conf.CertificateChain), []byte(s.conf.PrivateKey))
</s> add keypair, err := tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData) | TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChainData: certPem,
PrivateKeyData: keyPem, | s := createTestServer(t)
defer removeDataDir(t)
s.conf.TLSConfig = TLSConfig{
TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChainData: certPem,
PrivateKeyData: keyPem,
TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChainData: certPem,
PrivateKeyData: keyPem,
TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChainData: certPem,
PrivateKeyData: keyPem,
}
// Starting the server
err := s.Start(nil)
if err != nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | dnsforward/dnsforward_test.go |
config.Clients = nil
// Deduplicate filters
deduplicateFilters()
updateUniqueFilterID(config.Filters)
| </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
</s> remove TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChain: string(certPem),
PrivateKey: string(keyPem),
</s> add TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChainData: certPem,
PrivateKeyData: keyPem, </s> remove keypair, err := tls.X509KeyPair([]byte(s.conf.CertificateChain), []byte(s.conf.PrivateKey))
</s> add keypair, err := tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData) | status := tlsConfigStatus{}
if !tlsLoadConfig(&config.TLS, &status) {
log.Error("%s", status.WarningValidation)
return err
}
| config.Clients = nil
status := tlsConfigStatus{}
if !tlsLoadConfig(&config.TLS, &status) {
log.Error("%s", status.WarningValidation)
return err
}
// Deduplicate filters
deduplicateFilters()
updateUniqueFilterID(config.Filters)
| [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/config.go |
"errors"
"fmt"
"net/http"
"reflect"
"strings"
"time"
"github.com/AdguardTeam/golibs/log"
| </s> remove certchain := make([]byte, len(config.TLS.CertificateChain))
copy(certchain, []byte(config.TLS.CertificateChain))
privatekey := make([]byte, len(config.TLS.PrivateKey))
copy(privatekey, []byte(config.TLS.PrivateKey))
</s> add certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData) </s> remove data := validateCertificates(config.TLS.CertificateChain, config.TLS.PrivateKey, config.TLS.ServerName)
</s> add data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) </s> remove config.TLS.PrivateKey == "" ||
config.TLS.CertificateChain == "" { // sleep until necessary data is supplied
</s> add len(config.TLS.PrivateKeyData) == 0 ||
len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied | "io/ioutil" | "errors"
"fmt"
"io/ioutil"
"net/http"
"reflect"
"strings"
"time"
"github.com/AdguardTeam/golibs/log" | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/control_tls.go |
return
}
}
data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
marshalTLS(w, data)
}
func handleTLSConfigure(w http.ResponseWriter, r *http.Request) {
data, err := unmarshalTLS(r)
| </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add | status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
| return
}
}
status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
marshalTLS(w, data)
}
func handleTLSConfigure(w http.ResponseWriter, r *http.Request) {
data, err := unmarshalTLS(r) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/control_tls.go |
}
restartHTTPS := false
if !reflect.DeepEqual(config.TLS.tlsConfigSettings, data.tlsConfigSettings) {
log.Printf("tls config settings have changed, will restart HTTPS server")
restartHTTPS = true
}
| </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add </s> remove certchain := make([]byte, len(config.TLS.CertificateChain))
copy(certchain, []byte(config.TLS.CertificateChain))
privatekey := make([]byte, len(config.TLS.PrivateKey))
copy(privatekey, []byte(config.TLS.PrivateKey))
</s> add certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData) </s> remove data := validateCertificates(config.TLS.CertificateChain, config.TLS.PrivateKey, config.TLS.ServerName)
</s> add data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
| status := tlsConfigStatus{}
if !tlsLoadConfig(&data, &status) {
data.tlsConfigStatus = status
marshalTLS(w, data)
return
}
data.tlsConfigStatus = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName) | }
status := tlsConfigStatus{}
if !tlsLoadConfig(&data, &status) {
data.tlsConfigStatus = status
marshalTLS(w, data)
return
}
data.tlsConfigStatus = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
restartHTTPS := false
if !reflect.DeepEqual(config.TLS.tlsConfigSettings, data.tlsConfigSettings) {
log.Printf("tls config settings have changed, will restart HTTPS server")
restartHTTPS = true
} | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/control_tls.go |
}
}
restartHTTPS := false
data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
if !reflect.DeepEqual(config.TLS.tlsConfigSettings, data.tlsConfigSettings) {
log.Printf("tls config settings have changed, will restart HTTPS server")
restartHTTPS = true
}
config.TLS = data
| </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
</s> remove certchain := make([]byte, len(config.TLS.CertificateChain))
copy(certchain, []byte(config.TLS.CertificateChain))
privatekey := make([]byte, len(config.TLS.PrivateKey))
copy(privatekey, []byte(config.TLS.PrivateKey))
</s> add certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData) | }
}
restartHTTPS := false
if !reflect.DeepEqual(config.TLS.tlsConfigSettings, data.tlsConfigSettings) {
log.Printf("tls config settings have changed, will restart HTTPS server")
restartHTTPS = true
}
config.TLS = data | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/control_tls.go |
|
}
data.CertificateChain = string(certPEM)
}
if data.PrivateKey != "" {
keyPEM, err := base64.StdEncoding.DecodeString(data.PrivateKey)
if err != nil {
| </s> remove if s.conf.TLSListenAddr != nil && s.conf.CertificateChain != "" && s.conf.PrivateKey != "" {
</s> add if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 { </s> remove keypair, err := tls.X509KeyPair([]byte(s.conf.CertificateChain), []byte(s.conf.PrivateKey))
</s> add keypair, err := tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData) </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
| if data.CertificatePath != "" {
return data, fmt.Errorf("certificate data and file can't be set together")
} | }
data.CertificateChain = string(certPEM)
if data.CertificatePath != "" {
return data, fmt.Errorf("certificate data and file can't be set together")
}
}
if data.PrivateKey != "" {
keyPEM, err := base64.StdEncoding.DecodeString(data.PrivateKey)
if err != nil { | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/control_tls.go |
data.PrivateKey = string(keyPEM)
}
return data, nil
}
| </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add status := tlsConfigStatus{}
if tlsLoadConfig(&data, &status) {
status = validateCertificates(string(data.CertificateChainData), string(data.PrivateKeyData), data.ServerName)
}
data.tlsConfigStatus = status
</s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add | if data.PrivateKeyPath != "" {
return data, fmt.Errorf("private key data and file can't be set together")
} |
data.PrivateKey = string(keyPEM)
if data.PrivateKeyPath != "" {
return data, fmt.Errorf("private key data and file can't be set together")
}
}
return data, nil
} | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/control_tls.go |
config.httpsServer.cond.L.Lock()
// this mechanism doesn't let us through until all conditions are met
for config.TLS.Enabled == false ||
config.TLS.PortHTTPS == 0 ||
config.TLS.PrivateKey == "" ||
config.TLS.CertificateChain == "" { // sleep until necessary data is supplied
config.httpsServer.cond.Wait()
}
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS))
// validate current TLS config and update warnings (it could have been loaded from file)
data := validateCertificates(config.TLS.CertificateChain, config.TLS.PrivateKey, config.TLS.ServerName)
| </s> remove data := validateCertificates(config.TLS.CertificateChain, config.TLS.PrivateKey, config.TLS.ServerName)
</s> add data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add </s> remove if s.conf.TLSListenAddr != nil && s.conf.CertificateChain != "" && s.conf.PrivateKey != "" {
</s> add if s.conf.TLSListenAddr != nil && len(s.conf.CertificateChainData) != 0 && len(s.conf.PrivateKeyData) != 0 { | len(config.TLS.PrivateKeyData) == 0 ||
len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied | config.httpsServer.cond.L.Lock()
// this mechanism doesn't let us through until all conditions are met
for config.TLS.Enabled == false ||
config.TLS.PortHTTPS == 0 ||
len(config.TLS.PrivateKeyData) == 0 ||
len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied
len(config.TLS.PrivateKeyData) == 0 ||
len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied
config.httpsServer.cond.Wait()
}
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS))
// validate current TLS config and update warnings (it could have been loaded from file)
data := validateCertificates(config.TLS.CertificateChain, config.TLS.PrivateKey, config.TLS.ServerName) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/home.go |
config.httpsServer.cond.Wait()
}
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS))
// validate current TLS config and update warnings (it could have been loaded from file)
data := validateCertificates(config.TLS.CertificateChain, config.TLS.PrivateKey, config.TLS.ServerName)
if !data.ValidPair {
cleanupAlways()
log.Fatal(data.WarningValidation)
}
config.Lock()
| </s> remove config.TLS.PrivateKey == "" ||
config.TLS.CertificateChain == "" { // sleep until necessary data is supplied
</s> add len(config.TLS.PrivateKeyData) == 0 ||
len(config.TLS.CertificateChainData) == 0 { // sleep until necessary data is supplied </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add </s> remove certchain := make([]byte, len(config.TLS.CertificateChain))
copy(certchain, []byte(config.TLS.CertificateChain))
privatekey := make([]byte, len(config.TLS.PrivateKey))
copy(privatekey, []byte(config.TLS.PrivateKey))
</s> add certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData) | data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) | config.httpsServer.cond.Wait()
}
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.TLS.PortHTTPS))
// validate current TLS config and update warnings (it could have been loaded from file)
data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName)
if !data.ValidPair {
cleanupAlways()
log.Fatal(data.WarningValidation)
}
config.Lock() | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/home.go |
config.Unlock()
// prepare certs for HTTPS server
// important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests
certchain := make([]byte, len(config.TLS.CertificateChain))
copy(certchain, []byte(config.TLS.CertificateChain))
privatekey := make([]byte, len(config.TLS.PrivateKey))
copy(privatekey, []byte(config.TLS.PrivateKey))
cert, err := tls.X509KeyPair(certchain, privatekey)
if err != nil {
cleanupAlways()
log.Fatal(err)
}
| </s> remove data.tlsConfigStatus = validateCertificates(data.CertificateChain, data.PrivateKey, data.ServerName)
</s> add </s> remove TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChain: string(certPem),
PrivateKey: string(keyPem),
</s> add TLSListenAddr: &net.TCPAddr{Port: 0},
CertificateChainData: certPem,
PrivateKeyData: keyPem, </s> remove data := validateCertificates(config.TLS.CertificateChain, config.TLS.PrivateKey, config.TLS.ServerName)
</s> add data := validateCertificates(string(config.TLS.CertificateChainData), string(config.TLS.PrivateKeyData), config.TLS.ServerName) | certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData) | config.Unlock()
// prepare certs for HTTPS server
// important -- they have to be copies, otherwise changing the contents in config.TLS will break encryption for in-flight requests
certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData)
certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData)
certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData)
certchain := make([]byte, len(config.TLS.CertificateChainData))
copy(certchain, config.TLS.CertificateChainData)
privatekey := make([]byte, len(config.TLS.PrivateKeyData))
copy(privatekey, config.TLS.PrivateKeyData)
cert, err := tls.X509KeyPair(certchain, privatekey)
if err != nil {
cleanupAlways()
log.Fatal(err)
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | + config: add certificate_path, private_key_path
* POST /control/tls/configure: support certificate_path and private_key_path | https://github.com/AdguardTeam/AdGuardHome/commit/24bb708b21e158712e4c67ceca2816defd44ca88 | home/home.go |
}()
}
}
// Return 0 on success
func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int {
log.Tracef("got certificate: %s", certChain)
// now do a more extended validation
var certs []*pem.Block // PEM-encoded certificates
var skippedBytes []string // skipped bytes
| </s> remove // Return 0 on success
func validatePkey(data *tlsConfigStatus, pkey string) int {
</s> add func validatePkey(data *tlsConfigStatus, pkey string) error { </s> remove return 0
</s> add return nil </s> remove if verifyCertChain(&data, certChain, serverName) != 0 {
</s> add if verifyCertChain(&data, certChain, serverName) != nil { </s> remove return 1
</s> add return errors.New("") </s> remove if validatePkey(&data, pkey) != 0 {
</s> add if validatePkey(&data, pkey) != nil { | func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) error { | }()
}
}
func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) error {
func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) error {
log.Tracef("got certificate: %s", certChain)
// now do a more extended validation
var certs []*pem.Block // PEM-encoded certificates
var skippedBytes []string // skipped bytes | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
for _, cert := range certs {
parsed, err := x509.ParseCertificate(cert.Bytes)
if err != nil {
data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err)
return 1
}
parsedCerts = append(parsedCerts, parsed)
}
if len(parsedCerts) == 0 {
| </s> remove return 1
</s> add return errors.New("") </s> remove return 1
</s> add return errors.New("") </s> remove return 1
</s> add return errors.New("") </s> remove // Return 0 on success
func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int {
</s> add func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) error { </s> remove if validatePkey(&data, pkey) != 0 {
</s> add if validatePkey(&data, pkey) != nil { | return errors.New("") | for _, cert := range certs {
parsed, err := x509.ParseCertificate(cert.Bytes)
if err != nil {
data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err)
return errors.New("")
}
parsedCerts = append(parsedCerts, parsed)
}
if len(parsedCerts) == 0 { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
}
if len(parsedCerts) == 0 {
data.WarningValidation = fmt.Sprintf("You have specified an empty certificate")
return 1
}
data.ValidCert = true
// spew.Dump(parsedCerts)
| </s> remove return 1
</s> add return errors.New("") </s> remove return 1
</s> add return errors.New("") </s> remove return 1
</s> add return errors.New("") </s> remove return 0
</s> add return nil </s> remove return 0
</s> add return nil | return errors.New("") | }
if len(parsedCerts) == 0 {
data.WarningValidation = fmt.Sprintf("You have specified an empty certificate")
return errors.New("")
}
data.ValidCert = true
// spew.Dump(parsedCerts) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
data.NotBefore = mainCert.NotBefore
data.DNSNames = mainCert.DNSNames
}
return 0
}
// Return 0 on success
func validatePkey(data *tlsConfigStatus, pkey string) int {
// now do a more extended validation
| </s> remove // Return 0 on success
func validatePkey(data *tlsConfigStatus, pkey string) int {
</s> add func validatePkey(data *tlsConfigStatus, pkey string) error { </s> remove // Return 0 on success
func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int {
</s> add func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) error { </s> remove return 1
</s> add return errors.New("") </s> remove if validatePkey(&data, pkey) != 0 {
</s> add if validatePkey(&data, pkey) != nil { </s> remove return 1
</s> add return errors.New("") | return nil | data.NotBefore = mainCert.NotBefore
data.DNSNames = mainCert.DNSNames
}
return nil
}
// Return 0 on success
func validatePkey(data *tlsConfigStatus, pkey string) int {
// now do a more extended validation | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
return 0
}
// Return 0 on success
func validatePkey(data *tlsConfigStatus, pkey string) int {
// now do a more extended validation
var key *pem.Block // PEM-encoded certificates
var skippedBytes []string // skipped bytes
// go through all pem blocks, but take first valid pem block and drop the rest
| </s> remove // Return 0 on success
func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int {
</s> add func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) error { </s> remove return 0
</s> add return nil </s> remove if verifyCertChain(&data, certChain, serverName) != 0 {
</s> add if verifyCertChain(&data, certChain, serverName) != nil { </s> remove if validatePkey(&data, pkey) != 0 {
</s> add if validatePkey(&data, pkey) != nil { </s> remove return 1
</s> add return errors.New("") | func validatePkey(data *tlsConfigStatus, pkey string) error { |
return 0
}
func validatePkey(data *tlsConfigStatus, pkey string) error {
func validatePkey(data *tlsConfigStatus, pkey string) error {
// now do a more extended validation
var key *pem.Block // PEM-encoded certificates
var skippedBytes []string // skipped bytes
// go through all pem blocks, but take first valid pem block and drop the rest | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
}
if key == nil {
data.WarningValidation = "No valid keys were found"
return 1
}
// parse the decoded key
_, keytype, err := parsePrivateKey(key.Bytes)
if err != nil {
| </s> remove return 1
</s> add return errors.New("") </s> remove return 1
</s> add return errors.New("") </s> remove return 1
</s> add return errors.New("") </s> remove if validatePkey(&data, pkey) != 0 {
</s> add if validatePkey(&data, pkey) != nil { </s> remove if verifyCertChain(&data, certChain, serverName) != 0 {
</s> add if verifyCertChain(&data, certChain, serverName) != nil { | return errors.New("") | }
if key == nil {
data.WarningValidation = "No valid keys were found"
return errors.New("")
}
// parse the decoded key
_, keytype, err := parsePrivateKey(key.Bytes)
if err != nil { | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
// parse the decoded key
_, keytype, err := parsePrivateKey(key.Bytes)
if err != nil {
data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err)
return 1
}
data.ValidKey = true
data.KeyType = keytype
return 0
| </s> remove return 1
</s> add return errors.New("") </s> remove return 1
</s> add return errors.New("") </s> remove return 0
</s> add return nil </s> remove return 1
</s> add return errors.New("") </s> remove return 0
</s> add return nil | return errors.New("") | // parse the decoded key
_, keytype, err := parsePrivateKey(key.Bytes)
if err != nil {
data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err)
return errors.New("")
}
data.ValidKey = true
data.KeyType = keytype
return 0 | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
}
data.ValidKey = true
data.KeyType = keytype
return 0
}
/* Process certificate data and its private key.
All parameters are optional.
On error, return partially set object
| </s> remove return 1
</s> add return errors.New("") </s> remove return 1
</s> add return errors.New("") </s> remove if verifyCertChain(&data, certChain, serverName) != 0 {
</s> add if verifyCertChain(&data, certChain, serverName) != nil { </s> remove if validatePkey(&data, pkey) != 0 {
</s> add if validatePkey(&data, pkey) != nil { </s> remove return 0
</s> add return nil | return nil | }
data.ValidKey = true
data.KeyType = keytype
return nil
}
/* Process certificate data and its private key.
All parameters are optional.
On error, return partially set object | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
var data tlsConfigStatus
// check only public certificate separately from the key
if certChain != "" {
if verifyCertChain(&data, certChain, serverName) != 0 {
return data
}
}
// validate private key (right now the only validation possible is just parsing it)
| </s> remove if validatePkey(&data, pkey) != 0 {
</s> add if validatePkey(&data, pkey) != nil { </s> remove // Return 0 on success
func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) int {
</s> add func verifyCertChain(data *tlsConfigStatus, certChain string, serverName string) error { </s> remove return 0
</s> add return nil </s> remove return 1
</s> add return errors.New("") </s> remove // Return 0 on success
func validatePkey(data *tlsConfigStatus, pkey string) int {
</s> add func validatePkey(data *tlsConfigStatus, pkey string) error { | if verifyCertChain(&data, certChain, serverName) != nil { | var data tlsConfigStatus
// check only public certificate separately from the key
if certChain != "" {
if verifyCertChain(&data, certChain, serverName) != nil {
return data
}
}
// validate private key (right now the only validation possible is just parsing it) | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
}
// validate private key (right now the only validation possible is just parsing it)
if pkey != "" {
if validatePkey(&data, pkey) != 0 {
return data
}
}
// if both are set, validate both in unison
| </s> remove if verifyCertChain(&data, certChain, serverName) != 0 {
</s> add if verifyCertChain(&data, certChain, serverName) != nil { </s> remove return 1
</s> add return errors.New("") </s> remove return 0
</s> add return nil </s> remove return 1
</s> add return errors.New("") </s> remove return 0
</s> add return nil | if validatePkey(&data, pkey) != nil { | }
// validate private key (right now the only validation possible is just parsing it)
if pkey != "" {
if validatePkey(&data, pkey) != nil {
return data
}
}
// if both are set, validate both in unison | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * helper functions return 'error', not 'int' | https://github.com/AdguardTeam/AdGuardHome/commit/24edf7eeb66668893b9add03003309d755295088 | control.go |
"update_now": "Update now",
"update_failed": "Update failed",
"processing_update": "Please wait, AdGuard Home is being updated"
} | </s> remove }, CHECK_TIMEOUT);
</s> add const rmTimeout = t => t && clearTimeout(t);
const setRecursiveTimeout = (time, ...args) => setTimeout(
checkUpdate,
time,
...args,
);
console.log(count);
axios.get('control/status')
.then((response) => {
rmTimeout(timeout);
if (response) {
dispatch(getUpdateSuccess());
window.location.reload(true);
}
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
})
.catch(() => {
rmTimeout(timeout);
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
});
return false;
};
checkUpdate(); </s> remove const timer = setInterval(async () => {
const dnsStatus = await apiClient.getGlobalStatus();
if (dnsStatus) {
clearInterval(timer);
dispatch(getUpdateSuccess());
window.location.reload(true);
</s> add const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false; | "update_failed_try_later": "Update failed, please try again later", | "update_now": "Update now",
"update_failed": "Update failed",
"update_failed_try_later": "Update failed, please try again later",
"processing_update": "Please wait, AdGuard Home is being updated"
} | [
"keep",
"add",
"keep",
"keep"
] | * client: add update timeout | https://github.com/AdguardTeam/AdGuardHome/commit/24f582d36d99934295a2417de1c10d7a0afced25 | client/src/__locales/en.json |
import { t } from 'i18next';
import { showLoading, hideLoading } from 'react-redux-loading-bar';
import { normalizeHistory, normalizeFilteringStatus, normalizeLogs, normalizeTextarea } from '../helpers/helpers';
import { SETTINGS_NAMES, CHECK_TIMEOUT } from '../helpers/constants';
import Api from '../api/Api';
const apiClient = new Api();
| </s> remove }, CHECK_TIMEOUT);
</s> add const rmTimeout = t => t && clearTimeout(t);
const setRecursiveTimeout = (time, ...args) => setTimeout(
checkUpdate,
time,
...args,
);
console.log(count);
axios.get('control/status')
.then((response) => {
rmTimeout(timeout);
if (response) {
dispatch(getUpdateSuccess());
window.location.reload(true);
}
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
})
.catch(() => {
rmTimeout(timeout);
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
});
return false;
};
checkUpdate(); </s> remove const timer = setInterval(async () => {
const dnsStatus = await apiClient.getGlobalStatus();
if (dnsStatus) {
clearInterval(timer);
dispatch(getUpdateSuccess());
window.location.reload(true);
</s> add const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false; | import axios from 'axios'; | import { t } from 'i18next';
import { showLoading, hideLoading } from 'react-redux-loading-bar';
import axios from 'axios';
import { normalizeHistory, normalizeFilteringStatus, normalizeLogs, normalizeTextarea } from '../helpers/helpers';
import { SETTINGS_NAMES, CHECK_TIMEOUT } from '../helpers/constants';
import Api from '../api/Api';
const apiClient = new Api(); | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * client: add update timeout | https://github.com/AdguardTeam/AdGuardHome/commit/24f582d36d99934295a2417de1c10d7a0afced25 | client/src/actions/index.js |
dispatch(getUpdateRequest());
try {
await apiClient.getUpdate();
const timer = setInterval(async () => {
const dnsStatus = await apiClient.getGlobalStatus();
if (dnsStatus) {
clearInterval(timer);
dispatch(getUpdateSuccess());
window.location.reload(true);
}
}, CHECK_TIMEOUT);
} catch (error) {
dispatch(addErrorToast({ error: 'update_failed' }));
dispatch(getUpdateFailure());
| </s> remove }, CHECK_TIMEOUT);
</s> add const rmTimeout = t => t && clearTimeout(t);
const setRecursiveTimeout = (time, ...args) => setTimeout(
checkUpdate,
time,
...args,
);
console.log(count);
axios.get('control/status')
.then((response) => {
rmTimeout(timeout);
if (response) {
dispatch(getUpdateSuccess());
window.location.reload(true);
}
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
})
.catch(() => {
rmTimeout(timeout);
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
});
return false;
};
checkUpdate(); | const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false; | dispatch(getUpdateRequest());
try {
await apiClient.getUpdate();
const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false;
const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false;
const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false;
const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false;
const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false;
const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false;
}
}, CHECK_TIMEOUT);
} catch (error) {
dispatch(addErrorToast({ error: 'update_failed' }));
dispatch(getUpdateFailure()); | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * client: add update timeout | https://github.com/AdguardTeam/AdGuardHome/commit/24f582d36d99934295a2417de1c10d7a0afced25 | client/src/actions/index.js |
clearInterval(timer);
dispatch(getUpdateSuccess());
window.location.reload(true);
}
}, CHECK_TIMEOUT);
} catch (error) {
dispatch(addErrorToast({ error: 'update_failed' }));
dispatch(getUpdateFailure());
}
};
| </s> remove const timer = setInterval(async () => {
const dnsStatus = await apiClient.getGlobalStatus();
if (dnsStatus) {
clearInterval(timer);
dispatch(getUpdateSuccess());
window.location.reload(true);
</s> add const checkUpdate = async (attempts) => {
let count = attempts || 1;
let timeout;
if (count > 60) {
dispatch(addErrorToast({ error: 'update_failed_try_later' }));
dispatch(getUpdateFailure());
return false; | const rmTimeout = t => t && clearTimeout(t);
const setRecursiveTimeout = (time, ...args) => setTimeout(
checkUpdate,
time,
...args,
);
console.log(count);
axios.get('control/status')
.then((response) => {
rmTimeout(timeout);
if (response) {
dispatch(getUpdateSuccess());
window.location.reload(true);
}
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
})
.catch(() => {
rmTimeout(timeout);
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
});
return false;
};
checkUpdate(); | clearInterval(timer);
dispatch(getUpdateSuccess());
window.location.reload(true);
}
const rmTimeout = t => t && clearTimeout(t);
const setRecursiveTimeout = (time, ...args) => setTimeout(
checkUpdate,
time,
...args,
);
console.log(count);
axios.get('control/status')
.then((response) => {
rmTimeout(timeout);
if (response) {
dispatch(getUpdateSuccess());
window.location.reload(true);
}
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
})
.catch(() => {
rmTimeout(timeout);
timeout = setRecursiveTimeout(CHECK_TIMEOUT, count += 1);
});
return false;
};
checkUpdate();
} catch (error) {
dispatch(addErrorToast({ error: 'update_failed' }));
dispatch(getUpdateFailure());
}
}; | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * client: add update timeout | https://github.com/AdguardTeam/AdGuardHome/commit/24f582d36d99934295a2417de1c10d7a0afced25 | client/src/actions/index.js |
try {
const dnsStatus = await apiClient.getGlobalStatus();
dispatch(dnsStatusSuccess(dnsStatus));
dispatch(getVersion());
dispatch(getClients());
dispatch(getTopStats());
dispatch(getTlsStatus());
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(initSettingsFailure());
}
| </s> remove import { getClients } from '../actions';
</s> add import { getClients, getTopStats } from '../actions'; </s> remove import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast } from '../actions';
</s> add import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast, getClients } from '../actions'; | try {
const dnsStatus = await apiClient.getGlobalStatus();
dispatch(dnsStatusSuccess(dnsStatus));
dispatch(getVersion());
dispatch(getTlsStatus());
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(initSettingsFailure());
} | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * client: remove /clients and /stats_top request from global requests | https://github.com/AdguardTeam/AdGuardHome/commit/2520a62e2430dac1d9bf689c567b95d419a78339 | client/src/actions/index.js |
|
class Logs extends Component {
componentDidMount() {
this.getLogs();
this.props.getFilteringStatus();
}
componentDidUpdate(prevProps) {
// get logs when queryLog becomes enabled
if (this.props.dashboard.queryLogEnabled && !prevProps.dashboard.queryLogEnabled) {
| </s> remove import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast } from '../actions';
</s> add import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast, getClients } from '../actions'; </s> remove import { getClients } from '../actions';
</s> add import { getClients, getTopStats } from '../actions'; </s> remove dispatch(getClients());
dispatch(getTopStats());
</s> add | this.props.getClients(); | class Logs extends Component {
componentDidMount() {
this.getLogs();
this.props.getFilteringStatus();
this.props.getClients();
}
componentDidUpdate(prevProps) {
// get logs when queryLog becomes enabled
if (this.props.dashboard.queryLogEnabled && !prevProps.dashboard.queryLogEnabled) { | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * client: remove /clients and /stats_top request from global requests | https://github.com/AdguardTeam/AdGuardHome/commit/2520a62e2430dac1d9bf689c567b95d419a78339 | client/src/components/Logs/index.js |
logStatusProcessing: PropTypes.bool,
t: PropTypes.func,
};
export default withNamespaces()(Logs);
| </s> remove import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast } from '../actions';
</s> add import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast, getClients } from '../actions'; </s> remove import { getClients } from '../actions';
</s> add import { getClients, getTopStats } from '../actions'; | getClients: PropTypes.func.isRequired, | logStatusProcessing: PropTypes.bool,
t: PropTypes.func,
getClients: PropTypes.func.isRequired,
};
export default withNamespaces()(Logs); | [
"keep",
"add",
"keep",
"keep",
"keep"
] | * client: remove /clients and /stats_top request from global requests | https://github.com/AdguardTeam/AdGuardHome/commit/2520a62e2430dac1d9bf689c567b95d419a78339 | client/src/components/Logs/index.js |
class Clients extends Component {
componentDidMount() {
this.props.getClients();
}
render() {
const {
| </s> remove import { getClients } from '../actions';
</s> add import { getClients, getTopStats } from '../actions'; </s> remove import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast } from '../actions';
</s> add import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast, getClients } from '../actions'; </s> remove dispatch(getClients());
dispatch(getTopStats());
</s> add | this.props.getTopStats(); |
class Clients extends Component {
componentDidMount() {
this.props.getClients();
this.props.getTopStats();
}
render() {
const { | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | * client: remove /clients and /stats_top request from global requests | https://github.com/AdguardTeam/AdGuardHome/commit/2520a62e2430dac1d9bf689c567b95d419a78339 | client/src/components/Settings/Clients/index.js |
deleteClient: PropTypes.func.isRequired,
addClient: PropTypes.func.isRequired,
updateClient: PropTypes.func.isRequired,
getClients: PropTypes.func.isRequired,
topStats: PropTypes.object,
};
export default withNamespaces()(Clients);
| </s> remove import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast } from '../actions';
</s> add import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast, getClients } from '../actions'; </s> remove import { getClients } from '../actions';
</s> add import { getClients, getTopStats } from '../actions'; | getTopStats: PropTypes.func.isRequired, | deleteClient: PropTypes.func.isRequired,
addClient: PropTypes.func.isRequired,
updateClient: PropTypes.func.isRequired,
getClients: PropTypes.func.isRequired,
getTopStats: PropTypes.func.isRequired,
topStats: PropTypes.object,
};
export default withNamespaces()(Clients); | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | * client: remove /clients and /stats_top request from global requests | https://github.com/AdguardTeam/AdGuardHome/commit/2520a62e2430dac1d9bf689c567b95d419a78339 | client/src/components/Settings/Clients/index.js |
import { connect } from 'react-redux';
import { getClients } from '../actions';
import { addClient, updateClient, deleteClient, toggleClientModal } from '../actions/clients';
import Clients from '../components/Settings/Clients';
const mapStateToProps = (state) => {
const { dashboard, clients } = state;
| </s> remove import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast } from '../actions';
</s> add import { getLogs, toggleLogStatus, downloadQueryLog, getFilteringStatus, setRules, addSuccessToast, getClients } from '../actions'; </s> remove dispatch(getClients());
dispatch(getTopStats());
</s> add | import { getClients, getTopStats } from '../actions'; | import { connect } from 'react-redux';
import { getClients, getTopStats } from '../actions';
import { addClient, updateClient, deleteClient, toggleClientModal } from '../actions/clients';
import Clients from '../components/Settings/Clients';
const mapStateToProps = (state) => {
const { dashboard, clients } = state; | [
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | * client: remove /clients and /stats_top request from global requests | https://github.com/AdguardTeam/AdGuardHome/commit/2520a62e2430dac1d9bf689c567b95d419a78339 | client/src/containers/Clients.js |
Subsets and Splits