docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
rec, ok := hp.table[ip] | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
hp.table[ip] = rec | <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>
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
func (hp *hostsParser) addRules(ip netip.Addr, host, line string) { | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
func (hp *hostsParser) writeRules(host string, ip netip.Addr) (rule, rulePtr string) {
// TODO(a.garipov): Add a netip.Addr version to netutil.
arpa, err := netutil.IPToReversedAddr(ip.AsSlice()) | <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>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
if ip.Is4() { | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
<mask>
<mask> return rule, rulePtr
<mask> }
<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> // h... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go | |
func (hp *hostsParser) sendUpd(ch chan HostsRecords) { | <mask> return ok
<mask> }
<mask>
<mask> // sendUpd tries to send the parsed data to the ch.
<mask> func (hp *hostsParser) sendUpd(ch chan *netutil.IPMap) {
<mask> log.Debug("%s: sending upd", hostsContainerPref)
<mask>
<mask> upd := hp.table
<mask> select {
<mask> case ch <- upd:
</s> Pull request: 50... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
if maps.EqualFunc(hp.table, hc.last, (*HostsRecord).equal) { | <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> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
hc.last = maps.Clone(hp.table) | <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> }... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer.go |
"net/netip" | <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... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
"github.com/AdguardTeam/golibs/netutil" | <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... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
ip := netutil.IPv4Localhost() | <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)}}
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
assert.Len(t, upd, 1) | <mask> upd, ok := aghchan.MustReceive(hc.Upd(), 1*time.Second)
<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)
</s> Pull ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
rec, ok := upd[ip] | <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>
<mask> rec, _ := v.(*HostsRecord)
</s> Pull request: 5035-netip-arp-hosts
Updates #5035.
Squ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
<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,... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go | |
assert.Truef(t, rec.equal(want), "%+v != %+v", rec, want) | <mask>
<mask> rec, _ := v.(*HostsRecord)
<mask> require.NotNil(t, rec)
<mask>
<mask> assert.Truef(t, rec.Equal(want), "%+v != %+v", rec, want)
<mask> }
<mask>
<mask> t.Run("initial_refresh", func(t *testing.T) {
<mask> checkRefresh(t, &HostsRecord{
<mask> Aliases: stringutil.NewSet(),
</s> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
ip := netutil.IPv4Localhost() | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
wantIP netip.Addr | <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.
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
wantIP: netip.Addr{}, | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
wantIP: netip.Addr{}, | <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,
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
wantIP: netip.Addr{}, | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
assert.Equal(t, tc.wantIP, got) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/aghnet/hostscontainer_test.go |
// exists checks if client with this IP address already exists.
func (clients *clientsContainer) exists(ip net.IP, source clientSource) (ok bool) { | <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> _,... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
rc, ok = clients.findRuntimeClient(ip) | <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.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
// findRuntimeClient finds a runtime client by their IP.
func (clients *clientsContainer) findRuntimeClient(ip net.IP) (rc *RuntimeClient, ok bool) { | <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()
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
// setWHOISInfo sets the WHOIS information for a client.
func (clients *clientsContainer) setWHOISInfo(ip net.IP, wi *RuntimeClientWHOISInfo) { | <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(... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
// TODO(a.garipov): Remove once we switch to netip.Addr more fully.
ipAddr, err := netutil.IPToAddrNoMapped(ip)
if err != nil {
return false, fmt.Errorf("adding host: %w", err)
}
return clients.addHostLocked(ipAddr, host, src), nil | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
// addHostLocked adds a new IP-hostname pairing. clients.lock is expected to be
// locked.
func (clients *clientsContainer) addHostLocked(
ip netip.Addr,
host string,
src clientSource,
) (ok bool) {
rc, ok := clients.ipToRC[ip] | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
clients.ipToRC[ip] = rc | <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)
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
func (clients *clientsContainer) addFromHostsFile(hosts aghnet.HostsRecords) { | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
for ip, rec := range hosts { | <mask>
<mask> clients.rmHostsBySrc(ClientSourceHostsFile)
<mask>
<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> }... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
} | <mask> }
<mask>
<mask> clients.addHostLocked(ip, rec.Canonical, ClientSourceHostsFile)
<mask> n++
<mask>
<mask> return true
<mask> })
<mask>
<mask> log.Debug("clients: added %d client aliases from system hosts file", n)
<mask> }
<mask>
<mask> // addFromSystemARP adds the IP-hostname pairings f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
// TODO(a.garipov): Remove once we switch to netip.Addr more fully.
ipAddr, err := netutil.IPToAddrNoMapped(l.IP)
if err != nil {
log.Error("clients: bad client ip %v from dhcp: %s", l.IP, err)
continue
}
ok := clients.addHostLocked(ipAddr, l.Hostname, ClientSourceDHCP) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients.go |
assert.False(t, clients.exists(net.IP{1, 2, 3, 4}, ClientSourceHostsFile))
assert.True(t, clients.exists(net.IP{1, 1, 1, 1}, ClientSourceHostsFile))
assert.True(t, clients.exists(net.IP{2, 2, 2, 2}, ClientSourceHostsFile)) | <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}... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
assert.False(t, clients.exists(net.IP{1, 1, 1, 1}, ClientSourceHostsFile))
assert.True(t, clients.exists(net.IP{1, 1, 1, 2}, ClientSourceHostsFile)) | <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>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
assert.False(t, clients.exists(net.IP{1, 1, 1, 2}, ClientSourceHostsFile)) | <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("... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
assert.True(t, clients.exists(ip, ClientSourceHostsFile)) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
assert.True(t, clients.exists(ip, ClientSourceARP)) | <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)
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
assert.True(t, clients.exists(ip, ClientSourceDHCP)) | <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.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
clients.setWHOISInfo(ip.AsSlice(), whois) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
clients.setWHOISInfo(ip.AsSlice(), whois) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
clients.setWHOISInfo(ip.AsSlice(), whois) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clients_test.go |
rc, ok := clients.findRuntimeClient(ip) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/clientshttp.go |
if r.isCached(ip) || r.clients.exists(ip, ClientSourceRDNS) { | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/rdns.go |
assert.True(t, cc.exists(tc.cliIP, ClientSourceRDNS)) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/rdns_test.go |
w.clients.setWHOISInfo(ip, info) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04c8e3b2886bb02866ace61f796733c82b3e9aca | internal/home/whois.go |
if s.conf.BlockingMode == "custom_ip" {
s.conf.BlockingIPAddrv4 = net.ParseIP(s.conf.BlockingIPv4)
s.conf.BlockingIPAddrv6 = net.ParseIP(s.conf.BlockingIPv6)
if s.conf.BlockingIPAddrv4 == nil || s.conf.BlockingIPAddrv6 == nil {
return fmt.Errorf("DNS: invalid custom blocking IP address specified")
}
... | <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... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04de9d0f7bb1e59c2738538431ee90b1429fca0d | dnsforward/dnsforward.go |
func createTestMessageWithType(host string, qtype uint16) *dns.Msg {
req := dns.Msg{}
req.Id = dns.Id()
req.RecursionDesired = true
req.Question = []dns.Question{
{Name: host, Qtype: qtype, Qclass: dns.ClassINET},
}
return &req
}
| <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... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04de9d0f7bb1e59c2738538431ee90b1429fca0d | dnsforward/dnsforward_test.go |
if config.auth == nil {
return fmt.Errorf("Couldn't initialize Auth module")
} | <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... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04de9d0f7bb1e59c2738538431ee90b1429fca0d | home/dns.go |
if !isRunning() {
return nil
}
| <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... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04de9d0f7bb1e59c2738538431ee90b1429fca0d | home/dns.go |
e.Time = uint32(elapsed / 1000) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | dnsforward/dnsforward.go |
StatsInterval uint32 `yaml:"statistics_interval"` | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | home/config.go |
Interval uint32 `json:"interval"` | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | home/control_stats.go |
func checkStatsInterval(i uint32) bool { | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | home/control_stats.go |
statsDBFilename := filepath.Join(baseDir, "stats.db")
config.stats, err = stats.New(statsDBFilename, config.DNS.StatsInterval, nil) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | home/dns.go |
type unitIDCallback func() uint32 | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats.go |
func New(filename string, limit uint32, unitID unitIDCallback) (Stats, error) { | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats.go |
Time uint32 // processing time (msec) | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats.go |
func UIntArrayEquals(a []uint64, b []uint64) bool { | <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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
a := []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}
assert.True(t, UIntArrayEquals(d["dns_queries"].([]uint64), a)) | <mask> e.Time = 123456
<mask> s.Update(e)
<mask>
<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,... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
a = []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
assert.True(t, UIntArrayEquals(d["blocked_filtering"].([]uint64), a)) | <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, ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
a = []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
assert.True(t, UIntArrayEquals(d["replaced_safebrowsing"].([]uint64), 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, 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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
a = []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
assert.True(t, UIntArrayEquals(d["replaced_parental"].([]uint64), 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["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... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
m := d["top_queried_domains"].([]map[string]uint64) | <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_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
m = d["top_blocked_domains"].([]map[string]uint64) | <mask>
<mask> m := d["top_queried_domains"].([]map[string]uint)
<mask> assert.True(t, m[0]["domain"] == 1)
<mask>
<mask> m = d["top_blocked_domains"].([]map[string]uint)
<mask> assert.True(t, m[0]["domain"] == 1)
<mask>
<mask> m = d["top_clients"].([]map[string]uint)
<mask> assert.True(t, m[0]["127.0.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
m = d["top_clients"].([]map[string]uint64) | <mask>
<mask> m = d["top_blocked_domains"].([]map[string]uint)
<mask> assert.True(t, m[0]["domain"] == 1)
<mask>
<mask> m = d["top_clients"].([]map[string]uint)
<mask> assert.True(t, m[0]["127.0.0.1"] == 2)
<mask>
<mask> assert.True(t, d["num_dns_queries"].(uint) == 2)
<mask> assert.True(t, d["num_blo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
assert.True(t, d["num_dns_queries"].(uint64) == 2)
assert.True(t, d["num_blocked_filtering"].(uint64) == 1)
assert.True(t, d["num_replaced_safebrowsing"].(uint64) == 0)
assert.True(t, d["num_replaced_safesearch"].(uint64) == 0)
assert.True(t, d["num_replaced_parental"].(uint64) == 0) | <mask>
<mask> m = d["top_clients"].([]map[string]uint)
<mask> assert.True(t, m[0]["127.0.0.1"] == 2)
<mask>
<mask> assert.True(t, d["num_dns_queries"].(uint) == 2)
<mask> assert.True(t, d["num_blocked_filtering"].(uint) == 1)
<mask> assert.True(t, d["num_replaced_safebrowsing"].(uint) == 0)
<mask> asser... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
newID := func() uint32 { | <mask>
<mask> func TestLargeNumbers(t *testing.T) {
<mask> var hour int32
<mask> hour = 1
<mask> newID := func() int {
<mask> // use "atomic" to make Go race detector happy
<mask> return int(atomic.LoadInt32(&hour))
<mask> }
<mask>
<mask> // log.SetLevel(log.DEBUG)
</s> * stats: use uint32 or uint... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
return uint32(atomic.LoadInt32(&hour)) | <mask> var hour int32
<mask> hour = 1
<mask> newID := func() int {
<mask> // use "atomic" to make Go race detector happy
<mask> return int(atomic.LoadInt32(&hour))
<mask> }
<mask>
<mask> // log.SetLevel(log.DEBUG)
<mask> fn := "./stats.db"
<mask> os.Remove(fn)
</s> * stats: use uint32 or uint64 i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
assert.True(t, d["num_dns_queries"].(uint64) == uint64(int(hour)*n)) | <mask> }
<mask> }
<mask>
<mask> d := s.GetData(Hours)
<mask> assert.True(t, d["num_dns_queries"].(uint) == uint(int(hour)*n))
<mask>
<mask> s.Close()
<mask> os.Remove(fn)
<mask> }
</s> * stats: use uint32 or uint64 integer values, not int </s> remove assert.True(t, d["num_dns_queries"].(uint) == 2)
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_test.go |
limit uint32 // maximum time we need to keep data for (in hours) | <mask> )
<mask>
<mask> // statsCtx - global context
<mask> type statsCtx struct {
<mask> limit int // maximum time we need to keep data for (in hours)
<mask> filename string // database file name
<mask> unitID unitIDCallback // user function which returns the current unit ID
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 | <mask> }
<mask>
<mask> // data for 1 time unit
<mask> type unit struct {
<mask> id int // unit ID. Default: absolute hour since Jan 1, 1970
<mask>
<mask> nTotal int // total requests
<mask> nResult []int // number of requests per one result
<mask> timeSum int // sum of processing time of all reques... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
nTotal uint64 // total requests
nResult []uint64 // number of requests per one result
timeSum uint64 // sum of processing time of all requests (usec) | <mask> // data for 1 time unit
<mask> type unit struct {
<mask> id int // unit ID. Default: absolute hour since Jan 1, 1970
<mask>
<mask> nTotal int // total requests
<mask> nResult []int // number of requests per one result
<mask> timeSum int // sum of processing time of all requests (usec)
<mask>
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
domains map[string]uint64 // number of requests per domain
blockedDomains map[string]uint64 // number of blocked requests per domain
clients map[string]uint64 // number of requests per client | <mask> nResult []int // number of requests per one result
<mask> timeSum int // sum of processing time of all requests (usec)
<mask>
<mask> // top:
<mask> domains map[string]int // number of requests per domain
<mask> blockedDomains map[string]int // number of blocked requests per domain
<mask> c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
Count uint64 | <mask>
<mask> // name-count pair
<mask> type countPair struct {
<mask> Name string
<mask> Count uint
<mask> }
<mask>
<mask> // structure for storing data in file
<mask> type unitDB struct {
<mask> NTotal uint
</s> * stats: use uint32 or uint64 integer values, not int </s> remove NTotal uint
NResult... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
NTotal uint64
NResult []uint64 | <mask> }
<mask>
<mask> // structure for storing data in file
<mask> type unitDB struct {
<mask> NTotal uint
<mask> NResult []uint
<mask>
<mask> Domains []countPair
<mask> BlockedDomains []countPair
<mask> Clients []countPair
<mask>
</s> * stats: use uint32 or uint64 integer values, no... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
TimeAvg uint32 // usec | <mask> Domains []countPair
<mask> BlockedDomains []countPair
<mask> Clients []countPair
<mask>
<mask> TimeAvg uint // usec
<mask> }
<mask>
<mask> func createObject(filename string, limitDays int, unitID unitIDCallback) (*statsCtx, error) {
<mask> s := statsCtx{}
<mask> s.limit = limitDay... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func createObject(filename string, limitDays uint32, unitID unitIDCallback) (*statsCtx, error) { | <mask>
<mask> TimeAvg uint // usec
<mask> }
<mask>
<mask> func createObject(filename string, limitDays int, unitID unitIDCallback) (*statsCtx, error) {
<mask> s := statsCtx{}
<mask> s.limit = limitDays * 24
<mask> s.filename = filename
<mask> s.unitID = newUnitID
<mask> if unitID != nil {
</s> * stat... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
id := uint32(btoi(name)) | <mask> log.Tracef("Deleting old units...")
<mask> firstID := id - s.limit - 1
<mask> unitDel := 0
<mask> forEachBkt := func(name []byte, b *bolt.Bucket) error {
<mask> id := btoi(name)
<mask> if id < firstID {
<mask> err := tx.DeleteBucket(name)
<mask> if err != nil {
<mask> log.Debu... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func newUnitID() uint32 {
return uint32(time.Now().Unix() / (60 * 60)) | <mask> return u
<mask> }
<mask>
<mask> // Get unit ID for the current hour
<mask> func newUnitID() int {
<mask> return int(time.Now().Unix() / (60 * 60))
<mask> }
<mask>
<mask> // Initialize a unit
<mask> func (s *statsCtx) initUnit(u *unit, id int) {
<mask> u.id = id
</s> * stats: use uint32 or uint64... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func (s *statsCtx) initUnit(u *unit, id uint32) { | <mask> return int(time.Now().Unix() / (60 * 60))
<mask> }
<mask>
<mask> // Initialize a unit
<mask> func (s *statsCtx) initUnit(u *unit, id int) {
<mask> u.id = id
<mask> u.nResult = make([]int, rLast)
<mask> u.domains = make(map[string]int)
<mask> u.blockedDomains = make(map[string]int)
<mask> u.clien... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
u.nResult = make([]uint64, rLast)
u.domains = make(map[string]uint64)
u.blockedDomains = make(map[string]uint64)
u.clients = make(map[string]uint64) | <mask>
<mask> // Initialize a unit
<mask> func (s *statsCtx) initUnit(u *unit, id int) {
<mask> u.id = id
<mask> u.nResult = make([]int, rLast)
<mask> u.domains = make(map[string]int)
<mask> u.blockedDomains = make(map[string]int)
<mask> u.clients = make(map[string]int)
<mask> }
<mask>
<mask> // Open ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func unitName(id uint32) []byte {
return itob(uint64(id)) | <mask> log.Tracef("tx.Commit")
<mask> }
<mask>
<mask> // Get unit name
<mask> func unitName(id int) []byte {
<mask> return itob(id)
<mask> }
<mask>
<mask> // Convert integer to 8-byte array (big endian)
<mask> func itob(v int) []byte {
<mask> b := make([]byte, 8)
</s> * stats: use uint32 or uint64 inte... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func itob(v uint64) []byte { | <mask> return itob(id)
<mask> }
<mask>
<mask> // Convert integer to 8-byte array (big endian)
<mask> func itob(v int) []byte {
<mask> b := make([]byte, 8)
<mask> binary.BigEndian.PutUint64(b, uint64(v))
<mask> return b
<mask> }
<mask>
</s> * stats: use uint32 or uint64 integer values, not int </s> remo... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
binary.BigEndian.PutUint64(b, v) | <mask>
<mask> // Convert integer to 8-byte array (big endian)
<mask> func itob(v int) []byte {
<mask> b := make([]byte, 8)
<mask> binary.BigEndian.PutUint64(b, uint64(v))
<mask> return b
<mask> }
<mask>
<mask> // Convert 8-byte array (big endian) to integer
<mask> func btoi(b []byte) int {
</s> * stats:... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func btoi(b []byte) uint64 {
return binary.BigEndian.Uint64(b) | <mask> return b
<mask> }
<mask>
<mask> // Convert 8-byte array (big endian) to integer
<mask> func btoi(b []byte) int {
<mask> return int(binary.BigEndian.Uint64(b))
<mask> }
<mask>
<mask> // Flush the current unit to DB and delete an old unit when a new hour is started
<mask> func (s *statsCtx) periodicF... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool { | <mask> log.Tracef("periodicFlush() exited")
<mask> }
<mask>
<mask> // Delete unit's data from file
<mask> func (s *statsCtx) deleteUnit(tx *bolt.Tx, id int) bool {
<mask> err := tx.DeleteBucket(unitName(id))
<mask> if err != nil {
<mask> log.Tracef("bolt DeleteBucket: %s", err)
<mask> return false
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func convertMapToArray(m map[string]uint64, max int) []countPair { | <mask> log.Debug("Stats: deleted unit %d", id)
<mask> return true
<mask> }
<mask>
<mask> func convertMapToArray(m map[string]int, max int) []countPair {
<mask> a := []countPair{}
<mask> for k, v := range m {
<mask> pair := countPair{}
<mask> pair.Name = k
<mask> pair.Count = uint(v)
</s> * stats: ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
pair.Count = v | <mask> a := []countPair{}
<mask> for k, v := range m {
<mask> pair := countPair{}
<mask> pair.Name = k
<mask> pair.Count = uint(v)
<mask> a = append(a, pair)
<mask> }
<mask> less := func(i, j int) bool {
<mask> if a[i].Count >= a[j].Count {
<mask> return true
</s> * stats: use uint32 or uint... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func convertArrayToMap(a []countPair) map[string]uint64 {
m := map[string]uint64{} | <mask> }
<mask> return a[:max]
<mask> }
<mask>
<mask> func convertArrayToMap(a []countPair) map[string]int {
<mask> m := map[string]int{}
<mask> for _, it := range a {
<mask> m[it.Name] = int(it.Count)
<mask> }
<mask> return m
<mask> }
</s> * stats: use uint32 or uint64 integer values, not int </s>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
m[it.Name] = it.Count | <mask>
<mask> func convertArrayToMap(a []countPair) map[string]int {
<mask> m := map[string]int{}
<mask> for _, it := range a {
<mask> m[it.Name] = int(it.Count)
<mask> }
<mask> return m
<mask> }
<mask>
<mask> func serialize(u *unit) *unitDB {
</s> * stats: use uint32 or uint64 integer values, not in... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
udb.NTotal = u.nTotal | <mask> }
<mask>
<mask> func serialize(u *unit) *unitDB {
<mask> udb := unitDB{}
<mask> udb.NTotal = uint(u.nTotal)
<mask> for _, it := range u.nResult {
<mask> udb.NResult = append(udb.NResult, uint(it))
<mask> }
<mask> if u.nTotal != 0 {
<mask> udb.TimeAvg = uint(u.timeSum / u.nTotal)
</s> * stats... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
udb.NResult = append(udb.NResult, it) | <mask> func serialize(u *unit) *unitDB {
<mask> udb := unitDB{}
<mask> udb.NTotal = uint(u.nTotal)
<mask> for _, it := range u.nResult {
<mask> udb.NResult = append(udb.NResult, uint(it))
<mask> }
<mask> if u.nTotal != 0 {
<mask> udb.TimeAvg = uint(u.timeSum / u.nTotal)
<mask> }
<mask> udb.Domains ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
udb.TimeAvg = uint32(u.timeSum / u.nTotal) | <mask> for _, it := range u.nResult {
<mask> udb.NResult = append(udb.NResult, uint(it))
<mask> }
<mask> if u.nTotal != 0 {
<mask> udb.TimeAvg = uint(u.timeSum / u.nTotal)
<mask> }
<mask> udb.Domains = convertMapToArray(u.domains, maxDomains)
<mask> udb.BlockedDomains = convertMapToArray(u.blockedDoma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
u.nTotal = udb.NTotal | <mask> return &udb
<mask> }
<mask>
<mask> func deserialize(u *unit, udb *unitDB) {
<mask> u.nTotal = int(udb.NTotal)
<mask> for _, it := range udb.NResult {
<mask> u.nResult = append(u.nResult, int(it))
<mask> }
<mask> u.domains = convertArrayToMap(udb.Domains)
<mask> u.blockedDomains = convertArrayT... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
u.timeSum = uint64(udb.TimeAvg) * u.nTotal | <mask> }
<mask> u.domains = convertArrayToMap(udb.Domains)
<mask> u.blockedDomains = convertArrayToMap(udb.BlockedDomains)
<mask> u.clients = convertArrayToMap(udb.Clients)
<mask> u.timeSum = int(udb.TimeAvg) * u.nTotal
<mask> }
<mask>
<mask> func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id int, udb *unit... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id uint32, udb *unitDB) bool { | <mask> u.clients = convertArrayToMap(udb.Clients)
<mask> u.timeSum = int(udb.TimeAvg) * u.nTotal
<mask> }
<mask>
<mask> func (s *statsCtx) flushUnitToDB(tx *bolt.Tx, id int, udb *unitDB) bool {
<mask> log.Tracef("Flushing unit %d", id)
<mask>
<mask> bkt, err := tx.CreateBucketIfNotExists(unitName(id))
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB { | <mask>
<mask> return true
<mask> }
<mask>
<mask> func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id int) *unitDB {
<mask> bkt := tx.Bucket(unitName(id))
<mask> if bkt == nil {
<mask> return nil
<mask> }
<mask>
</s> * stats: use uint32 or uint64 integer values, not int </s> remove func (s *statsCtx) d... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
func convertTopArray(a []countPair) []map[string]uint64 {
m := []map[string]uint64{} | <mask>
<mask> return &udb
<mask> }
<mask>
<mask> func convertTopArray(a []countPair) []map[string]uint {
<mask> m := []map[string]uint{}
<mask> for _, it := range a {
<mask> ent := map[string]uint{}
<mask> ent[it.Name] = it.Count
<mask> m = append(m, ent)
<mask> }
</s> * stats: use uint32 or uin... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
ent := map[string]uint64{} | <mask>
<mask> func convertTopArray(a []countPair) []map[string]uint {
<mask> m := []map[string]uint{}
<mask> for _, it := range a {
<mask> ent := map[string]uint{}
<mask> ent[it.Name] = it.Count
<mask> m = append(m, ent)
<mask> }
<mask> return m
<mask> }
</s> * stats: use uint32 or uint64 integer ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/04e2566e9e968f299e134e812ca88d24073de9ff | stats/stats_unit.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.