docstring_tokens stringlengths 18 16.9k | code_tokens stringlengths 75 1.81M | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|
keep keep keep keep replace replace keep keep keep keep keep | <mask> n.MAC = mac
<mask> }
<mask>
<mask> host := fields[0]
<mask> if err := netutil.ValidateDomainName(host); err != nil {
<mask> log.Debug("parsing arp output: %s", err)
<mask> } else {
<mask> n.Name = host
<mask> }
<mask>
<mask> ns = append(ns, n)
</s> Pull request: 5035-netip-arp-... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_bsd.go |
keep add keep keep keep keep keep keep | <mask> import (
<mask> "net"
<mask> )
<mask>
<mask> const arpAOutput = `
<mask> invalid.mac (1.2.3.4) at 12:34:56:78:910 on el0 ifscope [ethernet]
<mask> invalid.ip (1.2.3.4.5) at ab:cd:ef:ab:cd:12 on ek0 ifscope [ethernet]
<mask> invalid.fmt 1 at 12:cd:ef:ab:cd:ef on er0 ifscope [ethernet]
</s> Pull reques... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_bsd_test.go |
keep keep keep replace keep keep keep replace keep keep | <mask>
<mask> var wantNeighs = []Neighbor{{
<mask> Name: "hostname.one",
<mask> IP: net.IPv4(192, 168, 1, 2),
<mask> MAC: net.HardwareAddr{0xAB, 0xCD, 0xEF, 0xAB, 0xCD, 0xEF},
<mask> }, {
<mask> Name: "hostname.two",
<mask> IP: net.ParseIP("::ffff:ffff"),
<mask> MAC: net.HardwareAddr{0xEF, 0xCD, 0... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_bsd_test.go |
keep keep keep keep replace keep keep | <mask> IP: net.ParseIP("::ffff:ffff"),
<mask> MAC: net.HardwareAddr{0xEF, 0xCD, 0xAB, 0xEF, 0xCD, 0xAB},
<mask> }, {
<mask> Name: "",
<mask> IP: net.ParseIP("::1234"),
<mask> MAC: net.HardwareAddr{0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF},
<mask> }}
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_bsd_test.go |
keep add keep keep keep keep keep keep | <mask> "io/fs"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/netutil"
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the followin... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> continue
<mask> }
<mask>
<mask> n := Neighbor{}
<mask> if n.IP = net.ParseIP(fields[0]); n.IP == nil || n.IP.IsUnspecified() {
<mask> continue
<mask> } else if n.MAC, err = net.ParseMAC(fields[3]); err != nil {
<mask> continue
<mask> }
<mask>
</s> Pull request: 5035-netip-arp-host... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> n := Neighbor{}
<mask>
<mask> if ip := net.ParseIP(fields[0]); ip == nil || n.IP.IsUnspecified() {
<mask> continue
<mask> } else {
<mask> n.IP = ip
<mask> }
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> n.IP = ip
<mask> }
<mask>
<mask> hwStr := fields[3]
<mask> if mac, err := net.ParseMAC(hwStr); err != nil {
<mask> log.Debug("parsing arp output: %s", err)
<mask>
<mask> continue
<mask> } else {
<mask> n.MAC = mac
<mask> }
</s> Pull request: 5035-netip-arp-hosts
Updates #5035... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> n := Neighbor{}
<mask>
<mask> if ipStr := fields[1]; len(ipStr) < 2 {
<mask> continue
<mask> } else if ip := net.ParseIP(ipStr[1 : len(ipStr)-1]); ip == nil {
<mask> continue
<mask> } else {
<mask> n.IP = ip
<mask> }
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> hwStr := fields[3]
<mask> if mac, err := net.ParseMAC(hwStr); err != nil {
<mask> log.Debug("parsing arp output: %s", err)
<mask>
<mask> continue
<mask> } else {
<mask> n.MAC = mac
<mask> }
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> host := fields[0]
<mask> if verr := netutil.ValidateDomainName(host); verr != nil {
<mask> log.Debug("parsing arp output: %s", verr)
<mask> } else {
<mask> n.Name = host
<mask> }
<mask>
<mask> ns = append(ns, n)
</s> Pull request: 5035-netip-arp-hosts
Updates #5035... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> n := Neighbor{}
<mask>
<mask> if ip := net.ParseIP(fields[0]); ip == nil {
<mask> continue
<mask> } else {
<mask> n.IP = ip
<mask> }
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532eba... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> } else {
<mask> n.IP = ip
<mask> }
<mask>
<mask> if mac, err := net.ParseMAC(fields[4]); err != nil {
<mask> log.Debug("parsing arp output: %s", err)
<mask>
<mask> continue
<mask> } else {
<mask> n.MAC = mac
<mask> }
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squ... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux.go |
keep keep add keep keep keep keep | <mask>
<mask> import (
<mask> "net"
<mask> "sync"
<mask> "testing"
<mask> "testing/fstest"
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532ebae1aa809d18da
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Oct 25 14:... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux_test.go |
keep keep keep replace keep keep replace keep | <mask> ::ffff:ffff dev enp0s3 lladdr ef:cd:ab:ef:cd:ab router STALE`
<mask>
<mask> var wantNeighs = []Neighbor{{
<mask> IP: net.IPv4(192, 168, 1, 2),
<mask> MAC: net.HardwareAddr{0xAB, 0xCD, 0xEF, 0xAB, 0xCD, 0xEF},
<mask> }, {
<mask> IP: net.ParseIP("::ffff:ffff"),
<mask> MAC: net.HardwareAddr{0xEF, 0xC... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_linux_test.go |
keep keep add keep keep keep keep keep | <mask> import (
<mask> "bufio"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532ebae1aa809d18da
Author: Ainar Garipov <A.Garipo... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_openbsd.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> n := Neighbor{}
<mask>
<mask> if ip := net.ParseIP(fields[0]); ip == nil {
<mask> continue
<mask> } else {
<mask> n.IP = ip
<mask> }
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532eba... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_openbsd.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> } else {
<mask> n.IP = ip
<mask> }
<mask>
<mask> if mac, err := net.ParseMAC(fields[1]); err != nil {
<mask> log.Debug("parsing arp output: %s", err)
<mask>
<mask> continue
<mask> } else {
<mask> n.MAC = mac
<mask> }
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squ... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_openbsd.go |
keep keep add keep keep keep keep keep keep | <mask>
<mask> import (
<mask> "net"
<mask> )
<mask>
<mask> const arpAOutput = `
<mask> Host Ethernet Address Netif Expire Flags
<mask> 1.2.3.4.5 aa:bb:cc:dd:ee:ff em0 permanent
<mask> 1.2.3.4 12:34:56:78:910 em0 permanent
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squas... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_openbsd_test.go |
keep keep keep replace keep keep replace | <mask> `
<mask>
<mask> var wantNeighs = []Neighbor{{
<mask> IP: net.IPv4(192, 168, 1, 2),
<mask> MAC: net.HardwareAddr{0xAB, 0xCD, 0xEF, 0xAB, 0xCD, 0xEF},
<mask> }, {
<mask> IP: net.ParseIP("::ffff:ffff"),
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit ... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_openbsd_test.go |
keep keep keep add keep keep keep keep keep keep | <mask> package aghnet
<mask>
<mask> import (
<mask> "net"
<mask> "sync"
<mask> "testing"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/testutil"
<mask> "github.com/stretchr/testify/assert"
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed c... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> return arp.OnNeighbors()
<mask> }
<mask>
<mask> func TestARPDBS(t *testing.T) {
<mask> knownIP := net.IP{1, 2, 3, 4}
<mask> knownMAC := net.HardwareAddr{0xAB, 0xCD, 0xEF, 0xAB, 0xCD, 0xEF}
<mask>
<mask> succRefrCount, failRefrCount := 0, 0
<mask> clnp := func() {
<mask> succRefrCount, failRefr... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_test.go |
keep keep keep add keep keep keep keep | <mask>
<mask> import (
<mask> "bufio"
<mask> "net"
<mask> "strings"
<mask> "sync"
<mask> )
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532ebae1aa809d18da
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Oct 25 14... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_windows.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> n := Neighbor{}
<mask>
<mask> if ip := net.ParseIP(fields[0]); ip == nil {
<mask> continue
<mask> } else {
<mask> n.IP = ip
<mask> }
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532eba... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_windows.go |
keep keep keep keep replace keep keep keep keep keep | <mask> } else {
<mask> n.IP = ip
<mask> }
<mask>
<mask> if mac, err := net.ParseMAC(fields[1]); err != nil {
<mask> continue
<mask> } else {
<mask> n.MAC = mac
<mask> }
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_windows.go |
keep add keep keep keep keep | <mask> import (
<mask> "net"
<mask> )
<mask>
<mask> const arpAOutput = `
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532ebae1aa809d18da
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Oct 25 14:26:52 2022 +0300
... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_windows_test.go |
keep keep replace keep keep replace | <mask>
<mask> var wantNeighs = []Neighbor{{
<mask> IP: net.IPv4(192, 168, 1, 2),
<mask> MAC: net.HardwareAddr{0xAB, 0xCD, 0xEF, 0xAB, 0xCD, 0xEF},
<mask> }, {
<mask> IP: net.ParseIP("::ffff:ffff"),
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/arpdb_windows_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> "bufio"
<mask> "fmt"
<mask> "io"
<mask> "io/fs"
<mask> "net"
<mask> "path"
<mask> "strings"
<mask> "sync"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos"
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c2... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep add keep keep keep keep | <mask> "github.com/AdguardTeam/urlfilter/rules"
<mask> "github.com/miekg/dns"
<mask> )
<mask>
<mask> // DefaultHostsPaths returns the slice of paths default for the operating system
<mask> // to files and directories which are containing the hosts database. The result
</s> Pull request: 5035-netip-arp-hosts
... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> "github.com/AdguardTeam/urlfilter/rules"
<mask> "github.com/miekg/dns"
<mask> )
<mask>
<mask> //lint:file-ignore SA1019 TODO(a.garipov): Replace [*netutil.IPMap].
<mask>
<mask> // DefaultHostsPaths returns the slice of paths default for the operating system
<mask> // to files and directories which a... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace replace replace keep keep keep keep keep | <mask> // done is the channel to sign closing the container.
<mask> done chan struct{}
<mask>
<mask> // updates is the channel for receiving updated hosts.
<mask> //
<mask> // TODO(e.burkov): Use map[netip.Addr]struct{} instead.
<mask> updates chan *netutil.IPMap
<mask>
<mask> // last is the set of h... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace replace replace keep keep keep keep keep | <mask> // TODO(e.burkov): Use map[netip.Addr]struct{} instead.
<mask> updates chan *netutil.IPMap
<mask>
<mask> // last is the set of hosts that was cached within last detected change.
<mask> //
<mask> // TODO(e.burkov): Use map[netip.Addr]struct{} instead.
<mask> last *netutil.IPMap
<mask>
<mask> /... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> stateLock: &sync.RWMutex{},
<mask> },
<mask> listID: listID,
<mask> done: make(chan struct{}, 1),
<mask> updates: make(chan *netutil.IPMap, 1),
<mask> fsys: fsys,
<mask> w: w,
<mask> patterns: patterns,
<mask> }
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updat... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace replace replace keep keep keep keep keep | <mask>
<mask> return nil
<mask> }
<mask>
<mask> // Upd returns the channel into which the updates are sent. The receivable
<mask> // map's values are guaranteed to be of type of *HostsRecord.
<mask> func (hc *HostsContainer) Upd() (updates <-chan *netutil.IPMap) {
<mask> return hc.updates
<mask> }
<mask>... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> translations map[string]string
<mask>
<mask> // table stores only the unique IP-hostname pairs. It's also sent to the
<mask> // updates channel afterwards.
<mask> table *netutil.IPMap
<mask> }
<mask>
<mask> // newHostsParser creates a new *hostsParser with buffers of size taken from the
<mask> //... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> func (hc *HostsContainer) newHostsParser() (hp *hostsParser) {
<mask> return &hostsParser{
<mask> rulesBuilder: &strings.Builder{},
<mask> translations: map[string]string{},
<mask> table: netutil.NewIPMap(hc.last.Len()),
<mask> }
<mask> }
<mask>
<mask> // parseFile is a aghos.FileWalker ... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> func (hp *hostsParser) parseFile(r io.Reader) (patterns []string, cont bool, err error) {
<mask> s := bufio.NewScanner(r)
<mask> for s.Scan() {
<mask> ip, hosts := hp.parseLine(s.Text())
<mask> if ip == nil || len(hosts) == 0 {
<mask> continue
<mask> }
<mask>
<mask> hp.addRecord(ip, hosts)... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep replace keep keep replace keep keep keep keep | <mask>
<mask> // parseLine parses the line having the hosts syntax ignoring invalid ones.
<mask> func (hp *hostsParser) parseLine(line string) (ip net.IP, hosts []string) {
<mask> fields := strings.Fields(line)
<mask> if len(fields) < 2 {
<mask> return nil, nil
<mask> }
<mask>
<mask> if ip = net.ParseI... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> if len(fields) < 2 {
<mask> return nil, nil
<mask> }
<mask>
<mask> if ip = net.ParseIP(fields[0]); ip == nil {
<mask> return nil, nil
<mask> }
<mask>
<mask> for _, f := range fields[1:] {
<mask> hashIdx := strings.IndexByte(f, '#')
<mask> if hashIdx == 0 {
</s> Pull request: 5035-netip... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> //
<mask> // See https://github.com/AdguardTeam/AdGuardHome/issues/3946.
<mask> //
<mask> // TODO(e.burkov): Investigate if hosts may contain DNS-SD domains.
<mask> err := netutil.ValidateDomainName(f)
<mask> if err != nil {
<mask> log.Error("%s: host %q is invalid, ignoring", hostsContain... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep replace | <mask>
<mask> return ip, hosts
<mask> }
<mask>
<mask> // HostsRecord represents a single hosts file record.
<mask> type HostsRecord struct {
<mask> Aliases *stringutil.Set
<mask> Canonical string
<mask> }
<mask>
<mask> // Equal returns true if all fields of rec are equal to field in other or they
<m... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> // hosts must have at least one name.
<mask> func (hp *hostsParser) addRecord(ip net.IP, hosts []string) {
<mask> line := strings.Join(append([]string{ip.String()}, hosts...), " ")
<mask>
<mask> var rec *HostsRecord
<mask> v, ok := hp.table.Get(ip)
<mask> if !ok {
<mask> rec = &HostsRecord{
<mask... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep | <mask> }
<mask>
<mask> rec.Canonical, hosts = hosts[0], hosts[1:]
<mask> hp.addRules(ip, rec.Canonical, line)
<mask> hp.table.Set(ip, rec)
<mask> } else {
<mask> rec, ok = v.(*HostsRecord)
<mask> if !ok {
<mask> log.Error("%s: adding pairs: unexpected type %T", hostsContainerPref, v)
<mask>
... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask> }
<mask>
<mask> // addRules adds rules and rule translations for the line.
<mask> func (hp *hostsParser) addRules(ip net.IP, host, line string) {
<mask> rule, rulePtr := hp.writeRules(host, ip)
<mask> hp.translations[rule], hp.translations[rulePtr] = line, line
<mask>
<mask> log.Debug("%s... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> }
<mask>
<mask> // writeRules writes the actual rule for the qtype and the PTR for the host-ip
<mask> // pair into internal builders.
<mask> func (hp *hostsParser) writeRules(host string, ip net.IP) (rule, rulePtr string) {
<mask> arpa, err := netutil.IPToReversedAddr(ip)
<mask> if err != nil {
<mask>... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> var qtype string
<mask> // The validation of the IP address has been performed earlier so it is
<mask> // guaranteed to be either an IPv4 or an IPv6.
<mask> if ip.To4() != nil {
<mask> qtype = "A"
<mask> } else {
<mask> qtype = "AAAA"
<mask> }
<mask>
</s> Pull request: 5035-netip-ar... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace rep... | <mask>
<mask> // equalSet returns true if the internal hosts table just parsed equals target.
<mask> // target's values must be of type *HostsRecord.
<mask> func (hp *hostsParser) equalSet(target *netutil.IPMap) (ok bool) {
<mask> if target == nil {
<mask> // hp.table shouldn't appear nil since it's initializ... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if _, err = aghos.FileWalker(hp.parseFile).Walk(hc.fsys, hc.patterns...); err != nil {
<mask> return fmt.Errorf("refreshing : %w", err)
<mask> }
<mask>
<mask> if hp.equalSet(hc.last) {
<mask> log.Debug("%s: no changes detected", hostsContainerPref)
<mask>
<mask> return nil
<mask> }
<mask> ... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep keep keep keep replace keep keep keep keep keep | <mask> return nil
<mask> }
<mask> defer hp.sendUpd(hc.updates)
<mask>
<mask> hc.last = hp.table.ShallowClone()
<mask>
<mask> var rulesStrg *filterlist.RuleStorage
<mask> if rulesStrg, err = hp.newStrg(hc.listID); err != nil {
<mask> return fmt.Errorf("initializing rules storage: %w", err)
<mask> }... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
keep add keep keep keep keep | <mask> "io/fs"
<mask> "net"
<mask> "path"
<mask> "strings"
<mask> "sync/atomic"
<mask> "testing"
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532ebae1aa809d18da
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Oct 25 14:26... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep add keep keep keep keep | <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/stringutil"
<mask> "github.com/AdguardTeam/golibs/testutil"
<mask> "github.com/AdguardTeam/urlfilter"
<mask> "github.com/AdguardTeam/urlfilter/rules"
</s> Pull re... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> func TestHostsContainer_refresh(t *testing.T) {
<mask> // TODO(e.burkov): Test the case with no actual updates.
<mask>
<mask> ip := net.IP{127, 0, 0, 1}
<mask> ipStr := ip.String()
<mask>
<mask> testFS := fstest.MapFS{"dir/file1": &fstest.MapFile{Data: []byte(ipStr + ` hostname` + nl)}}
<... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep replace keep replace keep keep keep keep | <mask> require.True(t, ok)
<mask> require.NotNil(t, upd)
<mask>
<mask> assert.Equal(t, 1, upd.Len())
<mask>
<mask> v, ok := upd.Get(ip)
<mask> require.True(t, ok)
<mask>
<mask> require.IsType(t, (*HostsRecord)(nil), v)
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed c... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep keep replace replace replace replace keep keep keep keep keep keep keep keep replace keep keep | <mask> assert.Equal(t, 1, upd.Len())
<mask>
<mask> v, ok := upd.Get(ip)
<mask> require.True(t, ok)
<mask>
<mask> require.IsType(t, (*HostsRecord)(nil), v)
<mask>
<mask> rec, _ := v.(*HostsRecord)
<mask> require.NotNil(t, rec)
<mask>
<mask> assert.Truef(t, rec.Equal(want), "%+v != %+v", rec,... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask> }
<mask>
<mask> func TestUniqueRules_ParseLine(t *testing.T) {
<mask> ip := net.IP{127, 0, 0, 1}
<mask> ipStr := ip.String()
<mask>
<mask> testCases := []struct {
<mask> name string
<mask> line string
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> testCases := []struct {
<mask> name string
<mask> line string
<mask> wantIP net.IP
<mask> wantHosts []string
<mask> }{{
<mask> name: "simple",
<mask> line: ipStr + ` hostname`,
<mask> wantIP: ip,
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> wantHosts: []string{"hostname", "alias"},
<mask> }, {
<mask> name: "invalid_line",
<mask> line: ipStr,
<mask> wantIP: nil,
<mask> wantHosts: nil,
<mask> }, {
<mask> name: "invalid_line_hostname",
<mask> line: ipStr + ` # hostname`,
<mask> wantIP: ip,
</s> Pu... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> wantHosts: []string{"hostname"},
<mask> }, {
<mask> name: "whole_comment",
<mask> line: `# ` + ipStr + ` hostname`,
<mask> wantIP: nil,
<mask> wantHosts: nil,
<mask> }, {
<mask> name: "partial_comment",
<mask> line: ipStr + ` host#name`,
<mask> wantIP: ip,
<... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> wantHosts: []string{"host"},
<mask> }, {
<mask> name: "empty",
<mask> line: ``,
<mask> wantIP: nil,
<mask> wantHosts: nil,
<mask> }}
<mask>
<mask> for _, tc := range testCases {
<mask> hp := hostsParser{}
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed co... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep keep replace keep keep keep keep | <mask> for _, tc := range testCases {
<mask> hp := hostsParser{}
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> got, hosts := hp.parseLine(tc.line)
<mask> assert.True(t, tc.wantIP.Equal(got))
<mask> assert.Equal(t, tc.wantHosts, hosts)
<mask> })
<mask> }
<mask> }
</s> Pull request: 5035-ne... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> clients.updateFromDHCP(false)
<mask> }
<mask> }
<mask>
<mask> // Exists checks if client with this IP address already exists.
<mask> func (clients *clientsContainer) Exists(ip net.IP, source clientSource) (ok bool) {
<mask> clients.lock.Lock()
<mask> defer clients.lock.Unlock()
<mask>
<mask> _,... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }, true
<mask> }
<mask>
<mask> var rc *RuntimeClient
<mask> rc, ok = clients.FindRuntimeClient(ip)
<mask> if ok {
<mask> return &querylog.Client{
<mask> Name: rc.Host,
<mask> WHOIS: toQueryLogWHOIS(rc.WHOISInfo),
<mask> }, false
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask>
<mask> return rc, ok
<mask> }
<mask>
<mask> // FindRuntimeClient finds a runtime client by their IP.
<mask> func (clients *clientsContainer) FindRuntimeClient(ip net.IP) (rc *RuntimeClient, ok bool) {
<mask> if ip == nil {
<mask> return nil, false
<mask> }
<mask>
<mask> clients.lock.Lock()
<... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask>
<mask> return nil
<mask> }
<mask>
<mask> // SetWHOISInfo sets the WHOIS information for a client.
<mask> func (clients *clientsContainer) SetWHOISInfo(ip net.IP, wi *RuntimeClientWHOISInfo) {
<mask> clients.lock.Lock()
<mask> defer clients.lock.Unlock()
<mask>
<mask> _, ok := clients.findLocked(... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep keep keep keep replace keep keep keep keep keep | <mask> func (clients *clientsContainer) AddHost(ip net.IP, host string, src clientSource) (ok bool, err error) {
<mask> clients.lock.Lock()
<mask> defer clients.lock.Unlock()
<mask>
<mask> return clients.addHostLocked(ip, host, src), nil
<mask> }
<mask>
<mask> // addHostLocked adds a new IP-hostname pairin... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep keep keep keep replace replace replace keep keep keep keep keep | <mask>
<mask> return clients.addHostLocked(ip, host, src), nil
<mask> }
<mask>
<mask> // addHostLocked adds a new IP-hostname pairing. For internal use only.
<mask> func (clients *clientsContainer) addHostLocked(ip net.IP, host string, src clientSource) (ok bool) {
<mask> rc, ok := clients.findRuntimeClient... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep | <mask> Source: src,
<mask> WHOISInfo: &RuntimeClientWHOISInfo{},
<mask> }
<mask>
<mask> // TODO(a.garipov): Remove once we switch to netip.Addr more fully.
<mask> ipAddr, err := netutil.IPToAddrNoMapped(ip)
<mask> if err != nil {
<mask> log.Error("clients: bad client ip %v: %s", ip, err)
... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep keep keep keep replace replace replace keep keep keep keep keep | <mask> }
<mask>
<mask> // addFromHostsFile fills the client-hostname pairing index from the system's
<mask> // hosts files.
<mask> //
<mask> //lint:ignore SA1019 TODO(a.garipov): Replace [*netutil.IPMap].
<mask> func (clients *clientsContainer) addFromHostsFile(hosts *netutil.IPMap) {
<mask> clients.lock.Loc... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep replace replace replace replace replace replace replace replace keep keep replace replace replace keep keep | <mask> n := 0
<mask> hosts.Range(func(ip net.IP, v any) (cont bool) {
<mask> rec, ok := v.(*aghnet.HostsRecord)
<mask> if !ok {
<mask> log.Error("clients: bad type %T in hosts for %s", v, ip)
<mask>
<mask> return true
<mask> }
<mask>
<mask> clients.addHostLocked(ip, rec.Canonical, ClientSour... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if l.Hostname == "" {
<mask> continue
<mask> }
<mask>
<mask> ok := clients.addHostLocked(l.IP, l.Hostname, ClientSourceDHCP)
<mask> if ok {
<mask> n++
<mask> }
<mask> }
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493e... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
keep keep keep keep replace replace replace keep keep keep keep keep | <mask> require.True(t, ok)
<mask>
<mask> assert.Equal(t, "client2", c.Name)
<mask>
<mask> assert.False(t, clients.Exists(net.IP{1, 2, 3, 4}, ClientSourceHostsFile))
<mask> assert.True(t, clients.Exists(net.IP{1, 1, 1, 1}, ClientSourceHostsFile))
<mask> assert.True(t, clients.Exists(net.IP{2, 2, 2, 2}... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask> Name: "client1",
<mask> })
<mask> require.NoError(t, err)
<mask>
<mask> assert.False(t, clients.Exists(net.IP{1, 1, 1, 1}, ClientSourceHostsFile))
<mask> assert.True(t, clients.Exists(net.IP{1, 1, 1, 2}, ClientSourceHostsFile))
<mask>
<mask> err = clients.Update("client1", &Client{
<mask>... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> t.Run("del_success", func(t *testing.T) {
<mask> ok := clients.Del("client1-renamed")
<mask> require.True(t, ok)
<mask>
<mask> assert.False(t, clients.Exists(net.IP{1, 1, 1, 2}, ClientSourceHostsFile))
<mask> })
<mask>
<mask> t.Run("del_fail", func(t *testing.T) {
<mask> ok := clients.Del("... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> require.NoError(t, err)
<mask>
<mask> assert.True(t, ok)
<mask>
<mask> assert.True(t, clients.Exists(ip, ClientSourceHostsFile))
<mask> })
<mask>
<mask> t.Run("dhcp_replaces_arp", func(t *testing.T) {
<mask> ip := net.IP{1, 2, 3, 4}
<mask>
</s> Pull request: 5035-netip-arp-hosts
Updates... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> ok, err := clients.AddHost(ip, "from_arp", ClientSourceARP)
<mask> require.NoError(t, err)
<mask>
<mask> assert.True(t, ok)
<mask> assert.True(t, clients.Exists(ip, ClientSourceARP))
<mask>
<mask> ok, err = clients.AddHost(ip, "from_dhcp", ClientSourceDHCP)
<mask> require.NoError(t, err)
<... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> ok, err = clients.AddHost(ip, "from_dhcp", ClientSourceDHCP)
<mask> require.NoError(t, err)
<mask>
<mask> assert.True(t, ok)
<mask> assert.True(t, clients.Exists(ip, ClientSourceDHCP))
<mask> })
<mask>
<mask> t.Run("addhost_fail", func(t *testing.T) {
<mask> ok, err := clients.AddHost(net.... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> }
<mask>
<mask> t.Run("new_client", func(t *testing.T) {
<mask> ip := netip.MustParseAddr("1.1.1.255")
<mask> clients.SetWHOISInfo(ip.AsSlice(), whois)
<mask> rc := clients.ipToRC[ip]
<mask> require.NotNil(t, rc)
<mask>
<mask> assert.Equal(t, rc.WHOISInfo, whois)
<mask> })
</s> Pull req... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> require.NoError(t, err)
<mask>
<mask> assert.True(t, ok)
<mask>
<mask> clients.SetWHOISInfo(ip.AsSlice(), whois)
<mask> rc := clients.ipToRC[ip]
<mask> require.NotNil(t, rc)
<mask>
<mask> assert.Equal(t, rc.WHOISInfo, whois)
<mask> })
</s> Pull request: 5035-netip-arp-hosts
Updates #5... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> })
<mask> require.NoError(t, err)
<mask> assert.True(t, ok)
<mask>
<mask> clients.SetWHOISInfo(ip.AsSlice(), whois)
<mask> rc := clients.ipToRC[ip]
<mask> require.Nil(t, rc)
<mask>
<mask> assert.True(t, clients.Del("client1"))
<mask> })
</s> Pull request: 5035-netip-arp-hosts
Updates... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
keep keep keep keep replace keep keep keep keep keep | <mask> // findRuntime looks up the IP in runtime and temporary storages, like
<mask> // /etc/hosts tables, DHCP leases, or blocklists. cj is guaranteed to be
<mask> // non-nil.
<mask> func (clients *clientsContainer) findRuntime(ip net.IP, idStr string) (cj *clientJSON) {
<mask> rc, ok := clients.FindRuntimeClie... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clientshttp.go |
keep keep keep keep replace keep keep keep keep keep | <mask> // resolved.
<mask> func (r *RDNS) Begin(ip net.IP) {
<mask> r.ensurePrivateCache()
<mask>
<mask> if r.isCached(ip) || r.clients.Exists(ip, ClientSourceRDNS) {
<mask> return
<mask> }
<mask>
<mask> select {
<mask> case r.ipCh <- ip:
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squa... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/rdns.go |
keep keep keep keep replace keep keep keep | <mask>
<mask> return
<mask> }
<mask>
<mask> assert.True(t, cc.Exists(tc.cliIP, ClientSourceRDNS))
<mask> })
<mask> }
<mask> }
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532ebae1aa809d18da
Author: Ainar Garipov <A.Garip... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/rdns_test.go |
keep keep keep keep replace keep keep | <mask> if info == nil {
<mask> continue
<mask> }
<mask>
<mask> w.clients.SetWHOISInfo(ip, info)
<mask> }
<mask> }
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squashed commit of the following:
commit d1c4493ee4e28d05670c20532ebae1aa809d18da
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
D... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/whois.go |
keep keep add keep keep keep keep | <mask> func (s *Server) Prepare(config *ServerConfig) error {
<mask> if config != nil {
<mask> s.conf = *config
<mask> }
<mask>
<mask> if len(s.conf.UpstreamDNS) == 0 {
<mask> s.conf.UpstreamDNS = defaultDNS
</s> Merge: - DNS: "custom_ip" blocking mode didn't work after app restart
Close #1262
Squashed... | https://github.com/AdguardTeam/AdGuardHome/commit/04de9d0f7bb1e59c2738538431ee90b1429fca0d | dnsforward/dnsforward.go |
keep add keep keep keep keep keep keep | <mask> }
<mask>
<mask> func assertGoogleAResponse(t *testing.T, reply *dns.Msg) {
<mask> assertResponse(t, reply, "8.8.8.8")
<mask> }
<mask>
<mask> func assertResponse(t *testing.T, reply *dns.Msg, ip string) {
<mask> if len(reply.Answer) != 1 {
</s> Merge: - DNS: "custom_ip" blocking mode didn't work afte... | https://github.com/AdguardTeam/AdGuardHome/commit/04de9d0f7bb1e59c2738538431ee90b1429fca0d | dnsforward/dnsforward_test.go |
keep keep keep add keep keep keep keep | <mask> }
<mask>
<mask> sessFilename := filepath.Join(baseDir, "sessions.db")
<mask> config.auth = InitAuth(sessFilename, config.Users, config.WebSessionTTLHours*60*60)
<mask> config.Users = nil
<mask>
<mask> Context.rdns = InitRDNS(Context.dnsServer, &Context.clients)
<mask> Context.whois = initWhois(&C... | https://github.com/AdguardTeam/AdGuardHome/commit/04de9d0f7bb1e59c2738538431ee90b1429fca0d | home/dns.go |
keep add keep keep keep keep keep | <mask>
<mask> func stopDNSServer() error {
<mask> err := Context.dnsServer.Stop()
<mask> if err != nil {
<mask> return errorx.Decorate(err, "Couldn't stop forwarding DNS server")
<mask> }
<mask>
</s> Merge: - DNS: "custom_ip" blocking mode didn't work after app restart
Close #1262
Squashed commit of the... | https://github.com/AdguardTeam/AdGuardHome/commit/04de9d0f7bb1e59c2738538431ee90b1429fca0d | home/dns.go |
keep keep keep keep replace keep keep keep keep keep | <mask> e.Client = addr.IP
<mask> case *net.TCPAddr:
<mask> e.Client = addr.IP
<mask> }
<mask> e.Time = uint(elapsed / 1000)
<mask> switch res.Reason {
<mask>
<mask> case dnsfilter.NotFilteredNotFound:
<mask> fallthrough
<mask> case dnsfilter.NotFilteredWhiteList:
</s> * stats: use uint32 or uint... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | dnsforward/dnsforward.go |
keep keep keep keep replace keep keep keep keep keep | <mask> BindHost string `yaml:"bind_host"`
<mask> Port int `yaml:"port"`
<mask>
<mask> // time interval for statistics (in days)
<mask> StatsInterval uint `yaml:"statistics_interval"`
<mask>
<mask> dnsforward.FilteringConfig `yaml:",inline"`
<mask>
<mask> UpstreamDNS []string `yaml:"upstream_dns... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | home/config.go |
keep keep keep keep replace keep keep keep keep keep | <mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> type statsConfig struct {
<mask> Interval uint `json:"interval"`
<mask> }
<mask>
<mask> // Get stats configuration
<mask> func handleStatsInfo(w http.ResponseWriter, r *http.Request) {
<mask> resp := statsConfig{}
</s> * stats: use uint32... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | home/control_stats.go |
keep keep keep keep replace keep keep | <mask> httpRegister(http.MethodPost, "/control/stats_config", handleStatsConfig)
<mask> httpRegister(http.MethodGet, "/control/stats_info", handleStatsInfo)
<mask> }
<mask>
<mask> func checkStatsInterval(i uint) bool {
<mask> return i == 1 || i == 7 || i == 30 || i == 90
<mask> }
</s> * stats: use uint32 or... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | home/control_stats.go |
keep keep keep keep replace keep keep keep keep keep | <mask> if err != nil {
<mask> log.Fatalf("Cannot create DNS data dir at %s: %s", baseDir, err)
<mask> }
<mask>
<mask> config.stats, err = stats.New(filepath.Join(baseDir, "stats.db"), int(config.DNS.StatsInterval), nil)
<mask> if err != nil {
<mask> log.Fatal("Couldn't initialize statistics module")
<m... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | home/dns.go |
keep keep keep keep replace keep keep keep keep keep | <mask> import (
<mask> "net"
<mask> )
<mask>
<mask> type unitIDCallback func() int
<mask>
<mask> // New - create object
<mask> // filename: DB file name
<mask> // limit: time limit (in days)
<mask> // unitID: user function to get the current unit ID. If nil, the current time hour is used.
</s> * stats: u... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats.go |
keep keep keep keep replace keep keep keep keep keep | <mask> // New - create object
<mask> // filename: DB file name
<mask> // limit: time limit (in days)
<mask> // unitID: user function to get the current unit ID. If nil, the current time hour is used.
<mask> func New(filename string, limit int, unitID unitIDCallback) (Stats, error) {
<mask> return createObject(f... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats.go |
keep keep keep keep replace keep | <mask> type Entry struct {
<mask> Domain string
<mask> Client net.IP
<mask> Result Result
<mask> Time uint // processing time (msec)
<mask> }
</s> * stats: use uint32 or uint64 integer values, not int </s> remove Count uint
</s> add Count uint64 </s> remove id int // unit ID. Default: absolute hour si... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats.go |
keep keep keep keep replace keep keep keep keep keep | <mask>
<mask> "github.com/stretchr/testify/assert"
<mask> )
<mask>
<mask> func UIntArrayEquals(a []uint, b []uint) bool {
<mask> if len(a) != len(b) {
<mask> return false
<mask> }
<mask>
<mask> for i := range a {
</s> * stats: use uint32 or uint64 integer values, not int </s> remove func (s *statsCt... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
keep replace replace keep replace replace keep | <mask> d := s.GetData(Hours)
<mask> a := []uint{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}
<mask> assert.True(t, UIntArrayEquals(d["dns_queries"].([]uint), a))
<mask>
<mask> a = []uint{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
<mask> assert.True(t, ... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask>
<mask> a = []uint{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
<mask> assert.True(t, UIntArrayEquals(d["blocked_filtering"].([]uint), a))
<mask>
<mask> a = []uint{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
<mask> assert.True(t, UIntArrayEquals(d... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
keep keep keep keep replace replace keep keep keep keep keep | <mask>
<mask> a = []uint{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
<mask> assert.True(t, UIntArrayEquals(d["replaced_safebrowsing"].([]uint), a))
<mask>
<mask> a = []uint{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
<mask> assert.True(t, UIntArrayEqua... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
keep keep keep keep replace keep keep keep keep keep keep keep keep replace | <mask>
<mask> a = []uint{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
<mask> assert.True(t, UIntArrayEquals(d["replaced_parental"].([]uint), a))
<mask>
<mask> m := d["top_queried_domains"].([]map[string]uint)
<mask> assert.True(t, m[0]["domain"] == 1)
<mask>
<mask> m = d["top_... | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.