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
if clientID != "" { d.ServerName = clientID + "." + d.ServerName
<mask> // See https://developer.apple.com/documentation/devicemanagement/dnssettings/dnssettings. <mask> d.ServerName = "" <mask> case dnsProtoTLS: <mask> dspName = fmt.Sprintf("%s DoT", d.ServerName) <mask> if d.clientID != "" { <mask> d.ServerName = d.clientID + "." + d.ServerName <mask> } <mask...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
payloadID := fmt.Sprintf("%s.%s", dnsSettingsPayloadType, genUUIDv4()) data := &mobileConfig{ PayloadDescription: "Adds AdGuard Home to macOS Big Sur " + "and iOS 14 or newer systems", PayloadDisplayName: dspName, PayloadIdentifier: genUUIDv4(), PayloadType: "Configuration", PayloadUUID: g...
<mask> default: <mask> return nil, fmt.Errorf("bad dns protocol %q", proto) <mask> } <mask> <mask> data := mobileConfig{ <mask> PayloadContent: []payloadContent{{ <mask> Name: dspName, <mask> PayloadDescription: "Configures device to use AdGuard Home", <mask> PayloadDisplayName: ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
PayloadDisplayName: dspName, PayloadDescription: "Configures device to use AdGuard Home",
<mask> PayloadContent: []*payloadContent{{ <mask> PayloadType: dnsSettingsPayloadType, <mask> PayloadIdentifier: payloadID, <mask> PayloadUUID: genUUIDv4(), <mask> PayloadVersion: 1, <mask> DNSSettings: d, <mask> }}, <mask> PayloadVersion: 1, <mask> Pa...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
<mask> PayloadUUID: genUUIDv4(), <mask> PayloadVersion: 1, <mask> DNSSettings: d, <mask> }}, <mask> PayloadDescription: "Adds AdGuard Home to Big Sur and iOS 14 or newer systems", <mask> PayloadDisplayName: dspName, <mask> PayloadIdentifier: genUUIDv4(), <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
PayloadRemovalDisallowed: false,
<mask> DNSSettings: d, <mask> }}, <mask> PayloadVersion: 1, <mask> } <mask> <mask> return plist.MarshalIndent(data, plist.XMLFormat, "\t") <mask> } <mask> <mask> func respondJSONError(w http.ResponseWriter, status int, msg string) { </s> Pull request: home: add bootstrap to mobilec...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: cloneBootstrap(),
<mask> return <mask> } <mask> } <mask> <mask> d := dnsSettings{ <mask> DNSProtocol: dnsp, <mask> ServerName: host, <mask> clientID: clientID, <mask> } <mask> <mask> mobileconfig, err := getMobileConfig(d) <mask> if err != nil { <mask> respondJSONError(w, http.StatusInternalServerErr...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
mobileconfig, err := encodeMobileConfig(d, clientID)
<mask> ServerName: host, <mask> clientID: clientID, <mask> } <mask> <mask> mobileconfig, err := getMobileConfig(d) <mask> if err != nil { <mask> respondJSONError(w, http.StatusInternalServerError, err.Error()) <mask> <mask> return <mask> } </s> Pull request: home: add bootstrap to mobilecon...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
// cloneBootstrap returns a clone of the current bootstrap DNS servers. func cloneBootstrap() (bootstrap []string) { config.RLock() defer config.RUnlock() return stringutil.CloneSlice(config.DNS.BootstrapDNS) }
<mask> <mask> _, _ = w.Write(mobileconfig) <mask> } <mask> <mask> func handleMobileConfigDoH(w http.ResponseWriter, r *http.Request) { <mask> handleMobileConfig(w, r, dnsProtoHTTPS) <mask> } <mask> <mask> func handleMobileConfigDoT(w http.ResponseWriter, r *http.Request) { </s> Pull request: home: add bo...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
<mask> "net/http/httptest" <mask> "testing" <mask> <mask> "github.com/stretchr/testify/assert" <mask> "github.com/stretchr/testify/require" <mask> "howett.net/plist" <mask> ) </s> Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
setupBootstraps(t)
<mask> } <mask> } <mask> <mask> func TestHandleMobileConfigDoH(t *testing.T) { <mask> t.Run("success", func(t *testing.T) { <mask> r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/doh.mobileconfig?host=example.org", nil) <mask> require.NoError(t, err) <mask> </s> Pull request:...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
<mask> _, err = plist.Unmarshal(w.Body.Bytes(), &mc) <mask> require.NoError(t, err) <mask> <mask> require.Len(t, mc.PayloadContent, 1) <mask> assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) <mask> assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) <mask> assert...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.Equal(t, testBootstrapDNS, s.ServerAddresses) assert.Empty(t, s.ServerName) assert.Equal(t, "https://example.org/dns-query", s.ServerURL)
<mask> <mask> require.Len(t, mc.PayloadContent, 1) <mask> assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) <mask> assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) <mask> assert.Equal(t, "https://example.org/dns-query", mc.PayloadContent[0].DNSSettings.ServerURL) <m...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
<mask> _, err = plist.Unmarshal(w.Body.Bytes(), &mc) <mask> require.NoError(t, err) <mask> <mask> require.Len(t, mc.PayloadContent, 1) <mask> assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) <mask> assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) <mask> assert...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.Equal(t, testBootstrapDNS, s.ServerAddresses) assert.Empty(t, s.ServerName) assert.Equal(t, "https://example.org/dns-query/cli42", s.ServerURL)
<mask> <mask> require.Len(t, mc.PayloadContent, 1) <mask> assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) <mask> assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) <mask> assert.Equal(t, "https://example.org/dns-query/cli42", mc.PayloadContent[0].DNSSettings.ServerUR...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
setupBootstraps(t)
<mask> } <mask> <mask> func TestHandleMobileConfigDoT(t *testing.T) { <mask> t.Run("success", func(t *testing.T) { <mask> r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/dot.mobileconfig?host=example.org", nil) <mask> require.NoError(t, err) <mask> </s> Pull request: home: add ...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
<mask> _, err = plist.Unmarshal(w.Body.Bytes(), &mc) <mask> require.NoError(t, err) <mask> <mask> require.Len(t, mc.PayloadContent, 1) <mask> assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) <mask> assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) <mask> assert...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.Equal(t, testBootstrapDNS, s.ServerAddresses) assert.Equal(t, "example.org", s.ServerName) assert.Empty(t, s.ServerURL)
<mask> <mask> require.Len(t, mc.PayloadContent, 1) <mask> assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) <mask> assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) <mask> assert.Equal(t, "example.org", mc.PayloadContent[0].DNSSettings.ServerName) <mask> }) <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
<mask> _, err = plist.Unmarshal(w.Body.Bytes(), &mc) <mask> require.NoError(t, err) <mask> <mask> require.Len(t, mc.PayloadContent, 1) <mask> assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) <mask> assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) <mask> assert...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
s := mc.PayloadContent[0].DNSSettings require.NotNil(t, s) assert.Equal(t, testBootstrapDNS, s.ServerAddresses) assert.Equal(t, "cli42.example.org", s.ServerName) assert.Empty(t, s.ServerURL)
<mask> <mask> require.Len(t, mc.PayloadContent, 1) <mask> assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) <mask> assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) <mask> assert.Equal(t, "cli42.example.org", mc.PayloadContent[0].DNSSettings.ServerName) <mask> }) <...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
// RegisterFunc is the function that sets the handler to handle the URL for the // method. // // TODO(e.burkov, a.garipov): Get rid of it. type RegisterFunc func(method, url string, handler http.HandlerFunc)
<mask> ) <mask> <mask> // OK responds with word OK. <mask> func OK(w http.ResponseWriter) { <mask> if _, err := io.WriteString(w, "OK\n"); err != nil { <mask> log.Error("couldn't write body: %s", err) </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. U...
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/aghhttp/aghhttp.go
<mask> import ( <mask> "encoding/json" <mask> "fmt" <mask> "net" <mask> "net/http" <mask> "path/filepath" <mask> "runtime" <mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/log" </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Update...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dhcpd/dhcpd.go
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "runtime" <mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/AdguardTeam/golibs/netutil" <mask> ) <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: comm...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dhcpd/dhcpd.go
HTTPRegister aghhttp.RegisterFunc `yaml:"-"`
<mask> // Called when the configuration is changed by HTTP request <mask> ConfigModified func() `yaml:"-"` <mask> <mask> // Register an HTTP handler <mask> HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` <mask> <mask> Enabled bool `yaml:"enabled"` <mask> In...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dhcpd/dhcpd.go
<mask> "crypto/tls" <mask> "crypto/x509" <mask> "fmt" <mask> "net" <mask> "net/http" <mask> "os" <mask> "sort" <mask> "strings" <mask> "time" <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the foll...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/config.go
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtls" <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/dnsproxy/proxy" <mask> "github.com/AdguardTeam/dnsproxy/upstream" <mask> "github.com/AdguardTeam/golibs/errors" </s> Pull request:...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/config.go
HTTPRegister aghhttp.RegisterFunc
<mask> // Called when the configuration is changed by HTTP request <mask> ConfigModified func() <mask> <mask> // Register an HTTP handler <mask> HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) <mask> <mask> // ResolveClients signals if the RDNS should resolve clients' addresses...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/config.go
stats stats.Interface
<mask> dnsProxy *proxy.Proxy // DNS proxy instance <mask> dnsFilter *filtering.DNSFilter // DNS filter instance <mask> dhcpServer dhcpd.ServerInterface // DHCP server instance (optional) <mask> queryLog querylog.QueryLog // Query log instance <mask> stats stats.Stats <mask> access ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/dnsforward.go
Stats stats.Interface
<mask> <mask> // DNSCreateParams are parameters to create a new server. <mask> type DNSCreateParams struct { <mask> DNSFilter *filtering.DNSFilter <mask> Stats stats.Stats <mask> QueryLog querylog.QueryLog <mask> DHCPServer dhcpd.ServerInterface <mask> PrivateNets netutil.SubnetSet <mask> An...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/dnsforward.go
stats.Interface
<mask> // testStats is a simple stats.Stats implementation for tests. <mask> type testStats struct { <mask> // Stats is embedded here simply to make testStats a stats.Stats without <mask> // actually implementing all methods. <mask> stats.Stats <mask> <mask> lastEntry stats.Entry <mask> } <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/stats_test.go
<mask> "context" <mask> "fmt" <mask> "io/fs" <mask> "net" <mask> "net/http" <mask> "os" <mask> "runtime" <mask> "runtime/debug" <mask> "strings" <mask> "sync" </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit o...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/filtering/filtering.go
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "strings" <mask> "sync" <mask> "sync/atomic" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet" <mask> "github.com/AdguardTeam/dnsproxy/upstream" <mask> "github.com/AdguardTeam/golibs/cache" <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log"...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/filtering/filtering.go
HTTPRegister aghhttp.RegisterFunc `yaml:"-"`
<mask> // Called when the configuration is changed by HTTP request <mask> ConfigModified func() `yaml:"-"` <mask> <mask> // Register an HTTP handler <mask> HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` <mask> <mask> // CustomResolver is the resolver used by DNSFilt...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/filtering/filtering.go
"encoding"
<mask> package home <mask> <mask> import ( <mask> "bytes" <mask> "fmt" <mask> "net" <mask> "sort" <mask> "strings" <mask> "sync" </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clients.go
Name string `json:"name"` Source clientSource `json:"source"` IP net.IP `json:"ip"`
<mask> <mask> type runtimeClientJSON struct { <mask> WHOISInfo *RuntimeClientWHOISInfo `json:"whois_info"` <mask> <mask> Name string `json:"name"` <mask> Source string `json:"source"` <mask> IP net.IP `json:"ip"` <mask> } <mask> <mask> type clientListJSON struct { <mask> Clients []*clien...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clientshttp.go
Name: rc.Host, Source: rc.Source, IP: ip,
<mask> <mask> cj := runtimeClientJSON{ <mask> WHOISInfo: rc.WHOISInfo, <mask> <mask> Name: rc.Host, <mask> IP: ip, <mask> } <mask> <mask> cj.Source = "etc/hosts" <mask> switch rc.Source { <mask> case ClientSourceDHCP: <mask> cj.Source = "DHCP" <mask> case ClientSourceRDNS: <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clientshttp.go
aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e)
<mask> <mask> w.Header().Set("Content-Type", "application/json") <mask> e := json.NewEncoder(w).Encode(data) <mask> if e != nil { <mask> aghhttp.Error( <mask> r, <mask> w, <mask> http.StatusInternalServerError, <mask> "Failed to encode to json: %v", <mask> e, <mask> ) <mask> <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clientshttp.go
// It is still possible that the IP used to be in the runtime clients // list, but then the server was reloaded. So, check the DNS server's // blocked IP list.
<mask> // non-nil. <mask> func (clients *clientsContainer) findRuntime(ip net.IP, idStr string) (cj *clientJSON) { <mask> rc, ok := clients.FindRuntimeClient(ip) <mask> if !ok { <mask> // It is still possible that the IP used to be in the runtime <mask> // clients list, but then the server was reloaded. So...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clientshttp.go
func httpRegister(method, url string, handler http.HandlerFunc) {
<mask> Context.mux.HandleFunc("/apple/dot.mobileconfig", postInstall(handleMobileConfigDoT)) <mask> RegisterAuthHandlers() <mask> } <mask> <mask> func httpRegister(method, url string, handler func(http.ResponseWriter, *http.Request)) { <mask> if method == "" { <mask> // "/dns-query" handler doesn't need au...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/control.go
stats stats.Interface // statistics module
<mask> // Modules <mask> // -- <mask> <mask> clients clientsContainer // per-client-settings module <mask> stats stats.Stats // statistics module <mask> queryLog querylog.QueryLog // query log module <mask> dnsServer *dnsforward.Server // DNS module <mask> rdns *RDNS ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/home.go
<mask> package querylog <mask> <mask> import ( <mask> "net" <mask> "net/http" <mask> "path/filepath" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet" <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" </s> Pull request: 4358 fix stats Merge in DNS/adguard-...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/querylog/querylog.go
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet" <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/AdguardTeam/golibs/timeutil" <mask> "github.com/miek...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/querylog/querylog.go
HTTPRegister aghhttp.RegisterFunc
<mask> // example by HTTP requests. <mask> ConfigModified func() <mask> <mask> // HTTPRegister registers an HTTP handler. <mask> HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) <mask> <mask> // FindClient returns client information by their IDs. <mask> FindClient func(ids []s...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/querylog/querylog.go
func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) {
<mask> ReplacedParental []uint64 `json:"replaced_parental"` <mask> } <mask> <mask> // handleStats is a handler for getting statistics. <mask> func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { <mask> start := time.Now() <mask> <mask> var resp statsResponse <mask> if s.conf.limit...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
var ok bool resp, ok = s.getData() log.Debug("stats: prepared data in %v", time.Since(start)) if !ok { // Don't bring the message to the lower case since it's a part of UI // text for the moment. aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get statistics data") return
<mask> func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { <mask> start := time.Now() <mask> <mask> var resp statsResponse <mask> if s.conf.limit == 0 { <mask> resp = statsResponse{ <mask> TimeUnits: "days", <mask> <mask> TopBlocked: []topAddrs{}, <mask> TopClients: []topA...
[ "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/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) {
<mask> IntervalDays uint32 `json:"interval"` <mask> } <mask> <mask> // Get configuration <mask> func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { <mask> resp := config{} <mask> resp.IntervalDays = s.conf.limit / 24 <mask> <mask> data, err := json.Marshal(resp) <mask> if err !...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
resp.IntervalDays = s.limitHours / 24
<mask> <mask> // Get configuration <mask> func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { <mask> resp := config{} <mask> resp.IntervalDays = s.conf.limit / 24 <mask> <mask> data, err := json.Marshal(resp) <mask> if err != nil { <mask> aghhttp.Error(r, w, http.StatusInternal...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
<mask> } <mask> } <mask> <mask> // Set configuration <mask> func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { <mask> reqData := config{} <mask> err := json.NewDecoder(r.Body).Decode(&reqData) <mask> if err != nil { <mask> aghhttp.Error(r, w, http.StatusBadRequest, "json deco...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
s.configModified()
<mask> return <mask> } <mask> <mask> s.setLimit(int(reqData.IntervalDays)) <mask> s.conf.ConfigModified() <mask> } <mask> <mask> // Reset data <mask> func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { <mask> s.clear() </s> Pull request: 4358 fix stats Merge in DNS/adguard-...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) {
<mask> s.conf.ConfigModified() <mask> } <mask> <mask> // Reset data <mask> func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { <mask> s.clear() <mask> } <mask> <mask> // Register web handlers <mask> func (s *statsCtx) initWeb() { </s> Pull request: 4358 fix stats Merge in DNS/a...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
func (s *StatsCtx) initWeb() { if s.httpRegister == nil {
<mask> s.clear() <mask> } <mask> <mask> // Register web handlers <mask> func (s *statsCtx) initWeb() { <mask> if s.conf.HTTPRegister == nil { <mask> return <mask> } <mask> <mask> s.conf.HTTPRegister(http.MethodGet, "/control/stats", s.handleStats) <mask> s.conf.HTTPRegister(http.MethodPost, "/contro...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
s.httpRegister(http.MethodGet, "/control/stats", s.handleStats) s.httpRegister(http.MethodPost, "/control/stats_reset", s.handleStatsReset) s.httpRegister(http.MethodPost, "/control/stats_config", s.handleStatsConfig) s.httpRegister(http.MethodGet, "/control/stats_info", s.handleStatsInfo)
<mask> if s.conf.HTTPRegister == nil { <mask> return <mask> } <mask> <mask> s.conf.HTTPRegister(http.MethodGet, "/control/stats", s.handleStats) <mask> s.conf.HTTPRegister(http.MethodPost, "/control/stats_reset", s.handleStatsReset) <mask> s.conf.HTTPRegister(http.MethodPost, "/control/stats_config", s.h...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> package stats <mask> <mask> import ( <mask> "net" <mask> "net/http" <mask> ) <mask> <mask> type unitIDCallback func() uint32 <mask> <mask> // DiskConfig - configuration settings that are stored on disk </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Upd...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// UnitIDGenFunc is the signature of a function that generates a unique ID for // the statistics unit. type UnitIDGenFunc func() (id uint32)
<mask> "net" <mask> "net/http" <mask> ) <mask> <mask> type unitIDCallback func() uint32 <mask> <mask> // DiskConfig - configuration settings that are stored on disk <mask> type DiskConfig struct { <mask> Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) <mask> } </s>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// DiskConfig is the configuration structure that is stored in file.
<mask> ) <mask> <mask> type unitIDCallback func() uint32 <mask> <mask> // DiskConfig - configuration settings that are stored on disk <mask> type DiskConfig struct { <mask> Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) <mask> } <mask> <mask> // Config - module conf...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"`
<mask> type unitIDCallback func() uint32 <mask> <mask> // DiskConfig - configuration settings that are stored on disk <mask> type DiskConfig struct { <mask> Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) <mask> } <mask> <mask> // Config - module configuration <mask> t...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Config is the configuration structure for the statistics collecting.
<mask> type DiskConfig struct { <mask> Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) <mask> } <mask> <mask> // Config - module configuration <mask> type Config struct { <mask> Filename string // database file name <mask> LimitDays uint32 // time limi...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc
<mask> } <mask> <mask> // Config - module configuration <mask> type Config struct { <mask> Filename string // database file name <mask> LimitDays uint32 // time limit (in days) <mask> UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// ConfigModified will be called each time the configuration changed via web // interface.
<mask> Filename string // database file name <mask> LimitDays uint32 // time limit (in days) <mask> UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. <mask> <mask> // Called when the configuration is changed by HTTP request <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc
<mask> <mask> // Called when the configuration is changed by HTTP request <mask> ConfigModified func() <mask> <mask> // Register an HTTP handler <mask> HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) <mask> <mask> limit uint32 // maximum time we need to keep data for (in hour...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Filename is the name of the database file. Filename string
<mask> <mask> // Register an HTTP handler <mask> HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) <mask> <mask> limit uint32 // maximum time we need to keep data for (in hours) <mask> } <mask> <mask> // New - create object <mask> func New(conf Config) (Stats, error) { <mask> ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32
<mask> <mask> limit uint32 // maximum time we need to keep data for (in hours) <mask> } <mask> <mask> // New - create object <mask> func New(conf Config) (Stats, error) { <mask> return createObject(conf) <mask> } <mask> <mask> // Stats - main interface <mask> type Stats interface { <mask> Start() </s...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Interface is the statistics interface to be used by other packages. type Interface interface { // Start begins the statistics collecting.
<mask> func New(conf Config) (Stats, error) { <mask> return createObject(conf) <mask> } <mask> <mask> // Stats - main interface <mask> type Stats interface { <mask> Start() <mask> <mask> // Close object. <mask> // This function is not thread safe <mask> // (can't be called in parallel with any other ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Close stops the statistics collecting.
<mask> // Stats - main interface <mask> type Stats interface { <mask> Start() <mask> <mask> // Close object. <mask> // This function is not thread safe <mask> // (can't be called in parallel with any other function of this interface). <mask> Close() <mask> <mask> // Update counters <mask> Update(e ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Update collects the incoming statistics data.
<mask> // This function is not thread safe <mask> // (can't be called in parallel with any other function of this interface). <mask> Close() <mask> <mask> // Update counters <mask> Update(e Entry) <mask> <mask> // Get IP addresses of the clients with the most number of requests <mask> GetTopClientsIP...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// GetTopClientIP returns at most limit IP addresses corresponding to the // clients with the most number of requests.
<mask> <mask> // Update counters <mask> Update(e Entry) <mask> <mask> // Get IP addresses of the clients with the most number of requests <mask> GetTopClientsIP(limit uint) []net.IP <mask> <mask> // WriteDiskConfig - write configuration <mask> WriteDiskConfig(dc *DiskConfig) <mask> } </s> Pull reque...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// WriteDiskConfig puts the Interface's configuration to the dc.
<mask> <mask> // Get IP addresses of the clients with the most number of requests <mask> GetTopClientsIP(limit uint) []net.IP <mask> <mask> // WriteDiskConfig - write configuration <mask> WriteDiskConfig(dc *DiskConfig) <mask> } <mask> <mask> // TimeUnit - time unit <mask> type TimeUnit int </s> Pull ...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// TimeUnit is the unit of measuring time while aggregating the statistics.
<mask> // WriteDiskConfig - write configuration <mask> WriteDiskConfig(dc *DiskConfig) <mask> } <mask> <mask> // TimeUnit - time unit <mask> type TimeUnit int <mask> <mask> // Supported time units <mask> const ( <mask> Hours TimeUnit = iota </s> Pull request: 4358 fix stats Merge in DNS/adguard-home fr...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Supported TimeUnit values.
<mask> <mask> // TimeUnit - time unit <mask> type TimeUnit int <mask> <mask> // Supported time units <mask> const ( <mask> Hours TimeUnit = iota <mask> Days <mask> ) <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Result is the resulting code of processing the DNS request.
<mask> Hours TimeUnit = iota <mask> Days <mask> ) <mask> <mask> // Result of DNS request processing <mask> type Result int <mask> <mask> // Supported result values <mask> const ( <mask> RNotFiltered Result = iota + 1 </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to mas...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Supported Result values. // // TODO(e.burkov): Think about better naming.
<mask> <mask> // Result of DNS request processing <mask> type Result int <mask> <mask> // Supported result values <mask> const ( <mask> RNotFiltered Result = iota + 1 <mask> RFiltered <mask> RSafeBrowsing <mask> RSafeSearch </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stat...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
resultLast = RParental + 1
<mask> RFiltered <mask> RSafeBrowsing <mask> RSafeSearch <mask> RParental <mask> rLast <mask> ) <mask> <mask> // Entry is a statistics data entry. <mask> type Entry struct { <mask> // Clients is the client's primary ID. </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats t...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Domain is the domain name requested.
<mask> Client string <mask> <mask> Domain string <mask> <mask> // Result is the result of processing the request. <mask> Result Result <mask> </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commi...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Result is the result of processing the request.
<mask> <mask> // Domain is the domain name requested. <mask> Domain string <mask> Result Result <mask> <mask> // Time is the duration of the request processing in milliseconds. <mask> Time uint32 </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Up...
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Time is the duration of the request processing in milliseconds. Time uint32
<mask> Client string <mask> <mask> Domain string <mask> Result Result <mask> Time uint32 // processing time (msec) <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to master Updates #4358. Updates #4342. Squashed commit of the following: commit 5683cb304688ea639...
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
s, err := New(conf)
<mask> Filename: "./stats.db", <mask> LimitDays: 1, <mask> } <mask> <mask> s, err := createObject(conf) <mask> require.NoError(t, err) <mask> testutil.CleanupAndRequireSuccess(t, func() (err error) { <mask> s.clear() <mask> s.Close() <mask> </s> Pull request: 4358 fix stats Merge in DNS/adgua...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats_test.go
s, err := New(conf)
<mask> Filename: "./stats.db", <mask> LimitDays: 1, <mask> UnitID: newID, <mask> } <mask> s, err := createObject(conf) <mask> require.NoError(t, err) <mask> testutil.CleanupAndRequireSuccess(t, func() (err error) { <mask> s.Close() <mask> <mask> return os.Remove(conf.Filename) </s> Pull re...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats_test.go
"sync/atomic"
<mask> "net" <mask> "os" <mask> "sort" <mask> "sync" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log" </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-st...
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log" <mask> "go.etcd.io/bbolt" <mask> ) <mask> <mask> // TODO(a.garipov): Rewrite all of this. Add proper error handling and </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix...
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
"go.etcd.io/bbolt"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/errors" <mask> "github.com/AdguardTeam/golibs/log" <mask> bolt "go.etcd.io/bbolt" <mask> ) <mask> <mask> // TODO(a.garipov): Rewrite all of this. Add proper error handling and <mask> // inspection. Improve logging. Decrease complexity. <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// StatsCtx collects the statistics and flushes it to the database. Its default // flushing interval is one hour. // // TODO(e.burkov): Use atomic.Pointer for accessing curr and db in go1.19. type StatsCtx struct { // currMu protects the current unit. currMu *sync.Mutex // curr is the actual statistics collection ...
<mask> maxDomains = 100 // max number of top domains to store in file or return via Get() <mask> maxClients = 100 // max number of top clients to store in file or return via Get() <mask> ) <mask> <mask> // statsCtx - global context <mask> type statsCtx struct { <mask> // mu protects unit. <mask> mu *sync.M...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// filename is the name of database file. filename string // limitHours is the maximum number of hours to collect statistics into the // current unit. limitHours uint32
<mask> mu *sync.Mutex <mask> // current is the actual statistics collection result. <mask> current *unit <mask> <mask> db *bolt.DB <mask> conf *Config <mask> } <mask> <mask> // data for 1 time unit <mask> type unit struct { <mask> id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 </s...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// unit collects the statistics data for a specific period of time.
<mask> db *bolt.DB <mask> conf *Config <mask> } <mask> <mask> // data for 1 time unit <mask> type unit struct { <mask> id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 <mask> <mask> nTotal uint64 // total requests <mask> nResult []uint64 // number of requests per one result </s> Pu...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// mu protects all the fields of a unit. mu *sync.RWMutex // id is the unique unit's identifier. It's set to an absolute hour number // since the beginning of UNIX time by the default ID generating function. id uint32 // nTotal stores the total number of requests. nTotal uint64 // nResult stores the number o...
<mask> } <mask> <mask> // data for 1 time unit <mask> type unit struct { <mask> id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 <mask> <mask> nTotal uint64 // total requests <mask> nResult []uint64 // number of requests per one result <mask> timeSum uint64 // sum of processing time o...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// swapCurrent swaps the current unit with another and returns it. It's safe // for concurrent use. func (s *StatsCtx) swapCurrent(with *unit) (old *unit) { s.currMu.Lock() defer s.currMu.Unlock()
<mask> // data for 1 time unit <mask> type unit struct { <mask> id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 <mask> <mask> nTotal uint64 // total requests <mask> nResult []uint64 // number of requests per one result <mask> timeSum uint64 // sum of processing time of all requests (use...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
old, s.curr = s.curr, with return old
<mask> nTotal uint64 // total requests <mask> nResult []uint64 // number of requests per one result <mask> timeSum uint64 // sum of processing time of all requests (usec) <mask> <mask> // top: <mask> domains map[string]uint64 // number of requests per domain <mask> blockedDomains map[string]ui...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// database returns the database if it's opened. It's safe for concurrent use. func (s *StatsCtx) database() (db *bbolt.DB) { s.dbMu.Lock() defer s.dbMu.Unlock() return s.db } // swapDatabase swaps the database with another one and returns it. It's safe // for concurrent use. func (s *StatsCtx) swapDatabase(with...
<mask> blockedDomains map[string]uint64 // number of blocked requests per domain <mask> clients map[string]uint64 // number of requests per client <mask> } <mask> <mask> // name-count pair <mask> type countPair struct { <mask> Name string <mask> Count uint64 <mask> } <mask> </s> Pull request: 4...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// unitDB is the structure for deserializing statistics data into the database.
<mask> Name string <mask> Count uint64 <mask> } <mask> <mask> // structure for storing data in file <mask> type unitDB struct { <mask> NTotal uint64 <mask> NResult []uint64 <mask> <mask> Domains []countPair </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-fix-stats to ma...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind.
<mask> } <mask> <mask> // structure for storing data in file <mask> type unitDB struct { <mask> NTotal uint64 <mask> NResult []uint64 <mask> <mask> Domains []countPair <mask> BlockedDomains []countPair <mask> Clients []countPair </s> Pull request: 4358 fix stats Merge in DNS/adguard-ho...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name.
<mask> type unitDB struct { <mask> NTotal uint64 <mask> NResult []uint64 <mask> <mask> Domains []countPair <mask> BlockedDomains []countPair <mask> Clients []countPair <mask> <mask> TimeAvg uint32 // usec <mask> } </s> Pull request: 4358 fix stats Merge in DNS/adguard-home from 4358-f...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// Clients is the number of requests from each client. Clients []countPair
<mask> NResult []uint64 <mask> <mask> Domains []countPair <mask> BlockedDomains []countPair <mask> Clients []countPair <mask> <mask> TimeAvg uint32 // usec <mask> } <mask> <mask> // withRecovered turns the value recovered from panic if any into an error and </s> Pull request: 4358 fix s...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// TimeAvg is the average of processing times in milliseconds of all the // requests in the unit. TimeAvg uint32
<mask> Domains []countPair <mask> BlockedDomains []countPair <mask> Clients []countPair <mask> <mask> TimeAvg uint32 // usec <mask> } <mask> <mask> // withRecovered turns the value recovered from panic if any into an error and <mask> // combines it with the one pointed by orig. orig must b...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// isEnabled is a helper that check if the statistics collecting is enabled. func (s *StatsCtx) isEnabled() (ok bool) { return atomic.LoadUint32(&s.limitHours) != 0 } // New creates s from conf and properly initializes it. Don't use s before // calling it's Start method. func New(conf Config) (s *StatsCtx, err error...
<mask> <mask> *orig = errors.WithDeferred(*orig, err) <mask> } <mask> <mask> // createObject creates s from conf and properly initializes it. <mask> func createObject(conf Config) (s *statsCtx, err error) { <mask> defer withRecovered(&err) <mask> <mask> s = &statsCtx{ <mask> mu: &sync.Mutex{}, <mask>...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
s = &StatsCtx{ currMu: &sync.Mutex{}, dbMu: &sync.Mutex{}, filename: conf.Filename, configModified: conf.ConfigModified, httpRegister: conf.HTTPRegister,
<mask> // createObject creates s from conf and properly initializes it. <mask> func createObject(conf Config) (s *statsCtx, err error) { <mask> defer withRecovered(&err) <mask> <mask> s = &statsCtx{ <mask> mu: &sync.Mutex{}, <mask> } <mask> if !checkInterval(conf.LimitDays) { <mask> conf.LimitDays = 1...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24
<mask> <mask> s = &statsCtx{ <mask> mu: &sync.Mutex{}, <mask> } <mask> if !checkInterval(conf.LimitDays) { <mask> conf.LimitDays = 1 <mask> } <mask> <mask> s.conf = &Config{} <mask> *s.conf = conf <mask> s.conf.limit = conf.LimitDays * 24 </s> Pull request: 4358 fix stats Merge in DNS/adguard-...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID
<mask> } <mask> if !checkInterval(conf.LimitDays) { <mask> conf.LimitDays = 1 <mask> } <mask> <mask> s.conf = &Config{} <mask> *s.conf = conf <mask> s.conf.limit = conf.LimitDays * 24 <mask> if conf.UnitID == nil { <mask> s.conf.UnitID = newUnitID <mask> } <mask> <mask> if !s.dbOpen() { <ma...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err)
<mask> if conf.UnitID == nil { <mask> s.conf.UnitID = newUnitID <mask> } <mask> <mask> if !s.dbOpen() { <mask> return nil, fmt.Errorf("open database") <mask> } <mask> <mask> id := s.conf.UnitID() <mask> tx := s.beginTxn(true) <mask> var udb *unitDB </s> Pull request: 4358 fix stats Merge in DN...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
id := s.unitIDGen() tx := beginTxn(s.db, true)
<mask> if !s.dbOpen() { <mask> return nil, fmt.Errorf("open database") <mask> } <mask> <mask> id := s.conf.UnitID() <mask> tx := s.beginTxn(true) <mask> var udb *unitDB <mask> if tx != nil { <mask> log.Tracef("Deleting old units...") <mask> firstID := id - s.conf.limit - 1 <mask> unitDel := 0 ...
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
firstID := id - s.limitHours - 1
<mask> tx := s.beginTxn(true) <mask> var udb *unitDB <mask> if tx != nil { <mask> log.Tracef("Deleting old units...") <mask> firstID := id - s.conf.limit - 1 <mask> unitDel := 0 <mask> <mask> err = tx.ForEach(newBucketWalker(tx, &unitDel, firstID)) <mask> if err != nil && !errors.Is(err, errStop)...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u
<mask> } <mask> } <mask> } <mask> <mask> u := unit{} <mask> s.initUnit(&u, id) <mask> if udb != nil { <mask> deserialize(&u, udb) <mask> } <mask> s.current = &u <mask> <mask> log.Debug("stats: initialized") <mask> <mask> return s, nil <mask> } </s> Pull request: 4358 fix stats Merge i...
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
tx *bbolt.Tx,
<mask> // newBucketWalker returns a new bucket walker that deletes old units. The <mask> // integer that unitDelPtr points to is incremented for every successful <mask> // deletion. If the bucket isn't deleted, f returns errStop. <mask> func newBucketWalker( <mask> tx *bolt.Tx, <mask> unitDelPtr *int, <mask>...
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go