code_before
stringlengths
16
1.81M
edits
stringlengths
4
328k
next_edit
stringlengths
0
76.5k
code_after
stringlengths
3
49.9M
label_window
sequencelengths
4
1.81k
instruction
stringlengths
20
51.9k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
// See https://developer.apple.com/documentation/devicemanagement/dnssettings/dnssettings. d.ServerName = "" case dnsProtoTLS: dspName = fmt.Sprintf("%s DoT", d.ServerName) if d.clientID != "" { d.ServerName = d.clientID + "." + d.ServerName } default: return nil, fmt.Errorf("bad dns protocol %q", proto) }
</s> remove // // See https://developer.apple.com/documentation/devicemanagement/dnssettings/dnssettings. </s> add </s> remove data := mobileConfig{ PayloadContent: []payloadContent{{ Name: dspName, PayloadDescription: "Configures device to use AdGuard Home", PayloadDisplayName: dspName, PayloadIdentifier: fmt.Sprintf("com.apple.dnsSettings.managed.%s", genUUIDv4()), PayloadType: "com.apple.dnsSettings.managed", </s> add 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, </s> remove func getMobileConfig(d dnsSettings) ([]byte, error) { </s> add func encodeMobileConfig(d *dnsSettings, clientID string) ([]byte, error) { </s> remove Path: path.Join("/dns-query", d.clientID), </s> add Path: path.Join("/dns-query", clientID), </s> remove restartHTTP := true if config.BindHost.Equal(req.Web.IP) && config.BindPort == req.Web.Port { // no need to rebind restartHTTP = false } // validate that hosts and ports are bindable if restartHTTP { err = aghnet.CheckPortAvailable(req.Web.IP, req.Web.Port) if err != nil { httpError( w, http.StatusBadRequest, "can not listen on IP:port %s: %s", netutil.JoinHostPort(req.Web.IP.String(), req.Web.Port), err, ) return } } </s> add
if clientID != "" { d.ServerName = clientID + "." + d.ServerName
// See https://developer.apple.com/documentation/devicemanagement/dnssettings/dnssettings. d.ServerName = "" case dnsProtoTLS: dspName = fmt.Sprintf("%s DoT", d.ServerName) if clientID != "" { d.ServerName = clientID + "." + d.ServerName if clientID != "" { d.ServerName = clientID + "." + d.ServerName } default: return nil, fmt.Errorf("bad dns protocol %q", proto) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
default: return nil, fmt.Errorf("bad dns protocol %q", proto) } data := mobileConfig{ PayloadContent: []payloadContent{{ Name: dspName, PayloadDescription: "Configures device to use AdGuard Home", PayloadDisplayName: dspName, PayloadIdentifier: fmt.Sprintf("com.apple.dnsSettings.managed.%s", genUUIDv4()), PayloadType: "com.apple.dnsSettings.managed", PayloadUUID: genUUIDv4(), PayloadVersion: 1, DNSSettings: d, }}, PayloadDescription: "Adds AdGuard Home to Big Sur and iOS 14 or newer systems",
</s> remove PayloadDescription: "Adds AdGuard Home to Big Sur and iOS 14 or newer systems", PayloadDisplayName: dspName, PayloadIdentifier: genUUIDv4(), PayloadRemovalDisallowed: false, PayloadType: "Configuration", PayloadUUID: genUUIDv4(), </s> add </s> remove if d.clientID != "" { d.ServerName = d.clientID + "." + d.ServerName </s> add if clientID != "" { d.ServerName = clientID + "." + d.ServerName </s> remove err = configureOS(&config) </s> add err = configureOS(config)
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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID,
default: return nil, fmt.Errorf("bad dns protocol %q", proto) } 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, PayloadUUID: genUUIDv4(), PayloadVersion: 1, DNSSettings: d, }}, PayloadDescription: "Adds AdGuard Home to Big Sur and iOS 14 or newer systems",
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, PayloadUUID: genUUIDv4(), PayloadVersion: 1, DNSSettings: d, }}, PayloadVersion: 1, PayloadRemovalDisallowed: false,
</s> remove PayloadDescription: "Adds AdGuard Home to Big Sur and iOS 14 or newer systems", PayloadDisplayName: dspName, PayloadIdentifier: genUUIDv4(), PayloadRemovalDisallowed: false, PayloadType: "Configuration", PayloadUUID: genUUIDv4(), </s> add </s> remove data := mobileConfig{ PayloadContent: []payloadContent{{ Name: dspName, PayloadDescription: "Configures device to use AdGuard Home", PayloadDisplayName: dspName, PayloadIdentifier: fmt.Sprintf("com.apple.dnsSettings.managed.%s", genUUIDv4()), PayloadType: "com.apple.dnsSettings.managed", </s> add 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, </s> remove assert.Equal(t, "cli42.example.org", mc.PayloadContent[0].DNSSettings.ServerName) </s> add 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)
PayloadDisplayName: dspName, PayloadDescription: "Configures device to use AdGuard Home",
PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, PayloadUUID: genUUIDv4(), PayloadDisplayName: dspName, PayloadDescription: "Configures device to use AdGuard Home", PayloadVersion: 1, DNSSettings: d, }}, PayloadVersion: 1, PayloadRemovalDisallowed: false,
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
PayloadUUID: genUUIDv4(), PayloadVersion: 1, DNSSettings: d, }}, PayloadDescription: "Adds AdGuard Home to Big Sur and iOS 14 or newer systems", PayloadDisplayName: dspName, PayloadIdentifier: genUUIDv4(), PayloadRemovalDisallowed: false, PayloadType: "Configuration", PayloadUUID: genUUIDv4(), PayloadVersion: 1, } return plist.MarshalIndent(data, plist.XMLFormat, "\t") }
</s> remove data := mobileConfig{ PayloadContent: []payloadContent{{ Name: dspName, PayloadDescription: "Configures device to use AdGuard Home", PayloadDisplayName: dspName, PayloadIdentifier: fmt.Sprintf("com.apple.dnsSettings.managed.%s", genUUIDv4()), PayloadType: "com.apple.dnsSettings.managed", </s> add 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, </s> remove restartHTTP := true if config.BindHost.Equal(req.Web.IP) && config.BindPort == req.Web.Port { // no need to rebind restartHTTP = false } // validate that hosts and ports are bindable if restartHTTP { err = aghnet.CheckPortAvailable(req.Web.IP, req.Web.Port) if err != nil { httpError( w, http.StatusBadRequest, "can not listen on IP:port %s: %s", netutil.JoinHostPort(req.Web.IP.String(), req.Web.Port), err, ) return } } </s> add </s> remove // Duration marshalling and unmarshalling cases. </s> add // Duration marshalling and unmarshaling cases.
PayloadUUID: genUUIDv4(), PayloadVersion: 1, DNSSettings: d, }}, PayloadVersion: 1, } return plist.MarshalIndent(data, plist.XMLFormat, "\t") }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
DNSSettings: d, }}, PayloadVersion: 1, } return plist.MarshalIndent(data, plist.XMLFormat, "\t") } func respondJSONError(w http.ResponseWriter, status int, msg string) {
</s> remove PayloadDescription: "Adds AdGuard Home to Big Sur and iOS 14 or newer systems", PayloadDisplayName: dspName, PayloadIdentifier: genUUIDv4(), PayloadRemovalDisallowed: false, PayloadType: "Configuration", PayloadUUID: genUUIDv4(), </s> add </s> remove data := mobileConfig{ PayloadContent: []payloadContent{{ Name: dspName, PayloadDescription: "Configures device to use AdGuard Home", PayloadDisplayName: dspName, PayloadIdentifier: fmt.Sprintf("com.apple.dnsSettings.managed.%s", genUUIDv4()), PayloadType: "com.apple.dnsSettings.managed", </s> add 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: genUUIDv4(), PayloadContent: []*payloadContent{{ PayloadType: dnsSettingsPayloadType, PayloadIdentifier: payloadID, </s> remove httpError(w, http.StatusBadRequest, "Failed to parse 'configure' JSON: %s", err) return } </s> add httpError(w, http.StatusBadRequest, "%s", err)
PayloadRemovalDisallowed: false,
DNSSettings: d, }}, PayloadVersion: 1, PayloadRemovalDisallowed: false, } return plist.MarshalIndent(data, plist.XMLFormat, "\t") } func respondJSONError(w http.ResponseWriter, status int, msg string) {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
return } } d := dnsSettings{ DNSProtocol: dnsp, ServerName: host, clientID: clientID, } mobileconfig, err := getMobileConfig(d) if err != nil { respondJSONError(w, http.StatusInternalServerError, err.Error())
</s> remove mobileconfig, err := getMobileConfig(d) </s> add mobileconfig, err := encodeMobileConfig(d, clientID) </s> remove copyInstallSettings(&config, &curConfig) </s> add copyInstallSettings(config, curConfig) </s> remove copyInstallSettings(&config, &curConfig) </s> add copyInstallSettings(config, curConfig) </s> remove restartHTTP := true if config.BindHost.Equal(req.Web.IP) && config.BindPort == req.Web.Port { // no need to rebind restartHTTP = false } // validate that hosts and ports are bindable if restartHTTP { err = aghnet.CheckPortAvailable(req.Web.IP, req.Web.Port) if err != nil { httpError( w, http.StatusBadRequest, "can not listen on IP:port %s: %s", netutil.JoinHostPort(req.Web.IP.String(), req.Web.Port), err, ) return } } </s> add </s> remove req := applyConfigReq{} err := json.NewDecoder(r.Body).Decode(&req) </s> add req, restartHTTP, err := decodeApplyConfigReq(r.Body)
d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: cloneBootstrap(),
return } } d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: cloneBootstrap(), d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: cloneBootstrap(), d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: cloneBootstrap(), d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: cloneBootstrap(), } mobileconfig, err := getMobileConfig(d) if err != nil { respondJSONError(w, http.StatusInternalServerError, err.Error())
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
ServerName: host, clientID: clientID, } mobileconfig, err := getMobileConfig(d) if err != nil { respondJSONError(w, http.StatusInternalServerError, err.Error()) return }
</s> remove d := dnsSettings{ DNSProtocol: dnsp, ServerName: host, clientID: clientID, </s> add d := &dnsSettings{ DNSProtocol: dnsp, ServerName: host, ServerAddresses: cloneBootstrap(), </s> remove copyInstallSettings(&config, &curConfig) </s> add copyInstallSettings(config, curConfig) </s> remove copyInstallSettings(&config, &curConfig) </s> add copyInstallSettings(config, curConfig) </s> remove restartHTTP := true if config.BindHost.Equal(req.Web.IP) && config.BindPort == req.Web.Port { // no need to rebind restartHTTP = false } // validate that hosts and ports are bindable if restartHTTP { err = aghnet.CheckPortAvailable(req.Web.IP, req.Web.Port) if err != nil { httpError( w, http.StatusBadRequest, "can not listen on IP:port %s: %s", netutil.JoinHostPort(req.Web.IP.String(), req.Web.Port), err, ) return } } </s> add </s> remove req := applyConfigReq{} err := json.NewDecoder(r.Body).Decode(&req) </s> add req, restartHTTP, err := decodeApplyConfigReq(r.Body)
mobileconfig, err := encodeMobileConfig(d, clientID)
ServerName: host, clientID: clientID, } mobileconfig, err := encodeMobileConfig(d, clientID) if err != nil { respondJSONError(w, http.StatusInternalServerError, err.Error()) return }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
_, _ = w.Write(mobileconfig) } func handleMobileConfigDoH(w http.ResponseWriter, r *http.Request) { handleMobileConfig(w, r, dnsProtoHTTPS) } func handleMobileConfigDoT(w http.ResponseWriter, r *http.Request) {
</s> remove req := applyConfigReq{} err := json.NewDecoder(r.Body).Decode(&req) </s> add req, restartHTTP, err := decodeApplyConfigReq(r.Body) </s> remove httpError(w, http.StatusBadRequest, "Failed to parse 'configure' JSON: %s", err) return } </s> add httpError(w, http.StatusBadRequest, "%s", err)
// 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) }
_, _ = w.Write(mobileconfig) } // 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) } func handleMobileConfigDoH(w http.ResponseWriter, r *http.Request) { handleMobileConfig(w, r, dnsProtoHTTPS) } func handleMobileConfigDoT(w http.ResponseWriter, r *http.Request) {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig.go
"net/http/httptest" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "howett.net/plist" )
</s> remove "github.com/AdguardTeam/golibs/netutil" </s> add </s> remove func getMobileConfig(d dnsSettings) ([]byte, error) { </s> add func encodeMobileConfig(d *dnsSettings, clientID string) ([]byte, error) {
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
"net/http/httptest" "testing" "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "howett.net/plist" )
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
} } func TestHandleMobileConfigDoH(t *testing.T) { t.Run("success", func(t *testing.T) { r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/doh.mobileconfig?host=example.org", nil) require.NoError(t, err)
</s> remove assert.Equal(t, "https://example.org/dns-query/cli42", mc.PayloadContent[0].DNSSettings.ServerURL) </s> add 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) </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add
setupBootstraps(t)
} } func TestHandleMobileConfigDoH(t *testing.T) { setupBootstraps(t) t.Run("success", func(t *testing.T) { r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/doh.mobileconfig?host=example.org", nil) require.NoError(t, err)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
_, err = plist.Unmarshal(w.Body.Bytes(), &mc) require.NoError(t, err) require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "https://example.org/dns-query", mc.PayloadContent[0].DNSSettings.ServerURL) }) t.Run("error_no_host", func(t *testing.T) {
</s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "https://example.org/dns-query", mc.PayloadContent[0].DNSSettings.ServerURL) </s> add 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) </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "https://example.org/dns-query/cli42", mc.PayloadContent[0].DNSSettings.ServerURL) </s> add 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)
_, err = plist.Unmarshal(w.Body.Bytes(), &mc) require.NoError(t, err) require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "https://example.org/dns-query", mc.PayloadContent[0].DNSSettings.ServerURL) }) t.Run("error_no_host", func(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "https://example.org/dns-query", mc.PayloadContent[0].DNSSettings.ServerURL) }) t.Run("error_no_host", func(t *testing.T) { oldTLSConf := Context.tls t.Cleanup(func() { Context.tls = oldTLSConf })
</s> remove assert.Equal(t, "example.org", mc.PayloadContent[0].DNSSettings.ServerName) </s> add 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) </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "https://example.org/dns-query/cli42", mc.PayloadContent[0].DNSSettings.ServerURL) </s> add 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) </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add
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)
require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) 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) }) t.Run("error_no_host", func(t *testing.T) { oldTLSConf := Context.tls t.Cleanup(func() { Context.tls = oldTLSConf })
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
_, err = plist.Unmarshal(w.Body.Bytes(), &mc) require.NoError(t, err) require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "https://example.org/dns-query/cli42", mc.PayloadContent[0].DNSSettings.ServerURL) }) }
</s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "https://example.org/dns-query/cli42", mc.PayloadContent[0].DNSSettings.ServerURL) </s> add 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) </s> remove assert.Equal(t, "https://example.org/dns-query", mc.PayloadContent[0].DNSSettings.ServerURL) </s> add 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)
_, err = plist.Unmarshal(w.Body.Bytes(), &mc) require.NoError(t, err) require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "https://example.org/dns-query/cli42", mc.PayloadContent[0].DNSSettings.ServerURL) }) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "https://example.org/dns-query/cli42", mc.PayloadContent[0].DNSSettings.ServerURL) }) } func TestHandleMobileConfigDoT(t *testing.T) { t.Run("success", func(t *testing.T) {
</s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "https://example.org/dns-query", mc.PayloadContent[0].DNSSettings.ServerURL) </s> add 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) </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org", mc.PayloadContent[0].DNSSettings.ServerName) </s> add 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)
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)
require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoH", mc.PayloadContent[0].PayloadDisplayName) 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) }) } func TestHandleMobileConfigDoT(t *testing.T) { t.Run("success", func(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
} func TestHandleMobileConfigDoT(t *testing.T) { t.Run("success", func(t *testing.T) { r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/dot.mobileconfig?host=example.org", nil) require.NoError(t, err)
</s> remove assert.Equal(t, "https://example.org/dns-query/cli42", mc.PayloadContent[0].DNSSettings.ServerURL) </s> add 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) </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add
setupBootstraps(t)
} func TestHandleMobileConfigDoT(t *testing.T) { setupBootstraps(t) t.Run("success", func(t *testing.T) { r, err := http.NewRequest(http.MethodGet, "https://example.com:12345/apple/dot.mobileconfig?host=example.org", nil) require.NoError(t, err)
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
_, err = plist.Unmarshal(w.Body.Bytes(), &mc) require.NoError(t, err) require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "example.org", mc.PayloadContent[0].DNSSettings.ServerName) }) t.Run("error_no_host", func(t *testing.T) {
</s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org", mc.PayloadContent[0].DNSSettings.ServerName) </s> add 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) </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "cli42.example.org", mc.PayloadContent[0].DNSSettings.ServerName) </s> add 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)
_, err = plist.Unmarshal(w.Body.Bytes(), &mc) require.NoError(t, err) require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "example.org", mc.PayloadContent[0].DNSSettings.ServerName) }) t.Run("error_no_host", func(t *testing.T) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "example.org", mc.PayloadContent[0].DNSSettings.ServerName) }) t.Run("error_no_host", func(t *testing.T) { oldTLSConf := Context.tls t.Cleanup(func() { Context.tls = oldTLSConf })
</s> remove assert.Equal(t, "https://example.org/dns-query", mc.PayloadContent[0].DNSSettings.ServerURL) </s> add 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) </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "cli42.example.org", mc.PayloadContent[0].DNSSettings.ServerName) </s> add 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) </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add
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)
require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) 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) }) t.Run("error_no_host", func(t *testing.T) { oldTLSConf := Context.tls t.Cleanup(func() { Context.tls = oldTLSConf })
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
_, err = plist.Unmarshal(w.Body.Bytes(), &mc) require.NoError(t, err) require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "cli42.example.org", mc.PayloadContent[0].DNSSettings.ServerName) }) }
</s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "cli42.example.org", mc.PayloadContent[0].DNSSettings.ServerName) </s> add 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) </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org", mc.PayloadContent[0].DNSSettings.ServerName) </s> add 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)
_, err = plist.Unmarshal(w.Body.Bytes(), &mc) require.NoError(t, err) require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "cli42.example.org", mc.PayloadContent[0].DNSSettings.ServerName) }) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) assert.Equal(t, "cli42.example.org", mc.PayloadContent[0].DNSSettings.ServerName) }) }
</s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org", mc.PayloadContent[0].DNSSettings.ServerName) </s> add 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) </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add </s> remove assert.Equal(t, "example.org DoH", mc.PayloadContent[0].Name) </s> add
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)
require.Len(t, mc.PayloadContent, 1) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].Name) assert.Equal(t, "example.org DoT", mc.PayloadContent[0].PayloadDisplayName) 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) }) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep" ]
Pull request: home: add bootstrap to mobileconfig, imp code Updates #3568. Squashed commit of the following: commit ec342e6223e2b2efe9a8bf833d5406a44c6417e4 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 15:16:07 2021 +0300 home: imp tests commit 67cd771e631938d3e8a5340315314210de796174 Author: Ainar Garipov <[email protected]> Date: Mon Sep 13 14:34:03 2021 +0300 home: add bootstrap to mobileconfig, imp code
https://github.com/AdguardTeam/AdGuardHome/commit/424f20da985b043ce4a6c5b5830d3e414e832196
internal/home/mobileconfig_test.go
) // OK responds with word OK. func OK(w http.ResponseWriter) { if _, err := io.WriteString(w, "OK\n"); err != nil { log.Error("couldn't write body: %s", err)
</s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err) </s> remove log.Tracef("db.Begin...") tx, err := db.Begin(wr) </s> add log.Tracef("opening a database transaction") tx, err := db.Begin(writable) </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> remove log.Tracef("db.Begin") </s> add log.Tracef("transaction has been opened")
// 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)
) // 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) // OK responds with word OK. func OK(w http.ResponseWriter) { if _, err := io.WriteString(w, "OK\n"); err != nil { log.Error("couldn't write body: %s", err)
[ "keep", "add", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/aghhttp/aghhttp.go
import ( "encoding/json" "fmt" "net" "net/http" "path/filepath" "runtime" "time" "github.com/AdguardTeam/golibs/log"
</s> remove "net/http" </s> add </s> remove "net/http" </s> add </s> remove "net/http" </s> add </s> remove "net/http" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
import ( "encoding/json" "fmt" "net" "path/filepath" "runtime" "time" "github.com/AdguardTeam/golibs/log"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dhcpd/dhcpd.go
"runtime" "time" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" )
</s> remove "net/http" </s> add </s> remove bolt "go.etcd.io/bbolt" </s> add "go.etcd.io/bbolt"
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"runtime" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" )
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dhcpd/dhcpd.go
// Called when the configuration is changed by HTTP request ConfigModified func() `yaml:"-"` // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` Enabled bool `yaml:"enabled"` InterfaceName string `yaml:"interface_name"` // LocalDomainName is the domain name used for DHCP hosts. For example,
</s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add HTTPRegister aghhttp.RegisterFunc </s> remove // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc </s> remove // Called when the configuration is changed by HTTP request </s> add // ConfigModified will be called each time the configuration changed via web // interface. </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add HTTPRegister aghhttp.RegisterFunc
HTTPRegister aghhttp.RegisterFunc `yaml:"-"`
// Called when the configuration is changed by HTTP request ConfigModified func() `yaml:"-"` // Register an HTTP handler HTTPRegister aghhttp.RegisterFunc `yaml:"-"` Enabled bool `yaml:"enabled"` InterfaceName string `yaml:"interface_name"` // LocalDomainName is the domain name used for DHCP hosts. For example,
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dhcpd/dhcpd.go
"crypto/tls" "crypto/x509" "fmt" "net" "net/http" "os" "sort" "strings" "time"
</s> remove "net/http" </s> add </s> remove "net/http" </s> add </s> remove "net/http" </s> add
"crypto/tls" "crypto/x509" "fmt" "net" "os" "sort" "strings" "time"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/config.go
"time" "github.com/AdguardTeam/AdGuardHome/internal/aghtls" "github.com/AdguardTeam/AdGuardHome/internal/filtering" "github.com/AdguardTeam/dnsproxy/proxy" "github.com/AdguardTeam/dnsproxy/upstream" "github.com/AdguardTeam/golibs/errors"
</s> remove "net/http" </s> add
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghtls" "github.com/AdguardTeam/AdGuardHome/internal/filtering" "github.com/AdguardTeam/dnsproxy/proxy" "github.com/AdguardTeam/dnsproxy/upstream" "github.com/AdguardTeam/golibs/errors"
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/config.go
// Called when the configuration is changed by HTTP request ConfigModified func() // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) // ResolveClients signals if the RDNS should resolve clients' addresses. ResolveClients bool // UsePrivateRDNS defines if the PTR requests for unknown addresses from
</s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc </s> remove // Called when the configuration is changed by HTTP request </s> add // ConfigModified will be called each time the configuration changed via web // interface. </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add HTTPRegister aghhttp.RegisterFunc
HTTPRegister aghhttp.RegisterFunc
// Called when the configuration is changed by HTTP request ConfigModified func() // Register an HTTP handler HTTPRegister aghhttp.RegisterFunc // ResolveClients signals if the RDNS should resolve clients' addresses. ResolveClients bool // UsePrivateRDNS defines if the PTR requests for unknown addresses from
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/config.go
dnsProxy *proxy.Proxy // DNS proxy instance dnsFilter *filtering.DNSFilter // DNS filter instance dhcpServer dhcpd.ServerInterface // DHCP server instance (optional) queryLog querylog.QueryLog // Query log instance stats stats.Stats access *accessCtx // localDomainSuffix is the suffix used to detect internal hosts. It // must be a valid domain name plus dots on each side. localDomainSuffix string
</s> remove stats stats.Stats // statistics module </s> add stats stats.Interface // statistics module </s> remove // 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. </s> add // 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. </s> remove Stats stats.Stats </s> add Stats stats.Interface </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"`
stats stats.Interface
dnsProxy *proxy.Proxy // DNS proxy instance dnsFilter *filtering.DNSFilter // DNS filter instance dhcpServer dhcpd.ServerInterface // DHCP server instance (optional) queryLog querylog.QueryLog // Query log instance stats stats.Interface access *accessCtx // localDomainSuffix is the suffix used to detect internal hosts. It // must be a valid domain name plus dots on each side. localDomainSuffix string
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/dnsforward.go
// DNSCreateParams are parameters to create a new server. type DNSCreateParams struct { DNSFilter *filtering.DNSFilter Stats stats.Stats QueryLog querylog.QueryLog DHCPServer dhcpd.ServerInterface PrivateNets netutil.SubnetSet Anonymizer *aghnet.IPMut LocalDomain string
</s> remove stats stats.Stats </s> add stats stats.Interface </s> remove stats.Stats </s> add stats.Interface </s> remove Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) </s> add // Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"` </s> remove // New - create object func New(conf Config) (Stats, error) { return createObject(conf) </s> add // LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32 </s> remove stats stats.Stats // statistics module </s> add stats stats.Interface // statistics module
Stats stats.Interface
// DNSCreateParams are parameters to create a new server. type DNSCreateParams struct { DNSFilter *filtering.DNSFilter Stats stats.Interface QueryLog querylog.QueryLog DHCPServer dhcpd.ServerInterface PrivateNets netutil.SubnetSet Anonymizer *aghnet.IPMut LocalDomain string
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/dnsforward.go
// testStats is a simple stats.Stats implementation for tests. type testStats struct { // Stats is embedded here simply to make testStats a stats.Stats without // actually implementing all methods. stats.Stats lastEntry stats.Entry } // Update implements the stats.Stats interface for *testStats.
</s> remove Stats stats.Stats </s> add Stats stats.Interface </s> remove stats stats.Stats </s> add stats stats.Interface </s> remove // Close object. // This function is not thread safe // (can't be called in parallel with any other function of this interface). </s> add // Close stops the statistics collecting. </s> remove // New - create object func New(conf Config) (Stats, error) { return createObject(conf) </s> add // LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32 </s> remove // Stats - main interface type Stats interface { </s> add // Interface is the statistics interface to be used by other packages. type Interface interface { // Start begins the statistics collecting.
stats.Interface
// testStats is a simple stats.Stats implementation for tests. type testStats struct { // Stats is embedded here simply to make testStats a stats.Stats without // actually implementing all methods. stats.Interface lastEntry stats.Entry } // Update implements the stats.Stats interface for *testStats.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/dnsforward/stats_test.go
"context" "fmt" "io/fs" "net" "net/http" "os" "runtime" "runtime/debug" "strings" "sync"
</s> remove "net/http" </s> add </s> remove "net/http" </s> add
"context" "fmt" "io/fs" "net" "os" "runtime" "runtime/debug" "strings" "sync"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/filtering/filtering.go
"strings" "sync" "sync/atomic" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/dnsproxy/upstream" "github.com/AdguardTeam/golibs/cache" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log"
</s> remove "net/http" </s> add
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"strings" "sync" "sync/atomic" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/dnsproxy/upstream" "github.com/AdguardTeam/golibs/cache" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/filtering/filtering.go
// Called when the configuration is changed by HTTP request ConfigModified func() `yaml:"-"` // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` // CustomResolver is the resolver used by DNSFilter. CustomResolver Resolver `yaml:"-"` }
</s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add HTTPRegister aghhttp.RegisterFunc </s> remove // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc </s> remove // Called when the configuration is changed by HTTP request </s> add // ConfigModified will be called each time the configuration changed via web // interface. </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add HTTPRegister aghhttp.RegisterFunc
HTTPRegister aghhttp.RegisterFunc `yaml:"-"`
// Called when the configuration is changed by HTTP request ConfigModified func() `yaml:"-"` // Register an HTTP handler HTTPRegister aghhttp.RegisterFunc `yaml:"-"` // CustomResolver is the resolver used by DNSFilter. CustomResolver Resolver `yaml:"-"` }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/filtering/filtering.go
package home import ( "bytes" "fmt" "net" "sort" "strings" "sync"
</s> remove "net/http" </s> add </s> remove "net/http" </s> add </s> remove "net/http" </s> add </s> remove "net/http" </s> add </s> remove "net/http" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"encoding"
package home import ( "bytes" "encoding" "fmt" "net" "sort" "strings" "sync"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clients.go
type runtimeClientJSON struct { WHOISInfo *RuntimeClientWHOISInfo `json:"whois_info"` Name string `json:"name"` Source string `json:"source"` IP net.IP `json:"ip"` } type clientListJSON struct { Clients []*clientJSON `json:"clients"` RuntimeClients []runtimeClientJSON `json:"auto_clients"`
</s> remove // structure for storing data in file </s> add // unitDB is the structure for deserializing statistics data into the database. </s> remove Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) </s> add // Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"` </s> remove Stats stats.Stats </s> add Stats stats.Interface </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting. </s> remove // top: 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 </s> add old, s.curr = s.curr, with return old
Name string `json:"name"` Source clientSource `json:"source"` IP net.IP `json:"ip"`
type runtimeClientJSON struct { WHOISInfo *RuntimeClientWHOISInfo `json:"whois_info"` Name string `json:"name"` Source clientSource `json:"source"` IP net.IP `json:"ip"` Name string `json:"name"` Source clientSource `json:"source"` IP net.IP `json:"ip"` Name string `json:"name"` Source clientSource `json:"source"` IP net.IP `json:"ip"` } type clientListJSON struct { Clients []*clientJSON `json:"clients"` RuntimeClients []runtimeClientJSON `json:"auto_clients"`
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clientshttp.go
cj := runtimeClientJSON{ WHOISInfo: rc.WHOISInfo, Name: rc.Host, IP: ip, } cj.Source = "etc/hosts" switch rc.Source { case ClientSourceDHCP: cj.Source = "DHCP" case ClientSourceRDNS: cj.Source = "rDNS" case ClientSourceARP: cj.Source = "ARP" case ClientSourceWHOIS: cj.Source = "WHOIS" } data.RuntimeClients = append(data.RuntimeClients, cj) return true
</s> remove if s.conf.limit == 0 { resp = statsResponse{ TimeUnits: "days", TopBlocked: []topAddrs{}, TopClients: []topAddrs{}, TopQueried: []topAddrs{}, BlockedFiltering: []uint64{}, DNSQueries: []uint64{}, ReplacedParental: []uint64{}, ReplacedSafebrowsing: []uint64{}, } } else { var ok bool resp, ok = s.getData() log.Debug("stats: prepared data in %v", time.Since(start)) if !ok { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get statistics data") return } </s> add 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 </s> remove // Atomically swap the currently active unit with a new value // Return old value func (s *statsCtx) swapUnit(new *unit) (u *unit) { s.mu.Lock() defer s.mu.Unlock() </s> add return err } </s> remove s.conf = &Config{} *s.conf = conf s.conf.limit = conf.LimitDays * 24 if conf.UnitID == nil { s.conf.UnitID = newUnitID </s> add if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB { </s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB { </s> remove func convertTopSlice(a []countPair) []map[string]uint64 { m := []map[string]uint64{} </s> add func convertTopSlice(a []countPair) (m []map[string]uint64) { m = make([]map[string]uint64, 0, len(a))
Name: rc.Host, Source: rc.Source, IP: ip,
cj := runtimeClientJSON{ WHOISInfo: rc.WHOISInfo, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, Name: rc.Host, Source: rc.Source, IP: ip, } data.RuntimeClients = append(data.RuntimeClients, cj) return true
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clientshttp.go
w.Header().Set("Content-Type", "application/json") e := json.NewEncoder(w).Encode(data) if e != nil { aghhttp.Error( r, w, http.StatusInternalServerError, "Failed to encode to json: %v", e, ) return } }
</s> remove if s.conf.limit == 0 { resp = statsResponse{ TimeUnits: "days", TopBlocked: []topAddrs{}, TopClients: []topAddrs{}, TopQueried: []topAddrs{}, BlockedFiltering: []uint64{}, DNSQueries: []uint64{}, ReplacedParental: []uint64{}, ReplacedSafebrowsing: []uint64{}, } } else { var ok bool resp, ok = s.getData() log.Debug("stats: prepared data in %v", time.Since(start)) if !ok { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get statistics data") return } </s> add 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 </s> remove resp.IntervalDays = s.conf.limit / 24 </s> add resp.IntervalDays = s.limitHours / 24 </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) commitTxn(tx *bolt.Tx) { </s> add // commitTxn applies the changes made in tx to the database. func (s *StatsCtx) commitTxn(tx *bbolt.Tx) { </s> remove func serialize(u *unit) *unitDB { udb := unitDB{} udb.NTotal = u.nTotal udb.NResult = append(udb.NResult, u.nResult...) </s> add // serialize converts u to the *unitDB. It's safe for concurrent use. func (u *unit) serialize() (udb *unitDB) { u.mu.RLock() defer u.mu.RUnlock()
aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e)
w.Header().Set("Content-Type", "application/json") e := json.NewEncoder(w).Encode(data) if e != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e) aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e) aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e) aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e) aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e) aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e) aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e) return } }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clientshttp.go
// non-nil. func (clients *clientsContainer) findRuntime(ip net.IP, idStr string) (cj *clientJSON) { rc, ok := clients.FindRuntimeClient(ip) if !ok { // 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. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2428. disallowed, rule := clients.dnsServer.IsBlockedClient(ip, idStr) cj = &clientJSON{ IDs: []string{idStr},
</s> remove stats stats.Stats </s> add stats stats.Interface </s> remove // Get IP addresses of the clients with the most number of requests </s> add // GetTopClientIP returns at most limit IP addresses corresponding to the // clients with the most number of requests. </s> remove // Update counters </s> add // Update collects the incoming statistics data. </s> remove // Stats - main interface type Stats interface { </s> add // Interface is the statistics interface to be used by other packages. type Interface interface { // Start begins the statistics collecting. </s> remove // WriteDiskConfig - write configuration </s> add // WriteDiskConfig puts the Interface's configuration to the dc.
// 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.
// non-nil. func (clients *clientsContainer) findRuntime(ip net.IP, idStr string) (cj *clientJSON) { rc, ok := clients.FindRuntimeClient(ip) if !ok { // 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. // 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. // 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. // // See https://github.com/AdguardTeam/AdGuardHome/issues/2428. disallowed, rule := clients.dnsServer.IsBlockedClient(ip, idStr) cj = &clientJSON{ IDs: []string{idStr},
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/clientshttp.go
Context.mux.HandleFunc("/apple/dot.mobileconfig", postInstall(handleMobileConfigDoT)) RegisterAuthHandlers() } func httpRegister(method, url string, handler func(http.ResponseWriter, *http.Request)) { if method == "" { // "/dns-query" handler doesn't need auth, gzip and isn't restricted by 1 HTTP method Context.mux.HandleFunc(url, postInstall(handler)) return }
</s> remove limit uint32 // maximum time we need to keep data for (in hours) } </s> add // Filename is the name of the database file. Filename string </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add HTTPRegister aghhttp.RegisterFunc
func httpRegister(method, url string, handler http.HandlerFunc) {
Context.mux.HandleFunc("/apple/dot.mobileconfig", postInstall(handleMobileConfigDoT)) RegisterAuthHandlers() } func httpRegister(method, url string, handler http.HandlerFunc) { if method == "" { // "/dns-query" handler doesn't need auth, gzip and isn't restricted by 1 HTTP method Context.mux.HandleFunc(url, postInstall(handler)) return }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/control.go
// Modules // -- clients clientsContainer // per-client-settings module stats stats.Stats // statistics module queryLog querylog.QueryLog // query log module dnsServer *dnsforward.Server // DNS module rdns *RDNS // rDNS module whois *WHOIS // WHOIS module dnsFilter *filtering.DNSFilter // DNS filtering module
</s> remove stats stats.Stats </s> add stats stats.Interface </s> remove // DiskConfig - configuration settings that are stored on disk </s> add // DiskConfig is the configuration structure that is stored in file. </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting. </s> remove Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) </s> add // Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"` </s> remove Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. </s> add // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc
stats stats.Interface // statistics module
// Modules // -- clients clientsContainer // per-client-settings module stats stats.Interface // statistics module queryLog querylog.QueryLog // query log module dnsServer *dnsforward.Server // DNS module rdns *RDNS // rDNS module whois *WHOIS // WHOIS module dnsFilter *filtering.DNSFilter // DNS filtering module
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/home/home.go
package querylog import ( "net" "net/http" "path/filepath" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/filtering"
</s> remove "net/http" </s> add </s> remove "net/http" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> remove "net/http" </s> add
package querylog import ( "net" "path/filepath" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/filtering"
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/querylog/querylog.go
"time" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/filtering" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/timeutil" "github.com/miekg/dns"
</s> remove "net/http" </s> add
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/filtering" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/timeutil" "github.com/miekg/dns"
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/querylog/querylog.go
// example by HTTP requests. ConfigModified func() // HTTPRegister registers an HTTP handler. HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) // FindClient returns client information by their IDs. FindClient func(ids []string) (c *Client, err error) // BaseDir is the base directory for log files.
</s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add HTTPRegister aghhttp.RegisterFunc </s> remove // Called when the configuration is changed by HTTP request </s> add // ConfigModified will be called each time the configuration changed via web // interface.
HTTPRegister aghhttp.RegisterFunc
// example by HTTP requests. ConfigModified func() // HTTPRegister registers an HTTP handler. HTTPRegister aghhttp.RegisterFunc // FindClient returns client information by their IDs. FindClient func(ids []string) (c *Client, err error) // BaseDir is the base directory for log files.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/querylog/querylog.go
ReplacedParental []uint64 `json:"replaced_parental"` } // handleStats is a handler for getting statistics. func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { start := time.Now() var resp statsResponse if s.conf.limit == 0 { resp = statsResponse{
</s> remove if s.conf.limit == 0 { resp = statsResponse{ TimeUnits: "days", TopBlocked: []topAddrs{}, TopClients: []topAddrs{}, TopQueried: []topAddrs{}, BlockedFiltering: []uint64{}, DNSQueries: []uint64{}, ReplacedParental: []uint64{}, ReplacedSafebrowsing: []uint64{}, } } else { var ok bool resp, ok = s.getData() log.Debug("stats: prepared data in %v", time.Since(start)) if !ok { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get statistics data") return } </s> add 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 </s> remove func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> remove resp.IntervalDays = s.conf.limit / 24 </s> add resp.IntervalDays = s.limitHours / 24 </s> remove func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) {
ReplacedParental []uint64 `json:"replaced_parental"` } // handleStats is a handler for getting statistics. func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) { start := time.Now() var resp statsResponse if s.conf.limit == 0 { resp = statsResponse{
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { start := time.Now() var resp statsResponse if s.conf.limit == 0 { resp = statsResponse{ TimeUnits: "days", TopBlocked: []topAddrs{}, TopClients: []topAddrs{}, TopQueried: []topAddrs{}, BlockedFiltering: []uint64{}, DNSQueries: []uint64{}, ReplacedParental: []uint64{}, ReplacedSafebrowsing: []uint64{}, } } else { var ok bool resp, ok = s.getData() log.Debug("stats: prepared data in %v", time.Since(start)) if !ok { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get statistics data") return } } w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(resp)
</s> remove func (s *statsCtx) getData() (statsResponse, bool) { limit := s.conf.limit </s> add func (s *StatsCtx) getData() (statsResponse, bool) { limit := atomic.LoadUint32(&s.limitHours) if limit == 0 { return statsResponse{ TimeUnits: "days", TopBlocked: []topAddrs{}, TopClients: []topAddrs{}, TopQueried: []topAddrs{}, BlockedFiltering: []uint64{}, DNSQueries: []uint64{}, ReplacedParental: []uint64{}, ReplacedSafebrowsing: []uint64{}, }, true } </s> remove func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> remove resp.IntervalDays = s.conf.limit / 24 </s> add resp.IntervalDays = s.limitHours / 24 </s> remove aghhttp.Error( r, w, http.StatusInternalServerError, "Failed to encode to json: %v", e, ) </s> add aghhttp.Error(r, w, http.StatusInternalServerError, "failed to encode to json: %v", e) </s> remove func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) {
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
func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { start := time.Now() var resp statsResponse 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 } w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(resp)
[ "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", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
IntervalDays uint32 `json:"interval"` } // Get configuration func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { resp := config{} resp.IntervalDays = s.conf.limit / 24 data, err := json.Marshal(resp) if err != nil {
</s> remove resp.IntervalDays = s.conf.limit / 24 </s> add resp.IntervalDays = s.limitHours / 24 </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> remove s.conf.ConfigModified() </s> add s.configModified()
func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) {
IntervalDays uint32 `json:"interval"` } // Get configuration func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { resp := config{} resp.IntervalDays = s.conf.limit / 24 data, err := json.Marshal(resp) if err != nil {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
// Get configuration func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { resp := config{} resp.IntervalDays = s.conf.limit / 24 data, err := json.Marshal(resp) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json encode: %s", err)
</s> remove func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> remove if s.conf.limit == 0 { resp = statsResponse{ TimeUnits: "days", TopBlocked: []topAddrs{}, TopClients: []topAddrs{}, TopQueried: []topAddrs{}, BlockedFiltering: []uint64{}, DNSQueries: []uint64{}, ReplacedParental: []uint64{}, ReplacedSafebrowsing: []uint64{}, } } else { var ok bool resp, ok = s.getData() log.Debug("stats: prepared data in %v", time.Since(start)) if !ok { aghhttp.Error(r, w, http.StatusInternalServerError, "Couldn't get statistics data") return } </s> add 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 </s> remove func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) {
resp.IntervalDays = s.limitHours / 24
// Get configuration func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { resp := config{} resp.IntervalDays = s.limitHours / 24 data, err := json.Marshal(resp) if err != nil { aghhttp.Error(r, w, http.StatusInternalServerError, "json encode: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
} } // Set configuration func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { reqData := config{} err := json.NewDecoder(r.Body).Decode(&reqData) if err != nil { aghhttp.Error(r, w, http.StatusBadRequest, "json decode: %s", err)
</s> remove resp.IntervalDays = s.conf.limit / 24 </s> add resp.IntervalDays = s.limitHours / 24 </s> remove func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err)
func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
} } // Set configuration func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { reqData := config{} err := json.NewDecoder(r.Body).Decode(&reqData) if err != nil { aghhttp.Error(r, w, http.StatusBadRequest, "json decode: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
return } s.setLimit(int(reqData.IntervalDays)) s.conf.ConfigModified() } // Reset data func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { s.clear()
</s> remove func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> remove resp.IntervalDays = s.conf.limit / 24 </s> add resp.IntervalDays = s.limitHours / 24
s.configModified()
return } s.setLimit(int(reqData.IntervalDays)) s.configModified() } // Reset data func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { s.clear()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
s.conf.ConfigModified() } // Reset data func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { s.clear() } // Register web handlers func (s *statsCtx) initWeb() {
</s> remove s.conf.ConfigModified() </s> add s.configModified() </s> remove func (s *statsCtx) initWeb() { if s.conf.HTTPRegister == nil { </s> add func (s *StatsCtx) initWeb() { if s.httpRegister == nil { </s> remove func (s *statsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) handleStats(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStats(w http.ResponseWriter, r *http.Request) {
func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) {
s.conf.ConfigModified() } // Reset data func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { s.clear() } // Register web handlers func (s *statsCtx) initWeb() {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
s.clear() } // Register web handlers func (s *statsCtx) initWeb() { if s.conf.HTTPRegister == nil { return } s.conf.HTTPRegister(http.MethodGet, "/control/stats", s.handleStats) s.conf.HTTPRegister(http.MethodPost, "/control/stats_reset", s.handleStatsReset)
</s> remove s.conf.HTTPRegister(http.MethodGet, "/control/stats", s.handleStats) s.conf.HTTPRegister(http.MethodPost, "/control/stats_reset", s.handleStatsReset) s.conf.HTTPRegister(http.MethodPost, "/control/stats_config", s.handleStatsConfig) s.conf.HTTPRegister(http.MethodGet, "/control/stats_info", s.handleStatsInfo) </s> add 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) </s> remove func (s *statsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> add func (s *StatsCtx) handleStatsReset(w http.ResponseWriter, r *http.Request) { </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove s.conf.ConfigModified() </s> add s.configModified() </s> remove log.Debug("stats: set limit: %d", limitDays) </s> add log.Debug("stats: set limit: %d days", limitDays)
func (s *StatsCtx) initWeb() { if s.httpRegister == nil {
s.clear() } // Register web handlers func (s *StatsCtx) initWeb() { if s.httpRegister == nil { func (s *StatsCtx) initWeb() { if s.httpRegister == nil { return } s.conf.HTTPRegister(http.MethodGet, "/control/stats", s.handleStats) s.conf.HTTPRegister(http.MethodPost, "/control/stats_reset", s.handleStatsReset)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
if s.conf.HTTPRegister == nil { return } s.conf.HTTPRegister(http.MethodGet, "/control/stats", s.handleStats) s.conf.HTTPRegister(http.MethodPost, "/control/stats_reset", s.handleStatsReset) s.conf.HTTPRegister(http.MethodPost, "/control/stats_config", s.handleStatsConfig) s.conf.HTTPRegister(http.MethodGet, "/control/stats_info", s.handleStatsInfo) }
</s> remove func (s *statsCtx) initWeb() { if s.conf.HTTPRegister == nil { </s> add func (s *StatsCtx) initWeb() { if s.httpRegister == nil { </s> remove units, _ := s.loadUnits(s.conf.limit) </s> add units, _ := s.loadUnits(atomic.LoadUint32(&s.limitHours)) </s> remove func (s *statsCtx) GetTopClientsIP(maxCount uint) []net.IP { if s.conf.limit == 0 { </s> add func (s *StatsCtx) GetTopClientsIP(maxCount uint) []net.IP { if !s.isEnabled() { </s> remove log.Tracef("db.Begin...") tx, err := db.Begin(wr) </s> add log.Tracef("opening a database transaction") tx, err := db.Begin(writable) </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB { </s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB {
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)
if s.conf.HTTPRegister == nil { return } 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) 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) 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) 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) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/http.go
package stats import ( "net" "net/http" ) type unitIDCallback func() uint32 // DiskConfig - configuration settings that are stored on disk
</s> remove // DiskConfig - configuration settings that are stored on disk </s> add // DiskConfig is the configuration structure that is stored in file. </s> remove type unitIDCallback func() uint32 </s> add // UnitIDGenFunc is the signature of a function that generates a unique ID for // the statistics unit. type UnitIDGenFunc func() (id uint32) </s> remove Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) </s> add // Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"` </s> remove "net/http" </s> add
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
package stats import ( "net" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" ) type unitIDCallback func() uint32 // DiskConfig - configuration settings that are stored on disk
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
"net" "net/http" ) type unitIDCallback func() uint32 // DiskConfig - configuration settings that are stored on disk type DiskConfig struct { Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) }
</s> remove // DiskConfig - configuration settings that are stored on disk </s> add // DiskConfig is the configuration structure that is stored in file. </s> remove Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) </s> add // Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"` </s> remove "net/http" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting. </s> remove Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. </s> add // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc
// UnitIDGenFunc is the signature of a function that generates a unique ID for // the statistics unit. type UnitIDGenFunc func() (id uint32)
"net" "net/http" ) // UnitIDGenFunc is the signature of a function that generates a unique ID for // the statistics unit. type UnitIDGenFunc func() (id uint32) // DiskConfig - configuration settings that are stored on disk type DiskConfig struct { Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
) type unitIDCallback func() uint32 // DiskConfig - configuration settings that are stored on disk type DiskConfig struct { Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) } // Config - module configuration
</s> remove Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) </s> add // Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"` </s> remove type unitIDCallback func() uint32 </s> add // UnitIDGenFunc is the signature of a function that generates a unique ID for // the statistics unit. type UnitIDGenFunc func() (id uint32) </s> remove "net/http" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting. </s> remove Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. </s> add // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc
// DiskConfig is the configuration structure that is stored in file.
) type unitIDCallback func() uint32 // DiskConfig is the configuration structure that is stored in file. type DiskConfig struct { Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) } // Config - module configuration
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
type unitIDCallback func() uint32 // DiskConfig - configuration settings that are stored on disk type DiskConfig struct { Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) } // Config - module configuration type Config struct { Filename string // database file name
</s> remove // DiskConfig - configuration settings that are stored on disk </s> add // DiskConfig is the configuration structure that is stored in file. </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting. </s> remove type unitIDCallback func() uint32 </s> add // UnitIDGenFunc is the signature of a function that generates a unique ID for // the statistics unit. type UnitIDGenFunc func() (id uint32) </s> remove "net/http" </s> add "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" </s> remove Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. </s> add // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc
// Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"`
type unitIDCallback func() uint32 // DiskConfig - configuration settings that are stored on disk type DiskConfig struct { // Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"` } // Config - module configuration type Config struct { Filename string // database file name
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
type DiskConfig struct { Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) } // Config - module configuration type Config struct { Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used.
</s> remove Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. </s> add // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc </s> remove Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) </s> add // Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"` </s> remove // Called when the configuration is changed by HTTP request </s> add // ConfigModified will be called each time the configuration changed via web // interface. </s> remove // DiskConfig - configuration settings that are stored on disk </s> add // DiskConfig is the configuration structure that is stored in file. </s> remove type unitIDCallback func() uint32 </s> add // UnitIDGenFunc is the signature of a function that generates a unique ID for // the statistics unit. type UnitIDGenFunc func() (id uint32)
// Config is the configuration structure for the statistics collecting.
type DiskConfig struct { Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) } // Config is the configuration structure for the statistics collecting. type Config struct { Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
} // Config - module configuration type Config struct { Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. // Called when the configuration is changed by HTTP request ConfigModified func() // Register an HTTP handler
</s> remove // Called when the configuration is changed by HTTP request </s> add // ConfigModified will be called each time the configuration changed via web // interface. </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting. </s> remove // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc </s> remove Interval uint32 `yaml:"statistics_interval"` // time interval for statistics (in days) </s> add // Interval is the number of days for which the statistics are collected // before flushing to the database. Interval uint32 `yaml:"statistics_interval"` </s> remove // DiskConfig - configuration settings that are stored on disk </s> add // DiskConfig is the configuration structure that is stored in file.
// UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc
} // Config - module configuration type Config struct { // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc // Called when the configuration is changed by HTTP request ConfigModified func() // Register an HTTP handler
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. // Called when the configuration is changed by HTTP request ConfigModified func() // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request))
</s> remove Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. </s> add // UnitID is the function to generate the identifier for current unit. If // nil, the default function is used, see newUnitID. UnitID UnitIDGenFunc </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting. </s> remove // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"`
// ConfigModified will be called each time the configuration changed via web // interface.
Filename string // database file name LimitDays uint32 // time limit (in days) UnitID unitIDCallback // user function to get the current unit ID. If nil, the current time hour is used. // ConfigModified will be called each time the configuration changed via web // interface. ConfigModified func() // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request))
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Called when the configuration is changed by HTTP request ConfigModified func() // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) limit uint32 // maximum time we need to keep data for (in hours) } // New - create object
</s> remove limit uint32 // maximum time we need to keep data for (in hours) } </s> add // Filename is the name of the database file. Filename string </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove // Called when the configuration is changed by HTTP request </s> add // ConfigModified will be called each time the configuration changed via web // interface. </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add HTTPRegister aghhttp.RegisterFunc
// HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc
// Called when the configuration is changed by HTTP request ConfigModified func() // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc limit uint32 // maximum time we need to keep data for (in hours) } // New - create object
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) limit uint32 // maximum time we need to keep data for (in hours) } // New - create object func New(conf Config) (Stats, error) { return createObject(conf) }
</s> remove // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc </s> remove // New - create object func New(conf Config) (Stats, error) { return createObject(conf) </s> add // LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32 </s> remove // Called when the configuration is changed by HTTP request </s> add // ConfigModified will be called each time the configuration changed via web // interface. </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"` </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"`
// Filename is the name of the database file. Filename string
// Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) // Filename is the name of the database file. Filename string // Filename is the name of the database file. Filename string // New - create object func New(conf Config) (Stats, error) { return createObject(conf) }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
limit uint32 // maximum time we need to keep data for (in hours) } // New - create object func New(conf Config) (Stats, error) { return createObject(conf) } // Stats - main interface type Stats interface { Start()
</s> remove limit uint32 // maximum time we need to keep data for (in hours) } </s> add // Filename is the name of the database file. Filename string </s> remove // Stats - main interface type Stats interface { </s> add // Interface is the statistics interface to be used by other packages. type Interface interface { // Start begins the statistics collecting. </s> remove // Register an HTTP handler HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) </s> add // HTTPRegister is the function that registers handlers for the stats // endpoints. HTTPRegister aghhttp.RegisterFunc </s> remove // Close object. // This function is not thread safe // (can't be called in parallel with any other function of this interface). </s> add // Close stops the statistics collecting. </s> remove stats.Stats </s> add stats.Interface
// LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32
limit uint32 // maximum time we need to keep data for (in hours) } // LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32 // LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32 // LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32 } // Stats - main interface type Stats interface { Start()
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
func New(conf Config) (Stats, error) { return createObject(conf) } // Stats - main interface type Stats interface { Start() // Close object. // This function is not thread safe // (can't be called in parallel with any other function of this interface).
</s> remove // Close object. // This function is not thread safe // (can't be called in parallel with any other function of this interface). </s> add // Close stops the statistics collecting. </s> remove // Update counters </s> add // Update collects the incoming statistics data. </s> remove // New - create object func New(conf Config) (Stats, error) { return createObject(conf) </s> add // LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32 </s> remove limit uint32 // maximum time we need to keep data for (in hours) } </s> add // Filename is the name of the database file. Filename string </s> remove stats.Stats </s> add stats.Interface
// Interface is the statistics interface to be used by other packages. type Interface interface { // Start begins the statistics collecting.
func New(conf Config) (Stats, error) { return createObject(conf) } // Interface is the statistics interface to be used by other packages. type Interface interface { // Start begins the statistics collecting. // Interface is the statistics interface to be used by other packages. type Interface interface { // Start begins the statistics collecting. Start() // Close object. // This function is not thread safe // (can't be called in parallel with any other function of this interface).
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Stats - main interface type Stats interface { Start() // Close object. // This function is not thread safe // (can't be called in parallel with any other function of this interface). Close() // Update counters Update(e Entry)
</s> remove // Stats - main interface type Stats interface { </s> add // Interface is the statistics interface to be used by other packages. type Interface interface { // Start begins the statistics collecting. </s> remove // Update counters </s> add // Update collects the incoming statistics data. </s> remove // New - create object func New(conf Config) (Stats, error) { return createObject(conf) </s> add // LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32 </s> remove stats.Stats </s> add stats.Interface </s> remove // Get IP addresses of the clients with the most number of requests </s> add // GetTopClientIP returns at most limit IP addresses corresponding to the // clients with the most number of requests.
// Close stops the statistics collecting.
// Stats - main interface type Stats interface { Start() // Close stops the statistics collecting. // Close stops the statistics collecting. // Close stops the statistics collecting. Close() // Update counters Update(e Entry)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// This function is not thread safe // (can't be called in parallel with any other function of this interface). Close() // Update counters Update(e Entry) // Get IP addresses of the clients with the most number of requests GetTopClientsIP(limit uint) []net.IP
</s> remove // Close object. // This function is not thread safe // (can't be called in parallel with any other function of this interface). </s> add // Close stops the statistics collecting. </s> remove // Get IP addresses of the clients with the most number of requests </s> add // GetTopClientIP returns at most limit IP addresses corresponding to the // clients with the most number of requests. </s> remove // Stats - main interface type Stats interface { </s> add // Interface is the statistics interface to be used by other packages. type Interface interface { // Start begins the statistics collecting. </s> remove // WriteDiskConfig - write configuration </s> add // WriteDiskConfig puts the Interface's configuration to the dc. </s> remove // top: 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 </s> add old, s.curr = s.curr, with return old
// Update collects the incoming statistics data.
// This function is not thread safe // (can't be called in parallel with any other function of this interface). Close() // Update collects the incoming statistics data. Update(e Entry) // Get IP addresses of the clients with the most number of requests GetTopClientsIP(limit uint) []net.IP
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Update counters Update(e Entry) // Get IP addresses of the clients with the most number of requests GetTopClientsIP(limit uint) []net.IP // WriteDiskConfig - write configuration WriteDiskConfig(dc *DiskConfig) }
</s> remove // WriteDiskConfig - write configuration </s> add // WriteDiskConfig puts the Interface's configuration to the dc. </s> remove // Update counters </s> add // Update collects the incoming statistics data. </s> remove // TimeUnit - time unit </s> add // TimeUnit is the unit of measuring time while aggregating the statistics. </s> remove // Close object. // This function is not thread safe // (can't be called in parallel with any other function of this interface). </s> add // Close stops the statistics collecting. </s> remove // top: 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 </s> add old, s.curr = s.curr, with return old
// GetTopClientIP returns at most limit IP addresses corresponding to the // clients with the most number of requests.
// Update counters Update(e Entry) // GetTopClientIP returns at most limit IP addresses corresponding to the // clients with the most number of requests. GetTopClientsIP(limit uint) []net.IP // WriteDiskConfig - write configuration WriteDiskConfig(dc *DiskConfig) }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Get IP addresses of the clients with the most number of requests GetTopClientsIP(limit uint) []net.IP // WriteDiskConfig - write configuration WriteDiskConfig(dc *DiskConfig) } // TimeUnit - time unit type TimeUnit int
</s> remove // Get IP addresses of the clients with the most number of requests </s> add // GetTopClientIP returns at most limit IP addresses corresponding to the // clients with the most number of requests. </s> remove // TimeUnit - time unit </s> add // TimeUnit is the unit of measuring time while aggregating the statistics. </s> remove // Update counters </s> add // Update collects the incoming statistics data. </s> remove // Supported time units </s> add // Supported TimeUnit values. </s> remove // top: 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 </s> add old, s.curr = s.curr, with return old
// WriteDiskConfig puts the Interface's configuration to the dc.
// Get IP addresses of the clients with the most number of requests GetTopClientsIP(limit uint) []net.IP // WriteDiskConfig puts the Interface's configuration to the dc. WriteDiskConfig(dc *DiskConfig) } // TimeUnit - time unit type TimeUnit int
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// WriteDiskConfig - write configuration WriteDiskConfig(dc *DiskConfig) } // TimeUnit - time unit type TimeUnit int // Supported time units const ( Hours TimeUnit = iota
</s> remove // Supported time units </s> add // Supported TimeUnit values. </s> remove // WriteDiskConfig - write configuration </s> add // WriteDiskConfig puts the Interface's configuration to the dc. </s> remove // Result of DNS request processing </s> add // Result is the resulting code of processing the DNS request. </s> remove // Supported result values </s> add // Supported Result values. // // TODO(e.burkov): Think about better naming. </s> remove // Get IP addresses of the clients with the most number of requests </s> add // GetTopClientIP returns at most limit IP addresses corresponding to the // clients with the most number of requests.
// TimeUnit is the unit of measuring time while aggregating the statistics.
// WriteDiskConfig - write configuration WriteDiskConfig(dc *DiskConfig) } // TimeUnit is the unit of measuring time while aggregating the statistics. type TimeUnit int // Supported time units const ( Hours TimeUnit = iota
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// TimeUnit - time unit type TimeUnit int // Supported time units const ( Hours TimeUnit = iota Days )
</s> remove // TimeUnit - time unit </s> add // TimeUnit is the unit of measuring time while aggregating the statistics. </s> remove // Result of DNS request processing </s> add // Result is the resulting code of processing the DNS request. </s> remove // WriteDiskConfig - write configuration </s> add // WriteDiskConfig puts the Interface's configuration to the dc. </s> remove // Supported result values </s> add // Supported Result values. // // TODO(e.burkov): Think about better naming. </s> remove // DiskConfig - configuration settings that are stored on disk </s> add // DiskConfig is the configuration structure that is stored in file.
// Supported TimeUnit values.
// TimeUnit - time unit type TimeUnit int // Supported TimeUnit values. const ( Hours TimeUnit = iota Days )
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
Hours TimeUnit = iota Days ) // Result of DNS request processing type Result int // Supported result values const ( RNotFiltered Result = iota + 1
</s> remove // Supported result values </s> add // Supported Result values. // // TODO(e.burkov): Think about better naming. </s> remove // Supported time units </s> add // Supported TimeUnit values. </s> remove // TimeUnit - time unit </s> add // TimeUnit is the unit of measuring time while aggregating the statistics.
// Result is the resulting code of processing the DNS request.
Hours TimeUnit = iota Days ) // Result is the resulting code of processing the DNS request. type Result int // Supported result values const ( RNotFiltered Result = iota + 1
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Result of DNS request processing type Result int // Supported result values const ( RNotFiltered Result = iota + 1 RFiltered RSafeBrowsing RSafeSearch
</s> remove // Result of DNS request processing </s> add // Result is the resulting code of processing the DNS request. </s> remove Time uint32 // processing time (msec) </s> add // Time is the duration of the request processing in milliseconds. Time uint32 </s> remove // Supported time units </s> add // Supported TimeUnit values.
// Supported Result values. // // TODO(e.burkov): Think about better naming.
// Result of DNS request processing type Result int // Supported Result values. // // TODO(e.burkov): Think about better naming. const ( RNotFiltered Result = iota + 1 RFiltered RSafeBrowsing RSafeSearch
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
RFiltered RSafeBrowsing RSafeSearch RParental rLast ) // Entry is a statistics data entry. type Entry struct { // Clients is the client's primary ID.
</s> remove // Supported result values </s> add // Supported Result values. // // TODO(e.burkov): Think about better naming. </s> remove type unitIDCallback func() uint32 </s> add // UnitIDGenFunc is the signature of a function that generates a unique ID for // the statistics unit. type UnitIDGenFunc func() (id uint32) </s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time. </s> remove db *bolt.DB conf *Config </s> add // 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 </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting.
resultLast = RParental + 1
RFiltered RSafeBrowsing RSafeSearch RParental resultLast = RParental + 1 ) // Entry is a statistics data entry. type Entry struct { // Clients is the client's primary ID.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
Client string Domain string // Result is the result of processing the request. Result Result
</s> remove Time uint32 // processing time (msec) </s> add // Time is the duration of the request processing in milliseconds. Time uint32 </s> remove // Result of DNS request processing </s> add // Result is the resulting code of processing the DNS request. </s> remove // Supported result values </s> add // Supported Result values. // // TODO(e.burkov): Think about better naming. </s> remove // top: 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 </s> add old, s.curr = s.curr, with return old
// Domain is the domain name requested.
Client string // Domain is the domain name requested. Domain string // Result is the result of processing the request. Result Result
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
// Domain is the domain name requested. Domain string Result Result // Time is the duration of the request processing in milliseconds. Time uint32
</s> remove Time uint32 // processing time (msec) </s> add // Time is the duration of the request processing in milliseconds. Time uint32 </s> remove // Result of DNS request processing </s> add // Result is the resulting code of processing the DNS request. </s> remove // Supported result values </s> add // Supported Result values. // // TODO(e.burkov): Think about better naming. </s> remove HTTPRegister func(string, string, func(http.ResponseWriter, *http.Request)) `yaml:"-"` </s> add HTTPRegister aghhttp.RegisterFunc `yaml:"-"`
// Result is the result of processing the request.
// Domain is the domain name requested. Domain string // Result is the result of processing the request. Result Result // Time is the duration of the request processing in milliseconds. Time uint32
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
Client string Domain string Result Result Time uint32 // processing time (msec) }
</s> remove // Result of DNS request processing </s> add // Result is the resulting code of processing the DNS request. </s> remove // Supported result values </s> add // Supported Result values. // // TODO(e.burkov): Think about better naming. </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting.
// Time is the duration of the request processing in milliseconds. Time uint32
Client string Domain string Result Result // Time is the duration of the request processing in milliseconds. Time uint32 }
[ "keep", "keep", "keep", "keep", "replace", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats.go
Filename: "./stats.db", LimitDays: 1, } s, err := createObject(conf) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, func() (err error) { s.clear() s.Close()
</s> remove s, err := createObject(conf) </s> add s, err := New(conf) </s> remove ) (f func(name []byte, b *bolt.Bucket) (err error)) { return func(name []byte, _ *bolt.Bucket) (err error) { </s> add ) (f func(name []byte, b *bbolt.Bucket) (err error)) { return func(name []byte, _ *bbolt.Bucket) (err error) { </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err)
s, err := New(conf)
Filename: "./stats.db", LimitDays: 1, } s, err := New(conf) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, func() (err error) { s.clear() s.Close()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats_test.go
Filename: "./stats.db", LimitDays: 1, UnitID: newID, } s, err := createObject(conf) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, func() (err error) { s.Close() return os.Remove(conf.Filename)
</s> remove s, err := createObject(conf) </s> add s, err := New(conf) </s> remove ) (f func(name []byte, b *bolt.Bucket) (err error)) { return func(name []byte, _ *bolt.Bucket) (err error) { </s> add ) (f func(name []byte, b *bbolt.Bucket) (err error)) { return func(name []byte, _ *bbolt.Bucket) (err error) { </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) { </s> remove log.Debug("tx.Commit: %s", err) </s> add log.Error("stats: committing a transaction: %s", err) </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err)
s, err := New(conf)
Filename: "./stats.db", LimitDays: 1, UnitID: newID, } s, err := New(conf) require.NoError(t, err) testutil.CleanupAndRequireSuccess(t, func() (err error) { s.Close() return os.Remove(conf.Filename)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/stats_test.go
"net" "os" "sort" "sync" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log"
</s> remove "net/http" </s> add </s> remove "net/http" </s> add
"sync/atomic"
"net" "os" "sort" "sync" "sync/atomic" "time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
"time" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "go.etcd.io/bbolt" ) // TODO(a.garipov): Rewrite all of this. Add proper error handling and
</s> remove bolt "go.etcd.io/bbolt" </s> add "go.etcd.io/bbolt" </s> remove TimeAvg uint32 // usec </s> add // TimeAvg is the average of processing times in milliseconds of all the // requests in the unit. TimeAvg uint32
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"time" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "go.etcd.io/bbolt" ) // TODO(a.garipov): Rewrite all of this. Add proper error handling and
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
"time" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" bolt "go.etcd.io/bbolt" ) // TODO(a.garipov): Rewrite all of this. Add proper error handling and // inspection. Improve logging. Decrease complexity.
</s> remove TimeAvg uint32 // usec </s> add // TimeAvg is the average of processing times in milliseconds of all the // requests in the unit. TimeAvg uint32
"go.etcd.io/bbolt"
"time" "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "go.etcd.io/bbolt" ) // TODO(a.garipov): Rewrite all of this. Add proper error handling and // inspection. Improve logging. Decrease complexity.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
maxDomains = 100 // max number of top domains to store in file or return via Get() maxClients = 100 // max number of top clients to store in file or return via Get() ) // statsCtx - global context type statsCtx struct { // mu protects unit. mu *sync.Mutex // current is the actual statistics collection result. current *unit db *bolt.DB conf *Config }
</s> remove db *bolt.DB conf *Config </s> add // 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 </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 </s> add // 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 of requests grouped by it's result. nResult []uint64 // timeSum stores the sum of processing time in milliseconds of each request // written by the unit. timeSum uint64 // domains stores the number of requests for each domain. domains map[string]uint64 // blockedDomains stores the number of requests for each domain that has // been blocked. blockedDomains map[string]uint64 // clients stores the number of requests from each client. clients map[string]uint64 } // ongoing returns the current unit. It's safe for concurrent use. // // Note that the unit itself should be locked before accessing. func (s *StatsCtx) ongoing() (u *unit) { s.currMu.Lock() defer s.currMu.Unlock() return s.curr } </s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time. </s> remove // New - create object func New(conf Config) (Stats, error) { return createObject(conf) </s> add // LimitDays is the maximum number of days to collect statistics into the // current unit. LimitDays uint32 </s> remove NTotal uint64 </s> add // NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind.
// 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 result. curr *unit // dbMu protects db. dbMu *sync.Mutex // db is the opened statistics database, if any. db *bbolt.DB // unitIDGen is the function that generates an identifier for the current // unit. It's here for only testing purposes. unitIDGen UnitIDGenFunc // httpRegister is used to set HTTP handlers. httpRegister aghhttp.RegisterFunc // configModified is called whenever the configuration is modified via web // interface. configModified func()
maxDomains = 100 // max number of top domains to store in file or return via Get() maxClients = 100 // max number of top clients to store in file or return via Get() ) // 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 result. curr *unit // dbMu protects db. dbMu *sync.Mutex // db is the opened statistics database, if any. db *bbolt.DB // unitIDGen is the function that generates an identifier for the current // unit. It's here for only testing purposes. unitIDGen UnitIDGenFunc // httpRegister is used to set HTTP handlers. httpRegister aghhttp.RegisterFunc // configModified is called whenever the configuration is modified via web // interface. configModified func() // 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 result. curr *unit // dbMu protects db. dbMu *sync.Mutex // db is the opened statistics database, if any. db *bbolt.DB // unitIDGen is the function that generates an identifier for the current // unit. It's here for only testing purposes. unitIDGen UnitIDGenFunc // httpRegister is used to set HTTP handlers. httpRegister aghhttp.RegisterFunc // configModified is called whenever the configuration is modified via web // interface. configModified func() // 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 result. curr *unit // dbMu protects db. dbMu *sync.Mutex // db is the opened statistics database, if any. db *bbolt.DB // unitIDGen is the function that generates an identifier for the current // unit. It's here for only testing purposes. unitIDGen UnitIDGenFunc // httpRegister is used to set HTTP handlers. httpRegister aghhttp.RegisterFunc // configModified is called whenever the configuration is modified via web // interface. configModified func() // 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 result. curr *unit // dbMu protects db. dbMu *sync.Mutex // db is the opened statistics database, if any. db *bbolt.DB // unitIDGen is the function that generates an identifier for the current // unit. It's here for only testing purposes. unitIDGen UnitIDGenFunc // httpRegister is used to set HTTP handlers. httpRegister aghhttp.RegisterFunc // configModified is called whenever the configuration is modified via web // interface. configModified func() // 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 result. curr *unit // dbMu protects db. dbMu *sync.Mutex // db is the opened statistics database, if any. db *bbolt.DB // unitIDGen is the function that generates an identifier for the current // unit. It's here for only testing purposes. unitIDGen UnitIDGenFunc // httpRegister is used to set HTTP handlers. httpRegister aghhttp.RegisterFunc // configModified is called whenever the configuration is modified via web // interface. configModified func() // 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 result. curr *unit // dbMu protects db. dbMu *sync.Mutex // db is the opened statistics database, if any. db *bbolt.DB // unitIDGen is the function that generates an identifier for the current // unit. It's here for only testing purposes. unitIDGen UnitIDGenFunc // httpRegister is used to set HTTP handlers. httpRegister aghhttp.RegisterFunc // configModified is called whenever the configuration is modified via web // interface. configModified func() db *bolt.DB conf *Config }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
mu *sync.Mutex // current is the actual statistics collection result. current *unit db *bolt.DB conf *Config } // data for 1 time unit type unit struct { id uint32 // unit ID. Default: absolute hour since Jan 1, 1970
</s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time. </s> remove // statsCtx - global context type statsCtx struct { // mu protects unit. mu *sync.Mutex // current is the actual statistics collection result. current *unit </s> add // 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 result. curr *unit // dbMu protects db. dbMu *sync.Mutex // db is the opened statistics database, if any. db *bbolt.DB // unitIDGen is the function that generates an identifier for the current // unit. It's here for only testing purposes. unitIDGen UnitIDGenFunc // httpRegister is used to set HTTP handlers. httpRegister aghhttp.RegisterFunc // configModified is called whenever the configuration is modified via web // interface. configModified func() </s> remove nTotal uint64 // total requests nResult []uint64 // number of requests per one result timeSum uint64 // sum of processing time of all requests (usec) </s> add // 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() </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 </s> add // 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 of requests grouped by it's result. nResult []uint64 // timeSum stores the sum of processing time in milliseconds of each request // written by the unit. timeSum uint64 // domains stores the number of requests for each domain. domains map[string]uint64 // blockedDomains stores the number of requests for each domain that has // been blocked. blockedDomains map[string]uint64 // clients stores the number of requests from each client. clients map[string]uint64 } // ongoing returns the current unit. It's safe for concurrent use. // // Note that the unit itself should be locked before accessing. func (s *StatsCtx) ongoing() (u *unit) { s.currMu.Lock() defer s.currMu.Unlock() return s.curr } </s> remove // Config - module configuration </s> add // Config is the configuration structure for the statistics collecting.
// 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
mu *sync.Mutex // current is the actual statistics collection result. current *unit // 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 // 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 } // data for 1 time unit type unit struct { id uint32 // unit ID. Default: absolute hour since Jan 1, 1970
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
db *bolt.DB conf *Config } // data for 1 time unit type unit struct { id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 nTotal uint64 // total requests nResult []uint64 // number of requests per one result
</s> remove nTotal uint64 // total requests nResult []uint64 // number of requests per one result timeSum uint64 // sum of processing time of all requests (usec) </s> add // 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() </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 </s> add // 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 of requests grouped by it's result. nResult []uint64 // timeSum stores the sum of processing time in milliseconds of each request // written by the unit. timeSum uint64 // domains stores the number of requests for each domain. domains map[string]uint64 // blockedDomains stores the number of requests for each domain that has // been blocked. blockedDomains map[string]uint64 // clients stores the number of requests from each client. clients map[string]uint64 } // ongoing returns the current unit. It's safe for concurrent use. // // Note that the unit itself should be locked before accessing. func (s *StatsCtx) ongoing() (u *unit) { s.currMu.Lock() defer s.currMu.Unlock() return s.curr } </s> remove db *bolt.DB conf *Config </s> add // 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 </s> remove // top: 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 </s> add old, s.curr = s.curr, with return old </s> remove NTotal uint64 </s> add // NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind.
// unit collects the statistics data for a specific period of time.
db *bolt.DB conf *Config } // unit collects the statistics data for a specific period of time. type unit struct { id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 nTotal uint64 // total requests nResult []uint64 // number of requests per one result
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
} // data for 1 time unit type unit struct { id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 nTotal uint64 // total requests nResult []uint64 // number of requests per one result timeSum uint64 // sum of processing time of all requests (usec)
</s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time. </s> remove nTotal uint64 // total requests nResult []uint64 // number of requests per one result timeSum uint64 // sum of processing time of all requests (usec) </s> add // 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() </s> remove // top: 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 </s> add old, s.curr = s.curr, with return old </s> remove db *bolt.DB conf *Config </s> add // 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 </s> remove NTotal uint64 </s> add // NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind.
// 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 of requests grouped by it's result. nResult []uint64 // timeSum stores the sum of processing time in milliseconds of each request // written by the unit. timeSum uint64 // domains stores the number of requests for each domain. domains map[string]uint64 // blockedDomains stores the number of requests for each domain that has // been blocked. blockedDomains map[string]uint64 // clients stores the number of requests from each client. clients map[string]uint64 } // ongoing returns the current unit. It's safe for concurrent use. // // Note that the unit itself should be locked before accessing. func (s *StatsCtx) ongoing() (u *unit) { s.currMu.Lock() defer s.currMu.Unlock() return s.curr }
} // data for 1 time unit type unit struct { // 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 of requests grouped by it's result. nResult []uint64 // timeSum stores the sum of processing time in milliseconds of each request // written by the unit. timeSum uint64 // domains stores the number of requests for each domain. domains map[string]uint64 // blockedDomains stores the number of requests for each domain that has // been blocked. blockedDomains map[string]uint64 // clients stores the number of requests from each client. clients map[string]uint64 } // ongoing returns the current unit. It's safe for concurrent use. // // Note that the unit itself should be locked before accessing. func (s *StatsCtx) ongoing() (u *unit) { s.currMu.Lock() defer s.currMu.Unlock() return s.curr } nTotal uint64 // total requests nResult []uint64 // number of requests per one result timeSum uint64 // sum of processing time of all requests (usec)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// data for 1 time unit type unit struct { id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 nTotal uint64 // total requests nResult []uint64 // number of requests per one result timeSum uint64 // sum of processing time of all requests (usec) // top: 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
</s> remove // top: 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 </s> add old, s.curr = s.curr, with return old </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 </s> add // 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 of requests grouped by it's result. nResult []uint64 // timeSum stores the sum of processing time in milliseconds of each request // written by the unit. timeSum uint64 // domains stores the number of requests for each domain. domains map[string]uint64 // blockedDomains stores the number of requests for each domain that has // been blocked. blockedDomains map[string]uint64 // clients stores the number of requests from each client. clients map[string]uint64 } // ongoing returns the current unit. It's safe for concurrent use. // // Note that the unit itself should be locked before accessing. func (s *StatsCtx) ongoing() (u *unit) { s.currMu.Lock() defer s.currMu.Unlock() return s.curr } </s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time. </s> remove // name-count pair </s> add // 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 *bbolt.DB) (old *bbolt.DB) { s.dbMu.Lock() defer s.dbMu.Unlock() old, s.db = s.db, with return old } // countPair is a single name-number pair for deserializing statistics data into // the database. </s> remove Domains []countPair </s> add // Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name.
// 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()
// data for 1 time unit type unit struct { id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 // 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() // 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() // 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() // top: 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
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/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) // top: 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 } // name-count pair type countPair struct { Name string
</s> remove nTotal uint64 // total requests nResult []uint64 // number of requests per one result timeSum uint64 // sum of processing time of all requests (usec) </s> add // 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() </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 </s> add // 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 of requests grouped by it's result. nResult []uint64 // timeSum stores the sum of processing time in milliseconds of each request // written by the unit. timeSum uint64 // domains stores the number of requests for each domain. domains map[string]uint64 // blockedDomains stores the number of requests for each domain that has // been blocked. blockedDomains map[string]uint64 // clients stores the number of requests from each client. clients map[string]uint64 } // ongoing returns the current unit. It's safe for concurrent use. // // Note that the unit itself should be locked before accessing. func (s *StatsCtx) ongoing() (u *unit) { s.currMu.Lock() defer s.currMu.Unlock() return s.curr } </s> remove // name-count pair </s> add // 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 *bbolt.DB) (old *bbolt.DB) { s.dbMu.Lock() defer s.dbMu.Unlock() old, s.db = s.db, with return old } // countPair is a single name-number pair for deserializing statistics data into // the database. </s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time. </s> remove Domains []countPair </s> add // Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name.
old, s.curr = s.curr, with return old
nTotal uint64 // total requests nResult []uint64 // number of requests per one result timeSum uint64 // sum of processing time of all requests (usec) old, s.curr = s.curr, with return old old, s.curr = s.curr, with return old old, s.curr = s.curr, with return old old, s.curr = s.curr, with return old } // name-count pair type countPair struct { Name string
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
blockedDomains map[string]uint64 // number of blocked requests per domain clients map[string]uint64 // number of requests per client } // name-count pair type countPair struct { Name string Count uint64 }
</s> remove // top: 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 </s> add old, s.curr = s.curr, with return old </s> remove nTotal uint64 // total requests nResult []uint64 // number of requests per one result timeSum uint64 // sum of processing time of all requests (usec) </s> add // 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() </s> remove id uint32 // unit ID. Default: absolute hour since Jan 1, 1970 </s> add // 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 of requests grouped by it's result. nResult []uint64 // timeSum stores the sum of processing time in milliseconds of each request // written by the unit. timeSum uint64 // domains stores the number of requests for each domain. domains map[string]uint64 // blockedDomains stores the number of requests for each domain that has // been blocked. blockedDomains map[string]uint64 // clients stores the number of requests from each client. clients map[string]uint64 } // ongoing returns the current unit. It's safe for concurrent use. // // Note that the unit itself should be locked before accessing. func (s *StatsCtx) ongoing() (u *unit) { s.currMu.Lock() defer s.currMu.Unlock() return s.curr } </s> remove Domains []countPair </s> add // Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name. </s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time.
// 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 *bbolt.DB) (old *bbolt.DB) { s.dbMu.Lock() defer s.dbMu.Unlock() old, s.db = s.db, with return old } // countPair is a single name-number pair for deserializing statistics data into // the database.
blockedDomains map[string]uint64 // number of blocked requests per domain clients map[string]uint64 // number of requests per client } // 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 *bbolt.DB) (old *bbolt.DB) { s.dbMu.Lock() defer s.dbMu.Unlock() old, s.db = s.db, with return old } // countPair is a single name-number pair for deserializing statistics data into // the database. type countPair struct { Name string Count uint64 }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
Name string Count uint64 } // structure for storing data in file type unitDB struct { NTotal uint64 NResult []uint64 Domains []countPair
</s> remove NTotal uint64 </s> add // NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind. </s> remove Domains []countPair </s> add // Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name. </s> remove // top: 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 </s> add old, s.curr = s.curr, with return old </s> remove Clients []countPair </s> add // Clients is the number of requests from each client. Clients []countPair </s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time.
// unitDB is the structure for deserializing statistics data into the database.
Name string Count uint64 } // unitDB is the structure for deserializing statistics data into the database. type unitDB struct { NTotal uint64 NResult []uint64 Domains []countPair
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
} // structure for storing data in file type unitDB struct { NTotal uint64 NResult []uint64 Domains []countPair BlockedDomains []countPair Clients []countPair
</s> remove // structure for storing data in file </s> add // unitDB is the structure for deserializing statistics data into the database. </s> remove Domains []countPair </s> add // Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name. </s> remove Clients []countPair </s> add // Clients is the number of requests from each client. Clients []countPair </s> remove TimeAvg uint32 // usec </s> add // TimeAvg is the average of processing times in milliseconds of all the // requests in the unit. TimeAvg uint32 </s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time.
// NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind.
} // structure for storing data in file type unitDB struct { // NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind. NResult []uint64 Domains []countPair BlockedDomains []countPair Clients []countPair
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
type unitDB struct { NTotal uint64 NResult []uint64 Domains []countPair BlockedDomains []countPair Clients []countPair TimeAvg uint32 // usec }
</s> remove NTotal uint64 </s> add // NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind. </s> remove Clients []countPair </s> add // Clients is the number of requests from each client. Clients []countPair </s> remove // structure for storing data in file </s> add // unitDB is the structure for deserializing statistics data into the database. </s> remove TimeAvg uint32 // usec </s> add // TimeAvg is the average of processing times in milliseconds of all the // requests in the unit. TimeAvg uint32 </s> remove // data for 1 time unit </s> add // unit collects the statistics data for a specific period of time.
// Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name.
type unitDB struct { NTotal uint64 NResult []uint64 // Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name. BlockedDomains []countPair Clients []countPair TimeAvg uint32 // usec }
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
NResult []uint64 Domains []countPair BlockedDomains []countPair Clients []countPair TimeAvg uint32 // usec } // withRecovered turns the value recovered from panic if any into an error and
</s> remove TimeAvg uint32 // usec </s> add // TimeAvg is the average of processing times in milliseconds of all the // requests in the unit. TimeAvg uint32 </s> remove Domains []countPair </s> add // Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name. </s> remove NTotal uint64 </s> add // NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind. </s> remove // structure for storing data in file </s> add // unitDB is the structure for deserializing statistics data into the database. </s> remove return false } log.Tracef("db.Open") return true } </s> add
// Clients is the number of requests from each client. Clients []countPair
NResult []uint64 Domains []countPair BlockedDomains []countPair // Clients is the number of requests from each client. Clients []countPair TimeAvg uint32 // usec } // withRecovered turns the value recovered from panic if any into an error and
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
Domains []countPair BlockedDomains []countPair Clients []countPair TimeAvg uint32 // usec } // withRecovered turns the value recovered from panic if any into an error and // combines it with the one pointed by orig. orig must be non-nil. func withRecovered(orig *error) {
</s> remove Clients []countPair </s> add // Clients is the number of requests from each client. Clients []countPair </s> remove Domains []countPair </s> add // Domains is the number of requests for each domain name. Domains []countPair // BlockedDomains is the number of requests blocked for each domain name. </s> remove NTotal uint64 </s> add // NTotal is the total number of requests. NTotal uint64 // NResult is the number of requests by the result's kind. </s> remove // structure for storing data in file </s> add // unitDB is the structure for deserializing statistics data into the database. </s> remove func (s *statsCtx) ongoing() (u *unit) { s.mu.Lock() defer s.mu.Unlock() return s.current } </s> add
// TimeAvg is the average of processing times in milliseconds of all the // requests in the unit. TimeAvg uint32
Domains []countPair BlockedDomains []countPair Clients []countPair // TimeAvg is the average of processing times in milliseconds of all the // requests in the unit. TimeAvg uint32 } // withRecovered turns the value recovered from panic if any into an error and // combines it with the one pointed by orig. orig must be non-nil. func withRecovered(orig *error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
*orig = errors.WithDeferred(*orig, err) } // createObject creates s from conf and properly initializes it. func createObject(conf Config) (s *statsCtx, err error) { defer withRecovered(&err) s = &statsCtx{ mu: &sync.Mutex{}, }
</s> remove s = &statsCtx{ mu: &sync.Mutex{}, </s> add s = &StatsCtx{ currMu: &sync.Mutex{}, dbMu: &sync.Mutex{}, filename: conf.Filename, configModified: conf.ConfigModified, httpRegister: conf.HTTPRegister, </s> remove if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 </s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24 </s> remove func (s *statsCtx) Start() { </s> add // Start makes s process the incoming data. func (s *StatsCtx) Start() { </s> remove // name-count pair </s> add // 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 *bbolt.DB) (old *bbolt.DB) { s.dbMu.Lock() defer s.dbMu.Unlock() old, s.db = s.db, with return old } // countPair is a single name-number pair for deserializing statistics data into // the database. </s> remove // Delete unit's data from file func (s *statsCtx) deleteUnit(tx *bolt.Tx, id uint32) bool { </s> add // deleteUnit removes the unit by it's id from the database the tx belongs to. func (s *StatsCtx) deleteUnit(tx *bbolt.Tx, id uint32) bool {
// 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) {
*orig = errors.WithDeferred(*orig, err) } // 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) { // 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) { defer withRecovered(&err) s = &statsCtx{ mu: &sync.Mutex{}, }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// createObject creates s from conf and properly initializes it. func createObject(conf Config) (s *statsCtx, err error) { defer withRecovered(&err) s = &statsCtx{ mu: &sync.Mutex{}, } if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 }
</s> remove // createObject creates s from conf and properly initializes it. func createObject(conf Config) (s *statsCtx, err error) { </s> add // 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) { </s> remove if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 </s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24 </s> remove s.conf = &Config{} *s.conf = conf s.conf.limit = conf.LimitDays * 24 if conf.UnitID == nil { s.conf.UnitID = newUnitID </s> add if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID </s> remove func (s *statsCtx) Start() { </s> add // Start makes s process the incoming data. func (s *StatsCtx) Start() { </s> remove func (s *statsCtx) dbOpen() bool { var err error </s> add // dbOpen returns an error if the database can't be opened from the specified // file. It's safe for concurrent use. func (s *StatsCtx) dbOpen() (err error) {
s = &StatsCtx{ currMu: &sync.Mutex{}, dbMu: &sync.Mutex{}, filename: conf.Filename, configModified: conf.ConfigModified, httpRegister: conf.HTTPRegister,
// createObject creates s from conf and properly initializes it. func createObject(conf Config) (s *statsCtx, err error) { defer withRecovered(&err) s = &StatsCtx{ currMu: &sync.Mutex{}, dbMu: &sync.Mutex{}, filename: conf.Filename, configModified: conf.ConfigModified, httpRegister: conf.HTTPRegister, s = &StatsCtx{ currMu: &sync.Mutex{}, dbMu: &sync.Mutex{}, filename: conf.Filename, configModified: conf.ConfigModified, httpRegister: conf.HTTPRegister, } if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
s = &statsCtx{ mu: &sync.Mutex{}, } if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 } s.conf = &Config{} *s.conf = conf s.conf.limit = conf.LimitDays * 24
</s> remove s.conf = &Config{} *s.conf = conf s.conf.limit = conf.LimitDays * 24 if conf.UnitID == nil { s.conf.UnitID = newUnitID </s> add if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID </s> remove s = &statsCtx{ mu: &sync.Mutex{}, </s> add s = &StatsCtx{ currMu: &sync.Mutex{}, dbMu: &sync.Mutex{}, filename: conf.Filename, configModified: conf.ConfigModified, httpRegister: conf.HTTPRegister, </s> remove // createObject creates s from conf and properly initializes it. func createObject(conf Config) (s *statsCtx, err error) { </s> add // 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) { </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays)) </s> remove func (s *statsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = s.conf.limit / 24 </s> add func (s *StatsCtx) WriteDiskConfig(dc *DiskConfig) { dc.Interval = atomic.LoadUint32(&s.limitHours) / 24
if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24
s = &statsCtx{ mu: &sync.Mutex{}, } if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24 if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24 } s.conf = &Config{} *s.conf = conf s.conf.limit = conf.LimitDays * 24
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
} if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 } s.conf = &Config{} *s.conf = conf s.conf.limit = conf.LimitDays * 24 if conf.UnitID == nil { s.conf.UnitID = newUnitID } if !s.dbOpen() { return nil, fmt.Errorf("open database") }
</s> remove if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 </s> add if s.limitHours = conf.LimitDays * 24; !checkInterval(conf.LimitDays) { s.limitHours = 24 </s> remove if !s.dbOpen() { return nil, fmt.Errorf("open database") </s> add if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err) </s> remove s = &statsCtx{ mu: &sync.Mutex{}, </s> add s = &StatsCtx{ currMu: &sync.Mutex{}, dbMu: &sync.Mutex{}, filename: conf.Filename, configModified: conf.ConfigModified, httpRegister: conf.HTTPRegister, </s> remove id := s.conf.UnitID() tx := s.beginTxn(true) </s> add id := s.unitIDGen() tx := beginTxn(s.db, true) </s> remove func (s *statsCtx) setLimit(limitDays int) { s.conf.limit = uint32(limitDays) * 24 </s> add func (s *StatsCtx) setLimit(limitDays int) { atomic.StoreUint32(&s.limitHours, uint32(24*limitDays))
if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID
} if !checkInterval(conf.LimitDays) { conf.LimitDays = 1 } if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID } if !s.dbOpen() { return nil, fmt.Errorf("open database") }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
if conf.UnitID == nil { s.conf.UnitID = newUnitID } if !s.dbOpen() { return nil, fmt.Errorf("open database") } id := s.conf.UnitID() tx := s.beginTxn(true) var udb *unitDB
</s> remove id := s.conf.UnitID() tx := s.beginTxn(true) </s> add id := s.unitIDGen() tx := beginTxn(s.db, true) </s> remove s.conf = &Config{} *s.conf = conf s.conf.limit = conf.LimitDays * 24 if conf.UnitID == nil { s.conf.UnitID = newUnitID </s> add if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID </s> remove firstID := id - s.conf.limit - 1 </s> add firstID := id - s.limitHours - 1 </s> remove nu := unit{} s.initUnit(&nu, id) u := s.swapUnit(&nu) udb := serialize(u) </s> add nu := newUnit(id) u := s.swapCurrent(nu) udb := u.serialize() </s> remove func (s *statsCtx) loadUnitFromDB(tx *bolt.Tx, id uint32) *unitDB { </s> add func (s *StatsCtx) loadUnitFromDB(tx *bbolt.Tx, id uint32) *unitDB {
if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err)
if conf.UnitID == nil { s.conf.UnitID = newUnitID } if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err) if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err) } id := s.conf.UnitID() tx := s.beginTxn(true) var udb *unitDB
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
if !s.dbOpen() { return nil, fmt.Errorf("open database") } id := s.conf.UnitID() tx := s.beginTxn(true) var udb *unitDB if tx != nil { log.Tracef("Deleting old units...") firstID := id - s.conf.limit - 1 unitDel := 0
</s> remove firstID := id - s.conf.limit - 1 </s> add firstID := id - s.limitHours - 1 </s> remove if !s.dbOpen() { return nil, fmt.Errorf("open database") </s> add if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err) </s> remove curID := cur.id </s> add var curID uint32 if cur != nil { curID = atomic.LoadUint32(&cur.id) } else { curID = s.unitIDGen() } </s> remove s.conf = &Config{} *s.conf = conf s.conf.limit = conf.LimitDays * 24 if conf.UnitID == nil { s.conf.UnitID = newUnitID </s> add if s.unitIDGen = newUnitID; conf.UnitID != nil { s.unitIDGen = conf.UnitID </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) {
id := s.unitIDGen() tx := beginTxn(s.db, true)
if !s.dbOpen() { return nil, fmt.Errorf("open database") } id := s.unitIDGen() tx := beginTxn(s.db, true) id := s.unitIDGen() tx := beginTxn(s.db, true) var udb *unitDB if tx != nil { log.Tracef("Deleting old units...") firstID := id - s.conf.limit - 1 unitDel := 0
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
tx := s.beginTxn(true) var udb *unitDB if tx != nil { log.Tracef("Deleting old units...") firstID := id - s.conf.limit - 1 unitDel := 0 err = tx.ForEach(newBucketWalker(tx, &unitDel, firstID)) if err != nil && !errors.Is(err, errStop) { log.Debug("stats: deleting units: %s", err)
</s> remove id := s.conf.UnitID() tx := s.beginTxn(true) </s> add id := s.unitIDGen() tx := beginTxn(s.db, true) </s> remove if !s.dbOpen() { return nil, fmt.Errorf("open database") </s> add if err = s.dbOpen(); err != nil { return nil, fmt.Errorf("opening database: %w", err) </s> remove log.Error("db.Begin: %s", err) </s> add log.Error("stats: opening a transaction: %s", err) </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) { </s> remove ) (f func(name []byte, b *bolt.Bucket) (err error)) { return func(name []byte, _ *bolt.Bucket) (err error) { </s> add ) (f func(name []byte, b *bbolt.Bucket) (err error)) { return func(name []byte, _ *bbolt.Bucket) (err error) {
firstID := id - s.limitHours - 1
tx := s.beginTxn(true) var udb *unitDB if tx != nil { log.Tracef("Deleting old units...") firstID := id - s.limitHours - 1 unitDel := 0 err = tx.ForEach(newBucketWalker(tx, &unitDel, firstID)) if err != nil && !errors.Is(err, errStop) { log.Debug("stats: deleting units: %s", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
} } } u := unit{} s.initUnit(&u, id) if udb != nil { deserialize(&u, udb) } s.current = &u log.Debug("stats: initialized") return s, nil }
</s> remove nu := unit{} s.initUnit(&nu, id) u := s.swapUnit(&nu) udb := serialize(u) </s> add nu := newUnit(id) u := s.swapCurrent(nu) udb := u.serialize() </s> remove func (s *statsCtx) Close() { u := s.swapUnit(nil) udb := serialize(u) tx := s.beginTxn(true) if tx != nil { if s.flushUnitToDB(tx, u.id, udb) { </s> add func (s *StatsCtx) Close() { u := s.swapCurrent(nil) db := s.database() if tx := beginTxn(db, true); tx != nil { udb := u.serialize() if flushUnitToDB(tx, u.id, udb) { </s> remove u := unit{} s.initUnit(&u, s.conf.UnitID()) _ = s.swapUnit(&u) </s> add u := newUnit(s.unitIDGen()) _ = s.swapCurrent(u) </s> remove err := os.Remove(s.conf.Filename) </s> add err := os.Remove(s.filename) </s> remove s.mu.Lock() defer s.mu.Unlock() </s> add u := s.ongoing() if u == nil { return }
u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u
} } } u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u u := newUnit(id) // This use of deserialize is safe since the accessed unit has just been // created. u.deserialize(udb) s.curr = u log.Debug("stats: initialized") return s, nil }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go
// newBucketWalker returns a new bucket walker that deletes old units. The // integer that unitDelPtr points to is incremented for every successful // deletion. If the bucket isn't deleted, f returns errStop. func newBucketWalker( tx *bolt.Tx, unitDelPtr *int, firstID uint32, ) (f func(name []byte, b *bolt.Bucket) (err error)) { return func(name []byte, _ *bolt.Bucket) (err error) { nameID, ok := unitNameToID(name)
</s> remove ) (f func(name []byte, b *bolt.Bucket) (err error)) { return func(name []byte, _ *bolt.Bucket) (err error) { </s> add ) (f func(name []byte, b *bbolt.Bucket) (err error)) { return func(name []byte, _ *bbolt.Bucket) (err error) { </s> remove // Open a DB transaction func (s *statsCtx) beginTxn(wr bool) *bolt.Tx { db := s.db </s> add // beginTxn opens a new database transaction. If writable is true, the // transaction will be opened for writing, and for reading otherwise. It // returns nil if the transaction can't be created. func beginTxn(db *bbolt.DB, writable bool) (tx *bbolt.Tx) { </s> remove func (s *statsCtx) ongoing() (u *unit) { s.mu.Lock() defer s.mu.Unlock() return s.current } </s> add </s> remove type unitIDCallback func() uint32 </s> add // UnitIDGenFunc is the signature of a function that generates a unique ID for // the statistics unit. type UnitIDGenFunc func() (id uint32) </s> remove return name </s> add return n[:]
tx *bbolt.Tx,
// newBucketWalker returns a new bucket walker that deletes old units. The // integer that unitDelPtr points to is incremented for every successful // deletion. If the bucket isn't deleted, f returns errStop. func newBucketWalker( tx *bbolt.Tx, unitDelPtr *int, firstID uint32, ) (f func(name []byte, b *bolt.Bucket) (err error)) { return func(name []byte, _ *bolt.Bucket) (err error) { nameID, ok := unitNameToID(name)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
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 5683cb304688ea639e5ba7f219a7bf12370211a4 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 18:20:54 2022 +0300 stats: rm races test commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 17:13:36 2022 +0300 stats: try to imp test commit 59a0f249fc00566872db62e362c87bc0c201b333 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 16:38:57 2022 +0300 stats: fix nil ptr deref commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572 Author: Eugene Burkov <[email protected]> Date: Thu Apr 7 16:02:51 2022 +0300 stats: fix races finally, imp tests commit c63f5f4e7929819fe79b3a1e392f6b91cd630846 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:56:49 2022 +0300 aghhttp: add register func commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411 Merge: edbdb2d4 9b3adac1 Author: Eugene Burkov <[email protected]> Date: Thu Aug 4 00:36:01 2022 +0300 Merge branch 'master' into 4358-fix-stats commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907 Merge: a91e4d7a a481ff4c Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 21:00:42 2022 +0300 Merge branch 'master' into 4358-fix-stats commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:46:19 2022 +0300 stats: imp code, docs commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:16:13 2022 +0300 all: log changes commit 5e6caafc771dddc4c6be07c34658de359106fbe5 Merge: 091ba756 eb8e8166 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:09:10 2022 +0300 Merge branch 'master' into 4358-fix-stats commit 091ba75618d3689b9c04f05431283417c8cc52f9 Author: Eugene Burkov <[email protected]> Date: Wed Aug 3 18:07:39 2022 +0300 stats: imp docs, code commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a Author: Eugene Burkov <[email protected]> Date: Tue Aug 2 17:09:30 2022 +0300 all: refactor stats & add mutexes commit b3f11c455ceaa3738ec20eefc46f866ff36ed046 Author: Eugene Burkov <[email protected]> Date: Wed Apr 27 15:30:09 2022 +0300 WIP
https://github.com/AdguardTeam/AdGuardHome/commit/4293cf5945a9331fd8ce1eb33a88865c6b8713cc
internal/stats/unit.go