docstring_tokens stringlengths 0 76.5k | code_tokens stringlengths 75 1.81M | label_window listlengths 4 2.12k | html_url stringlengths 74 116 | file_name stringlengths 3 311 |
|---|---|---|---|---|
if lease.Expiry.Unix() <= now && lease.Expiry.Unix() != leaseExpireStatic { | <mask> // Find an expired lease and return its index or -1
<mask> func (s *Server) findExpiredLease() int {
<mask> now := time.Now().Unix()
<mask> for i, lease := range s.leases {
<mask> if lease.Expiry.Unix() <= now {
<mask> return i
<mask> }
<mask> }
<mask> return -1
<mask> }
</s> + dhcp: /dhcp/... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/725aeeb910eeb69fc7463cd2492eaf97e4863868 | dhcpd/dhcpd.go |
github.com/AdguardTeam/urlfilter v0.15.1 | <mask>
<mask> require (
<mask> github.com/AdguardTeam/dnsproxy v0.39.13
<mask> github.com/AdguardTeam/golibs v0.10.3
<mask> github.com/AdguardTeam/urlfilter v0.15.0
<mask> github.com/NYTimes/gziphandler v1.1.1
<mask> github.com/ameshkov/dnscrypt/v2 v2.2.2
<mask> github.com/digineo/go-ipset/v2 v2.2.1
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/72a160ac59395cd700d270eaf7234c95c62533ea | go.mod |
<mask> github.com/mdlayher/netlink v1.4.0
<mask> github.com/mdlayher/raw v0.0.0-20210412142147-51b895745faf
<mask> github.com/miekg/dns v1.1.43
<mask> github.com/satori/go.uuid v1.2.0
<mask> github.com/stretchr/objx v0.1.1 // indirect
<mask> github.com/stretchr/testify v1.7.0
<mask> github.com/ti-mo/netfi... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/72a160ac59395cd700d270eaf7234c95c62533ea | go.mod | |
require github.com/stretchr/objx v0.1.1 // indirect
| <mask> )
<mask>
<mask> // TODO(e.burkov): Get rid of the fork in v0.108.0.
<mask> replace github.com/insomniacslk/dhcp => github.com/AdguardTeam/dhcp v0.0.0-20210519141215-51808c73c0bf
</s> Pull request: all: do not apply $denyallow to ip addrs
Closes #3175.
Squashed commit of the following:
commit e80e4610a1... | [
"keep",
"add",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/72a160ac59395cd700d270eaf7234c95c62533ea | go.mod |
github.com/AdguardTeam/urlfilter v0.15.1 h1:dP6S7J6eFAk8MN4IDpUq2fZoBo8K8fmc6pXpxNIv84M=
github.com/AdguardTeam/urlfilter v0.15.1/go.mod h1:EwXwrYhowP7bedqmOrmKKmQtpBYFyDNEBFQ+lxdUgQU= | <mask> github.com/AdguardTeam/golibs v0.9.2/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY=
<mask> github.com/AdguardTeam/golibs v0.10.3 h1:FBgk17zf35ESVWQKIqEUiqqB2bDaCBC8X5vMU760yB4=
<mask> github.com/AdguardTeam/golibs v0.10.3/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw=
<mask> github.com/Adguar... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/72a160ac59395cd700d270eaf7234c95c62533ea | go.sum |
<mask> .logs__row:hover .button-action,
<mask> .button-action--active {
<mask> visibility: visible;
<mask> }
<mask>
<mask> @media (max-width: 500px) {
<mask> .dashboard .button-action {
<mask> visibility: visible;
<mask> }
<mask> }
</s> - client: 2152 Do not show dashboard buttons on mob... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace"
] | https://github.com/AdguardTeam/AdGuardHome/commit/72ab51bce0dd0b892acc797689f0cd32d779fd9f | client/src/components/App/index.css | |
}) => <div className="card-actions">
<button
className="btn btn-success btn-standard mr-2 btn-large mb-2" | <mask> import { withTranslation, Trans } from 'react-i18next';
<mask>
<mask> const Actions = ({
<mask> handleAdd, handleRefresh, processingRefreshFilters, whitelist,
<mask> }) => (
<mask> <div className="card-actions">
<mask> <button
<mask> className="btn btn-success btn-standard mr... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/72ab51bce0dd0b892acc797689f0cd32d779fd9f | client/src/components/Filters/Actions.js |
>
{whitelist ? <Trans>add_allowlist</Trans> : <Trans>add_blocklist</Trans>}
</button>
<button
className="btn btn-primary btn-standard mb-2" | <mask> <button
<mask> className="btn btn-success btn-standard mr-2 btn-large"
<mask> type="submit"
<mask> onClick={handleAdd}
<mask> >
<mask> {whitelist ? (
<mask> <Trans>add_allowlist</Trans>
<mask> ) : (
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/72ab51bce0dd0b892acc797689f0cd32d779fd9f | client/src/components/Filters/Actions.js |
>
<Trans>check_updates_btn</Trans>
</button>
</div>; | <mask> className="btn btn-primary btn-standard"
<mask> type="submit"
<mask> onClick={handleRefresh}
<mask> disabled={processingRefreshFilters}
<mask> >
<mask> <Trans>check_updates_btn</Trans>
<mask> </button>
<mask> </div>
<mask> )... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/72ab51bce0dd0b892acc797689f0cd32d779fd9f | client/src/components/Filters/Actions.js |
// This callback function returns the list of upstream servers for a client specified by IP address
GetUpstreamsByClient func(clientAddr string) []string `yaml:"-"`
| <mask> type FilteringConfig struct {
<mask> // Filtering callback function
<mask> FilterHandler func(clientAddr string, settings *dnsfilter.RequestFilteringSettings) `yaml:"-"`
<mask>
<mask> ProtectionEnabled bool `yaml:"protection_enabled"` // whether or not use any of dnsfilter features
<mask>
<mask> Blo... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | dnsforward/dnsforward.go |
if d.Addr != nil && s.conf.GetUpstreamsByClient != nil {
clientIP, _, _ := net.SplitHostPort(d.Addr.String())
upstreams := s.conf.GetUpstreamsByClient(clientIP)
for _, us := range upstreams {
u, err := upstream.AddressToUpstream(us, upstream.Options{Timeout: 30 * time.Second})
if err != nil {
lo... | <mask> // resolve canonical name, not the original host name
<mask> d.Req.Question[0].Name = dns.Fqdn(res.CanonName)
<mask> }
<mask>
<mask> // request was not filtered so let it be processed further
<mask> err = p.Resolve(d)
<mask> if err != nil {
<mask> return err
<mask> }
</s> + use per-... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | dnsforward/dnsforward.go |
err = ValidateUpstreams(req.Upstreams) | <mask> httpError(r, w, http.StatusBadRequest, "Failed to parse new upstreams config json: %s", err)
<mask> return
<mask> }
<mask>
<mask> err = validateUpstreams(req.Upstreams)
<mask> if err != nil {
<mask> httpError(r, w, http.StatusBadRequest, "wrong upstreams specification: %s", err)
<mask> return... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | dnsforward/dnsforward_http.go |
// ValidateUpstreams validates each upstream and returns an error if any upstream is invalid or if there are no default upstreams specified
func ValidateUpstreams(upstreams []string) error { | <mask> return
<mask> }
<mask> }
<mask>
<mask> // validateUpstreams validates each upstream and returns an error if any upstream is invalid or if there are no default upstreams specified
<mask> func validateUpstreams(upstreams []string) error {
<mask> var defaultUpstreamFound bool
<mask> for _, u := range ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | dnsforward/dnsforward_http.go |
err := ValidateUpstreams(upstreamsSet) | <mask> "[/www.host.com/]#",
<mask> "[/host.com/google.com/]8.8.8.8",
<mask> "[/host/]sdns://AQMAAAAAAAAAFDE3Ni4xMDMuMTMwLjEzMDo1NDQzINErR_JS3PLCu_iZEIbq95zkSV2LFsigxDIuUso_OQhzIjIuZG5zY3J5cHQuZGVmYXVsdC5uczEuYWRndWFyZC5jb20",
<mask> }
<mask> err := validateUpstreams(upstreamsSet)
<mask> if err == nil {
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | dnsforward/dnsforward_test.go |
err = ValidateUpstreams(upstreamsSet) | <mask> }
<mask>
<mask> // Let's add default upstream
<mask> upstreamsSet = append(upstreamsSet, "8.8.8.8")
<mask> err = validateUpstreams(upstreamsSet)
<mask> if err != nil {
<mask> t.Fatalf("upstreams set is valid, but doesn't pass through validation cause: %s", err)
<mask> }
<mask>
<mask> // Let'... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | dnsforward/dnsforward_test.go |
err = ValidateUpstreams(upstreamsSet) | <mask> }
<mask>
<mask> // Let's add invalid upstream
<mask> upstreamsSet = append(upstreamsSet, "dhcp://fake.dns")
<mask> err = validateUpstreams(upstreamsSet)
<mask> if err == nil {
<mask> t.Fatalf("there is an invalid upstream in set, but it pass through validation")
<mask> }
<mask> }
</s> + use pe... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | dnsforward/dnsforward_test.go |
"github.com/AdguardTeam/AdGuardHome/dnsforward" | <mask> "sync"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/dhcpd"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/utils"
<mask> )
<mask>
</s> + use per-client DNS servers </s> remove err = validateUpstreams(req.Upstreams)
</s> add err = ValidateUpst... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/clients.go |
Upstreams []string // list of upstream servers to be used for the client's requests | <mask> WhoisInfo [][]string // [[key,value], ...]
<mask>
<mask> UseOwnBlockedServices bool // false: use global settings
<mask> BlockedServices []string
<mask> }
<mask>
<mask> type clientSource uint
<mask>
<mask> // Client sources
</s> + use per-client DNS servers </s> remove err = vali... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/clients.go |
Upstreams []string `yaml:"upstreams"` | <mask> SafeBrowsingEnabled bool `yaml:"safesearch_enabled"`
<mask>
<mask> UseGlobalBlockedServices bool `yaml:"use_global_blocked_services"`
<mask> BlockedServices []string `yaml:"blocked_services"`
<mask> }
<mask>
<mask> func (clients *clientsContainer) addFromConfig(objects []clientObject... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/clients.go |
Upstreams: cy.Upstreams, | <mask> SafeBrowsingEnabled: cy.SafeBrowsingEnabled,
<mask>
<mask> UseOwnBlockedServices: !cy.UseGlobalBlockedServices,
<mask> BlockedServices: cy.BlockedServices,
<mask> }
<mask> _, err := clients.Add(cli)
<mask> if err != nil {
<mask> log.Tracef("clientAdd: %s", err)
<mask> }
</s> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/clients.go |
Upstreams: cli.Upstreams, | <mask> SafeBrowsingEnabled: cli.SafeBrowsingEnabled,
<mask>
<mask> UseGlobalBlockedServices: !cli.UseOwnBlockedServices,
<mask> BlockedServices: cli.BlockedServices,
<mask> }
<mask> *objects = append(*objects, cy)
<mask> }
<mask> }
<mask>
<mask> func (clients *clientsContainer) period... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/clients.go |
if len(c.Upstreams) != 0 {
err := dnsforward.ValidateUpstreams(c.Upstreams)
if err != nil {
return fmt.Errorf("Invalid upstream servers: %s", err)
}
}
| <mask> return fmt.Errorf("Invalid ID: %s", id)
<mask> }
<mask> return nil
<mask> }
<mask>
<mask> // Add a new client object
</s> + use per-client DNS servers </s> remove err = validateUpstreams(req.Upstreams)
</s> add err = ValidateUpstreams(req.Upstreams) | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/clients.go |
Upstreams []string `json:"upstreams"` | <mask>
<mask> UseGlobalBlockedServices bool `json:"use_global_blocked_services"`
<mask> BlockedServices []string `json:"blocked_services"`
<mask> }
<mask>
<mask> type clientHostJSON struct {
<mask> IP string `json:"ip"`
</s> + use per-client DNS servers | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/clients_http.go |
Upstreams: cj.Upstreams, | <mask>
<mask> UseOwnBlockedServices: !cj.UseGlobalBlockedServices,
<mask> BlockedServices: cj.BlockedServices,
<mask> }
<mask> return &c, nil
<mask> }
<mask>
<mask> // Convert Client object to JSON
<mask> func clientToJSON(c *Client) clientJSON {
</s> + use per-client DNS servers | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/clients_http.go |
Upstreams: c.Upstreams, | <mask> SafeBrowsingEnabled: c.SafeBrowsingEnabled,
<mask>
<mask> UseGlobalBlockedServices: !c.UseOwnBlockedServices,
<mask> BlockedServices: c.BlockedServices,
<mask> }
<mask>
<mask> cj.WhoisInfo = make(map[string]interface{})
<mask> for _, wi := range c.WhoisInfo {
<mask> cj.WhoisInfo[wi... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/clients_http.go |
newconfig.GetUpstreamsByClient = getUpstreamsByClient | <mask> }
<mask> }
<mask>
<mask> newconfig.FilterHandler = applyAdditionalFiltering
<mask> return newconfig, nil
<mask> }
<mask>
<mask> func getUpstreamsByClient(clientAddr string) []string {
<mask> c, ok := config.clients.Find(clientAddr)
</s> + use per-client DNS servers | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/dns.go |
func getUpstreamsByClient(clientAddr string) []string {
c, ok := config.clients.Find(clientAddr)
if !ok {
return []string{}
}
log.Debug("Using upstreams %v for client %s (IP: %s)", c.Upstreams, c.Name, clientAddr)
return c.Upstreams
}
| <mask> return newconfig, nil
<mask> }
<mask>
<mask> // If a client has his own settings, apply them
<mask> func applyAdditionalFiltering(clientAddr string, setts *dnsfilter.RequestFilteringSettings) {
<mask>
<mask> ApplyBlockedServices(setts, config.DNS.BlockedServices)
<mask>
</s> + use per-client DNS se... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/7313c3bc5387cdc77f9f688e846a4a4aca5b1ec8 | home/dns.go |
var _ wrapper = &manyError{}
| <mask> }
<mask>
<mask> func TestError_Unwrap(t *testing.T) {
<mask> const (
<mask> errSimple = iota
<mask> errWrapped
<mask> errNil
</s> Pull request: all: fix lint and naming issues vol. 4
Merge in DNS/adguard-home from 2276-fix-lint-4 to master
Updates #2276.
Squashed commit of the following:
comm... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73c30590e015f55e3de0a01f98a3c79761dce3b7 | internal/agherr/agherr_test.go |
<mask> // NotFilteredNotFound - host was not find in any checks, default value for result
<mask> NotFilteredNotFound Reason = iota
<mask> // NotFilteredWhiteList - the host is explicitly whitelisted
<mask> NotFilteredWhiteList
<mask> // NotFilteredError - there was a transitive error during check
<mask> Not... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73c30590e015f55e3de0a01f98a3c79761dce3b7 | internal/dnsfilter/dnsfilter.go | |
<mask> d.registerRewritesHandlers()
<mask> d.registerBlockedServicesHandlers()
<mask> }
<mask> }
<mask>
<mask> //
<mask> // stats
<mask> //
<mask>
<mask> // GetStats return dns filtering stats since startup.
<mask> func (d *Dnsfilter) GetStats() Stats {
<mask> return gctx.stats
<mask> }
</s> Pull ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73c30590e015f55e3de0a01f98a3c79761dce3b7 | internal/dnsfilter/dnsfilter.go | |
<mask>
<mask> package sysutil
<mask>
<mask> import (
<mask> "log"
<mask> "log/syslog"
<mask> )
<mask>
<mask> func configureSyslog(serviceName string) error {
<mask> w, err := syslog.New(syslog.LOG_NOTICE|syslog.LOG_USER, serviceName)
</s> Pull request: all: fix lint and naming issues vol. 4
Merge in D... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73c30590e015f55e3de0a01f98a3c79761dce3b7 | internal/sysutil/syslog_others.go | |
"github.com/AdguardTeam/golibs/log" | <mask> package sysutil
<mask>
<mask> import (
<mask> "log/syslog"
<mask> )
<mask>
<mask> func configureSyslog(serviceName string) error {
<mask> w, err := syslog.New(syslog.LOG_NOTICE|syslog.LOG_USER, serviceName)
<mask> if err != nil {
</s> Pull request: all: fix lint and naming issues vol. 4
Merge in ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73c30590e015f55e3de0a01f98a3c79761dce3b7 | internal/sysutil/syslog_others.go |
<mask>
<mask> package sysutil
<mask>
<mask> import (
<mask> "log"
<mask> "strings"
<mask>
<mask> "golang.org/x/sys/windows"
<mask> "golang.org/x/sys/windows/svc/eventlog"
<mask> )
</s> Pull request: all: fix lint and naming issues vol. 4
Merge in DNS/adguard-home from 2276-fix-lint-4 to master
Updat... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73c30590e015f55e3de0a01f98a3c79761dce3b7 | internal/sysutil/syslog_windows.go | |
"github.com/AdguardTeam/golibs/log" | <mask>
<mask> import (
<mask> "strings"
<mask>
<mask> "golang.org/x/sys/windows"
<mask> "golang.org/x/sys/windows/svc/eventlog"
<mask> )
<mask>
</s> Pull request: all: fix lint and naming issues vol. 4
Merge in DNS/adguard-home from 2276-fix-lint-4 to master
Updates #2276.
Squashed commit of the follo... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73c30590e015f55e3de0a01f98a3c79761dce3b7 | internal/sysutil/syslog_windows.go |
<mask> "fmt"
<mask> "io/ioutil"
<mask> "os"
<mask> "os/exec"
<mask> "path"
<mask> "runtime"
<mask> "strings"
<mask> )
<mask>
<mask> // ContainsString checks if string is in the slice of strings.
</s> Pull request: all: fix lint and naming issues vol. 4
Merge in DNS/adguard-home from 2276-fix-lint-4 ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73c30590e015f55e3de0a01f98a3c79761dce3b7 | internal/util/helpers.go | |
<mask>
<mask> return cmd.ProcessState.ExitCode(), string(out), nil
<mask> }
<mask>
<mask> func FuncName() string {
<mask> pc := make([]uintptr, 10) // at least 1 entry needed
<mask> runtime.Callers(2, pc)
<mask> f := runtime.FuncForPC(pc[0])
<mask> return path.Base(f.Name())
<mask> }
<mask>
<mask> /... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73c30590e015f55e3de0a01f98a3c79761dce3b7 | internal/util/helpers.go | |
// Copy installation parameters between two configuration objects
func copyInstallSettings(dst *configuration, src *configuration) {
dst.BindHost = src.BindHost
dst.BindPort = src.BindPort
dst.DNS.BindHost = src.DNS.BindHost
dst.DNS.Port = src.DNS.Port
dst.AuthName = src.AuthName
dst.AuthPass = src.AuthPass
}
| <mask> }
<mask>
<mask> // Apply new configuration, start DNS server, restart Web server
<mask> func handleInstallConfigure(w http.ResponseWriter, r *http.Request) {
<mask> log.Tracef("%s %v", r.Method, r.URL)
<mask> newSettings := applyConfigReq{}
</s> * control: /install/configure: reset configuration back t... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73fbe8b95aca6092b0beb7327a9c811a32464bcc | control.go |
var curConfig configuration
copyInstallSettings(&curConfig, &config)
| <mask> return
<mask> }
<mask>
<mask> config.firstRun = false
<mask> config.BindHost = newSettings.Web.IP
<mask> config.BindPort = newSettings.Web.Port
<mask> config.DNS.BindHost = newSettings.DNS.IP
<mask> config.DNS.Port = newSettings.DNS.Port
</s> * control: /install/configure: reset configuration b... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73fbe8b95aca6092b0beb7327a9c811a32464bcc | control.go |
err = startDNSServer()
if err != nil {
config.firstRun = true
copyInstallSettings(&config, &curConfig)
httpError(w, http.StatusInternalServerError, "Couldn't start DNS server: %s", err)
return
}
err = config.write()
if err != nil {
config.firstRun = true
copyInstallSettings(&config, &curConfig)
http... | <mask> config.DNS.Port = newSettings.DNS.Port
<mask> config.AuthName = newSettings.Username
<mask> config.AuthPass = newSettings.Password
<mask>
<mask> if config.DNS.Port != 0 {
<mask> err = startDNSServer()
<mask> if err != nil {
<mask> httpError(w, http.StatusInternalServerError, "Couldn't start D... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73fbe8b95aca6092b0beb7327a9c811a32464bcc | control.go |
<mask> return
<mask> }
<mask> }
<mask>
<mask> httpUpdateConfigReloadDNSReturnOK(w, r)
<mask> // this needs to be done in a goroutine because Shutdown() is a blocking call, and it will block
<mask> // until all requests are finished, and _we_ are inside a request right now, so it will block indefinitely... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73fbe8b95aca6092b0beb7327a9c811a32464bcc | control.go | |
returnOK(w) | <mask> }()
<mask> }
<mask> }
<mask>
<mask> // --------------
<mask> // DNS-over-HTTPS
<mask> // --------------
<mask> func handleDOH(w http.ResponseWriter, r *http.Request) {
</s> * control: /install/configure: reset configuration back to its current state on error </s> remove httpUpdateConfigReloadDNSRet... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/73fbe8b95aca6092b0beb7327a9c811a32464bcc | control.go |
"encoding/json" | <mask> package querylog
<mask>
<mask> import (
<mask> "fmt"
<mask> "math"
<mask> "net"
<mask> "net/http"
</s> Pull request: rm-jsonutil
Merge in DNS/adguard-home from rm-jsonutil to master
Squashed commit of the following:
commit dec746d321adbeb41bfd0c44e71d198809c4731e
Author: Ainar Garipov <A.Garipov@... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
"math" | <mask>
<mask> import (
<mask> "encoding/json"
<mask> "fmt"
<mask> "net"
<mask> "net/http"
<mask> "net/url"
<mask> "strconv"
<mask> "strings"
<mask> "time"
</s> Pull request: rm-jsonutil
Merge in DNS/adguard-home from rm-jsonutil to master
Squashed commit of the following:
commit dec746d321adbeb41... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
"github.com/AdguardTeam/AdGuardHome/internal/aghalg" | <mask> "strconv"
<mask> "strings"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/stringutil"
<mask> "github.com/AdguardTeam/golibs/timeutil"
</s> Pull request: rm-jsonutil
Merge in DNS/a... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
<mask> "strings"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/golibs/jsonutil"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/stringutil"
<mask> "github.com/AdguardTeam/golibs/timeutil"
<mask> "golang... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go | |
// configJSON is the JSON structure for the querylog configuration.
type configJSON struct {
// Interval is the querylog rotation interval. Use float64 here to support
// fractional numbers and not mess the API users by changing the units.
Interval float64 `json:"interval"`
// Enabled shows if the querylog is ena... | <mask> "github.com/AdguardTeam/golibs/timeutil"
<mask> "golang.org/x/net/idna"
<mask> )
<mask>
<mask> type qlogConfig struct {
<mask> // Use float64 here to support fractional numbers and not mess the API
<mask> // users by changing the units.
<mask> Interval float64 `json:"interval"`
<mask> En... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
_ = aghhttp.WriteJSONResponse(w, r, configJSON{
Enabled: aghalg.BoolToNullBool(l.conf.Enabled), | <mask> }
<mask>
<mask> // Get configuration
<mask> func (l *queryLog) handleQueryLogInfo(w http.ResponseWriter, r *http.Request) {
<mask> resp := qlogConfig{
<mask> Enabled: l.conf.Enabled,
<mask> Interval: l.conf.RotationIvl.Hours() / 24,
<mask> AnonymizeClientIP: l.conf.AnonymizeCli... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
AnonymizeClientIP: aghalg.BoolToNullBool(l.conf.AnonymizeClientIP),
}) | <mask> func (l *queryLog) handleQueryLogInfo(w http.ResponseWriter, r *http.Request) {
<mask> resp := qlogConfig{
<mask> Enabled: l.conf.Enabled,
<mask> Interval: l.conf.RotationIvl.Hours() / 24,
<mask> AnonymizeClientIP: l.conf.AnonymizeClientIP,
<mask> }
<mask>
<mask> _ = aghhttp.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
// handleQueryLogConfig handles the POST /control/querylog_config queries. | <mask> copy(ip[net.IPv6len-10:net.IPv6len], zeroes)
<mask> }
<mask> }
<mask>
<mask> // Set configuration
<mask> func (l *queryLog) handleQueryLogConfig(w http.ResponseWriter, r *http.Request) {
<mask> d := &qlogConfig{}
<mask> req, err := jsonutil.DecodeObject(d, r.Body)
<mask> if err != nil {
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
// Set NaN as initial value to be able to know if it changed later by
// comparing it to NaN.
newConf := &configJSON{
Interval: math.NaN(),
}
err := json.NewDecoder(r.Body).Decode(newConf) | <mask> }
<mask>
<mask> // Set configuration
<mask> func (l *queryLog) handleQueryLogConfig(w http.ResponseWriter, r *http.Request) {
<mask> d := &qlogConfig{}
<mask> req, err := jsonutil.DecodeObject(d, r.Body)
<mask> if err != nil {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "%s", err)
<mask>
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
ivl := time.Duration(float64(timeutil.Day) * newConf.Interval)
hasIvl := !math.IsNaN(newConf.Interval)
if hasIvl && !checkInterval(ivl) {
aghhttp.Error(r, w, http.StatusBadRequest, "unsupported interval") | <mask>
<mask> return
<mask> }
<mask>
<mask> ivl := time.Duration(float64(timeutil.Day) * d.Interval)
<mask> if req.Exists("interval") && !checkInterval(ivl) {
<mask> aghhttp.Error(r, w, http.StatusBadRequest, "Unsupported interval")
<mask>
<mask> return
<mask> }
<mask>
<mask> defer l.conf.Con... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
if newConf.Enabled != aghalg.NBNull {
conf.Enabled = newConf.Enabled == aghalg.NBTrue | <mask>
<mask> // Copy data, modify it, then activate. Other threads (readers) don't need
<mask> // to use this lock.
<mask> conf := *l.conf
<mask> if req.Exists("enabled") {
<mask> conf.Enabled = d.Enabled
<mask> }
<mask> if req.Exists("interval") {
<mask> conf.RotationIvl = ivl
<mask> }
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
if hasIvl { | <mask> conf := *l.conf
<mask> if req.Exists("enabled") {
<mask> conf.Enabled = d.Enabled
<mask> }
<mask> if req.Exists("interval") {
<mask> conf.RotationIvl = ivl
<mask> }
<mask> if req.Exists("anonymize_client_ip") {
<mask> if conf.AnonymizeClientIP = d.AnonymizeClientIP; conf.AnonymizeClientIP {
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
if newConf.AnonymizeClientIP != aghalg.NBNull {
conf.AnonymizeClientIP = newConf.AnonymizeClientIP == aghalg.NBTrue
if conf.AnonymizeClientIP { | <mask> }
<mask> if req.Exists("interval") {
<mask> conf.RotationIvl = ivl
<mask> }
<mask> if req.Exists("anonymize_client_ip") {
<mask> if conf.AnonymizeClientIP = d.AnonymizeClientIP; conf.AnonymizeClientIP {
<mask> l.anonymizer.Store(AnonymizeIP)
<mask> } else {
<mask> l.anonymizer.Store(nil)... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/746e9df727866a2ae90f1533fd2ee92f4d914de2 | internal/querylog/http.go |
log.Println(text) | <mask> }
<mask>
<mask> func httpError(w http.ResponseWriter, code int, format string, args ...interface{}) {
<mask> text := fmt.Sprintf(format, args...)
<mask> http.Error(w, text, code)
<mask> }
<mask>
<mask> func handleSetUpstreamDNS(w http.ResponseWriter, r *http.Request) {
</s> API filtering/add_url -- ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
filter := filter{}
err := json.NewDecoder(r.Body).Decode(&filter) | <mask> }
<mask> }
<mask>
<mask> func handleFilteringAddURL(w http.ResponseWriter, r *http.Request) {
<mask> parameters, err := parseParametersFromBody(r.Body)
<mask> if err != nil {
<mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err)
<mask> log.Println(errortext)
<mask> h... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
httpError(w, http.StatusBadRequest, "Failed to parse request body json: %s", err) | <mask>
<mask> func handleFilteringAddURL(w http.ResponseWriter, r *http.Request) {
<mask> parameters, err := parseParametersFromBody(r.Body)
<mask> if err != nil {
<mask> errortext := fmt.Sprintf("failed to parse parameters from body: %s", err)
<mask> log.Println(errortext)
<mask> http.Error(w, errortex... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
filter.Enabled = true
if len(filter.URL) == 0 { | <mask> http.Error(w, errortext, 400)
<mask> return
<mask> }
<mask>
<mask> url, ok := parameters["url"]
<mask> if !ok {
<mask> http.Error(w, "URL parameter was not specified", 400)
<mask> return
<mask> }
<mask>
<mask> if valid := govalidator.IsRequestURL(url); !valid {
</s> API filtering/add_u... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
if valid := govalidator.IsRequestURL(filter.URL); !valid { | <mask> http.Error(w, "URL parameter was not specified", 400)
<mask> return
<mask> }
<mask>
<mask> if valid := govalidator.IsRequestURL(url); !valid {
<mask> http.Error(w, "URL parameter is not valid request URL", 400)
<mask> return
<mask> }
<mask>
<mask> // check for duplicates
</s> API filteri... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
if config.Filters[i].URL == filter.URL {
errortext := fmt.Sprintf("Filter URL already added -- %s", filter.URL) | <mask> }
<mask>
<mask> // check for duplicates
<mask> for i := range config.Filters {
<mask> filter := &config.Filters[i]
<mask> if filter.URL == url {
<mask> errortext := fmt.Sprintf("Filter URL already added -- %s", url)
<mask> log.Println(errortext)
<mask> http.Error(w, errortext, http.Stat... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
ok, err := filter.update(time.Now()) | <mask> return
<mask> }
<mask> }
<mask>
<mask> var filter = filter{
<mask> Enabled: true,
<mask> URL: url,
<mask> }
<mask> ok, err = filter.update(time.Now())
<mask> if err != nil {
<mask> errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", url, err)
<mask> log.Println(er... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", filter.URL, err) | <mask> URL: url,
<mask> }
<mask> ok, err = filter.update(time.Now())
<mask> if err != nil {
<mask> errortext := fmt.Sprintf("Couldn't fetch filter from url %s: %s", url, err)
<mask> log.Println(errortext)
<mask> http.Error(w, errortext, http.StatusBadRequest)
<mask> return
<mask> }
<mask> i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", filter.URL) | <mask> http.Error(w, errortext, http.StatusBadRequest)
<mask> return
<mask> }
<mask> if filter.RulesCount == 0 {
<mask> errortext := fmt.Sprintf("Filter at url %s has no rules (maybe it points to blank page?)", url)
<mask> log.Println(errortext)
<mask> http.Error(w, errortext, http.StatusBadRequest)
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", filter.URL) | <mask> http.Error(w, errortext, http.StatusBadRequest)
<mask> return
<mask> }
<mask> if !ok {
<mask> errortext := fmt.Sprintf("Filter at url %s is invalid (maybe it points to blank page?)", url)
<mask> log.Println(errortext)
<mask> http.Error(w, errortext, http.StatusBadRequest)
<mask> return
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/751be05a31e8479fb0e8ca318260264466871b16 | control.go |
const normalizedRules = {
rules: normalizeRulesTextarea(rules)?.split('\n'),
}; | <mask>
<mask> export const setRules = (rules) => async (dispatch) => {
<mask> dispatch(setRulesRequest());
<mask> try {
<mask> const normalizedRules = normalizeRulesTextarea(rules);
<mask> await apiClient.setRules(normalizedRules);
<mask> dispatch(addSuccessToast('updated_custom_... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/actions/filtering.js |
await apiClient.changeLanguage({ language: lang }); | <mask>
<mask> export const changeLanguage = (lang) => async (dispatch) => {
<mask> dispatch(changeLanguageRequest());
<mask> try {
<mask> await apiClient.changeLanguage(lang);
<mask> dispatch(changeLanguageSuccess());
<mask> } catch (error) {
<mask> dispatch(addErrorToast({ ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/actions/index.js |
const langSettings = await apiClient.getCurrentLanguage();
dispatch(getLanguageSuccess(langSettings.language)); | <mask>
<mask> export const getLanguage = () => async (dispatch) => {
<mask> dispatch(getLanguageRequest());
<mask> try {
<mask> const language = await apiClient.getCurrentLanguage();
<mask> dispatch(getLanguageSuccess(language));
<mask> } catch (error) {
<mask> dispatch(addE... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/actions/index.js |
const req = {
interface: name,
};
const activeDhcp = await apiClient.findActiveDhcp(req); | <mask>
<mask> export const findActiveDhcp = (name) => async (dispatch, getState) => {
<mask> dispatch(findActiveDhcpRequest());
<mask> try {
<mask> const activeDhcp = await apiClient.findActiveDhcp(name);
<mask> dispatch(findActiveDhcpSuccess(activeDhcp));
<mask> const { check, i... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/actions/index.js |
headers: { 'Content-Type': 'application/json' }, | <mask> setRules(rules) {
<mask> const { path, method } = this.FILTERING_SET_RULES;
<mask> const parameters = {
<mask> data: rules,
<mask> headers: { 'Content-Type': 'text/plain' },
<mask> };
<mask> return this.makeRequest(path, method, parameters);
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/api/Api.js |
return this.makeRequest(path, method); | <mask> }
<mask>
<mask> enableParentalControl() {
<mask> const { path, method } = this.PARENTAL_ENABLE;
<mask> const parameter = 'sensitivity=TEEN'; // this parameter TEEN is hardcoded
<mask> const config = {
<mask> data: parameter,
<mask> headers: { 'Cont... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/api/Api.js |
changeLanguage(config) { | <mask> const { path, method } = this.CURRENT_LANGUAGE;
<mask> return this.makeRequest(path, method);
<mask> }
<mask>
<mask> changeLanguage(lang) {
<mask> const { path, method } = this.CHANGE_LANGUAGE;
<mask> const parameters = {
<mask> data: lang,
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/api/Api.js |
data: config,
headers: { 'Content-Type': 'application/json' }, | <mask>
<mask> changeLanguage(lang) {
<mask> const { path, method } = this.CHANGE_LANGUAGE;
<mask> const parameters = {
<mask> data: lang,
<mask> headers: { 'Content-Type': 'text/plain' },
<mask> };
<mask> return this.makeRequest(path, method, paramete... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/api/Api.js |
findActiveDhcp(req) { | <mask> };
<mask> return this.makeRequest(path, method, parameters);
<mask> }
<mask>
<mask> findActiveDhcp(name) {
<mask> const { path, method } = this.DHCP_FIND_ACTIVE;
<mask> const parameters = {
<mask> data: name,
<mask> headers: { 'Content-Typ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/api/Api.js |
data: req,
headers: { 'Content-Type': 'application/json' }, | <mask>
<mask> findActiveDhcp(name) {
<mask> const { path, method } = this.DHCP_FIND_ACTIVE;
<mask> const parameters = {
<mask> data: name,
<mask> headers: { 'Content-Type': 'text/plain' },
<mask> };
<mask> return this.makeRequest(path, method, paramet... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | client/src/api/Api.js |
"encoding/json" | <mask> // Package aghhttp provides some common methods to work with HTTP.
<mask> package aghhttp
<mask>
<mask> import (
<mask> "fmt"
<mask> "io"
<mask> "net/http"
<mask>
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
commit 75ab27bf... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/aghhttp/aghhttp.go |
"github.com/AdguardTeam/AdGuardHome/internal/version" | <mask> "io"
<mask> "net/http"
<mask>
<mask> "github.com/AdguardTeam/golibs/log"
<mask> )
<mask>
<mask> // HTTP scheme constants.
<mask> const (
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
commit 75ab27bf6c52b80ab4e7347d7c254fa659... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/aghhttp/aghhttp.go |
<mask>
<mask> import (
<mask> "encoding/json"
<mask> "fmt"
<mask> "io"
<mask> "net"
<mask> "net/http"
<mask> "os"
<mask> "strings"
<mask>
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
commit 75ab27bf6c52b80ab4e7347d7c254fa659... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go | |
<mask> "io"
<mask> "net"
<mask> "net/http"
<mask> "os"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghalg"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet"
<mask> "github.com/AdguardTeam/golibs/er... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go | |
// findActiveServerReq is the JSON structure for the request to find active DHCP
// servers.
type findActiveServerReq struct {
Interface string `json:"interface"`
}
// handleDHCPFindActiveServer performs the following tasks:
// 1. searches for another DHCP server in the network;
// 2. check if a static IP is config... | <mask> V4 dhcpSearchV4Result `json:"v4"`
<mask> V6 dhcpSearchV6Result `json:"v6"`
<mask> }
<mask>
<mask> // Perform the following tasks:
<mask> // . Search for another DHCP server running
<mask> // . Check if a static IP is configured for the network interface
<mask> // Respond with results
<mask> func (s *... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go |
if aghhttp.WriteTextPlainDeprecated(w, r) {
return
}
req := &findActiveServerReq{}
err := json.NewDecoder(r.Body).Decode(req) | <mask> // . Search for another DHCP server running
<mask> // . Check if a static IP is configured for the network interface
<mask> // Respond with results
<mask> func (s *server) handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) {
<mask> // This use of ReadAll is safe, because request's body is n... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go |
aghhttp.Error(r, w, http.StatusBadRequest, "reading req: %s", err) | <mask> func (s *server) handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) {
<mask> // This use of ReadAll is safe, because request's body is now limited.
<mask> body, err := io.ReadAll(r.Body)
<mask> if err != nil {
<mask> msg := fmt.Sprintf("failed to read request body: %s", err)
<mask> l... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go |
ifaceName := req.Interface | <mask>
<mask> return
<mask> }
<mask>
<mask> ifaceName := strings.TrimSpace(string(body))
<mask> if ifaceName == "" {
<mask> msg := "empty interface name specified"
<mask> log.Error(msg)
<mask> http.Error(w, msg, http.StatusBadRequest)
<mask>
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go |
aghhttp.Error(r, w, http.StatusBadRequest, "empty interface name") | <mask> }
<mask>
<mask> ifaceName := strings.TrimSpace(string(body))
<mask> if ifaceName == "" {
<mask> msg := "empty interface name specified"
<mask> log.Error(msg)
<mask> http.Error(w, msg, http.StatusBadRequest)
<mask>
<mask> return
<mask> }
<mask>
<mask> result := dhcpSearchResult{
</s> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go |
result := &dhcpSearchResult{ | <mask>
<mask> return
<mask> }
<mask>
<mask> result := dhcpSearchResult{
<mask> V4: dhcpSearchV4Result{
<mask> OtherServer: dhcpSearchOtherResult{
<mask> Found: "no",
<mask> },
<mask> StaticIP: dhcpStaticIPStatus{
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go |
setOtherDHCPResult(ifaceName, result)
_ = aghhttp.WriteJSONResponse(w, r, result)
}
// setOtherDHCPResult sets the results of the check for another DHCP server in
// result.
func setOtherDHCPResult(ifaceName string, result *dhcpSearchResult) { | <mask> // TODO(e.burkov): The returned IP should only be of version 4.
<mask> result.V4.StaticIP.IP = aghnet.GetSubnet(ifaceName).String()
<mask> }
<mask>
<mask> found4, found6, err4, err6 := aghnet.CheckOtherDHCP(ifaceName)
<mask> if err4 != nil {
<mask> result.V4.OtherServer.Found = "error"
<mask> ... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go |
<mask> result.V6.OtherServer.Error = err6.Error()
<mask> } else if found6 {
<mask> result.V6.OtherServer.Found = "yes"
<mask> }
<mask>
<mask> w.Header().Set("Content-Type", "application/json")
<mask> err = json.NewEncoder(w).Encode(result)
<mask> if err != nil {
<mask> aghhttp.Error(
<mask> r,
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/dhcpd/http_unix.go | |
"path" | <mask> "fmt"
<mask> "net"
<mask> "net/http"
<mask> "strconv"
<mask> "strings"
<mask> "sync"
<mask> "time"
<mask>
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
commit 75ab27bf6c52b80ab4e7347d7c254fa659eac244
Author: Ainar Garipov... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
"github.com/AdguardTeam/golibs/errors" | <mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/netutil"
<mask> "github.com/AdguardTeam/golibs/timeutil"
<mask> "go.etcd.io/bbolt"
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home f... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
// expire is the expiration time, in seconds.
expire uint32 | <mask> const sessionTokenSize = 16
<mask>
<mask> type session struct {
<mask> userName string
<mask> expire uint32 // expiration time (in seconds)
<mask> }
<mask>
<mask> func (s *session) serialize() []byte {
<mask> const (
<mask> expireLen = 4
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-ho... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
db *bbolt.DB
raleLimiter *authRateLimiter
sessions map[string]*session
users []webUser
lock sync.Mutex
sessionTTL uint32 | <mask> }
<mask>
<mask> // Auth - global object
<mask> type Auth struct {
<mask> db *bbolt.DB
<mask> blocker *authRateLimiter
<mask> sessions map[string]*session
<mask> users []User
<mask> lock sync.Mutex
<mask> sessionTTL uint32
<mask> }
<mask>
<mask> // User object
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
// webUser represents a user of the Web UI.
type webUser struct { | <mask> lock sync.Mutex
<mask> sessionTTL uint32
<mask> }
<mask>
<mask> // User object
<mask> type User struct {
<mask> Name string `yaml:"name"`
<mask> PasswordHash string `yaml:"password"` // bcrypt hash
<mask> }
<mask>
<mask> // InitAuth - create a global object
</s> Pull request: HOFT... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
PasswordHash string `yaml:"password"` | <mask>
<mask> // User object
<mask> type User struct {
<mask> Name string `yaml:"name"`
<mask> PasswordHash string `yaml:"password"` // bcrypt hash
<mask> }
<mask>
<mask> // InitAuth - create a global object
<mask> func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateL... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
func InitAuth(dbFilename string, users []webUser, sessionTTL uint32, rateLimiter *authRateLimiter) *Auth { | <mask> PasswordHash string `yaml:"password"` // bcrypt hash
<mask> }
<mask>
<mask> // InitAuth - create a global object
<mask> func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateLimiter) *Auth {
<mask> log.Info("Initializing auth module: %s", dbFilename)
<mask>
<mask> a := &... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
sessionTTL: sessionTTL,
raleLimiter: rateLimiter,
sessions: make(map[string]*session),
users: users, | <mask> func InitAuth(dbFilename string, users []User, sessionTTL uint32, blocker *authRateLimiter) *Auth {
<mask> log.Info("Initializing auth module: %s", dbFilename)
<mask>
<mask> a := &Auth{
<mask> sessionTTL: sessionTTL,
<mask> blocker: blocker,
<mask> sessions: make(map[string]*session),
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
// newCookie creates a new authentication cookie.
func (a *Auth) newCookie(req loginJSON, addr string) (c *http.Cookie, err error) {
rateLimiter := a.raleLimiter
u, ok := a.findUser(req.Name, req.Password)
if !ok {
if rateLimiter != nil {
rateLimiter.inc(addr) | <mask>
<mask> return randData, nil
<mask> }
<mask>
<mask> // cookieTimeFormat is the format to be used in (time.Time).Format for cookie's
<mask> // expiry field.
<mask> const cookieTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
<mask>
<mask> // cookieExpiryFormat returns the formatted exp to be used in cooki... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
return nil, errors.Error("invalid username or password") | <mask> if blocker != nil {
<mask> blocker.inc(addr)
<mask> }
<mask>
<mask> return "", err
<mask> }
<mask>
<mask> if blocker != nil {
<mask> blocker.remove(addr)
<mask> }
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed commit of the following:
co... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
if rateLimiter != nil {
rateLimiter.remove(addr) | <mask>
<mask> return "", err
<mask> }
<mask>
<mask> if blocker != nil {
<mask> blocker.remove(addr)
<mask> }
<mask>
<mask> var sess []byte
<mask> sess, err = newSessionToken()
<mask> if err != nil {
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
sess, err := newSessionToken() | <mask> if blocker != nil {
<mask> blocker.remove(addr)
<mask> }
<mask>
<mask> var sess []byte
<mask> sess, err = newSessionToken()
<mask> if err != nil {
<mask> return "", err
<mask> }
<mask>
<mask> now := time.Now().UTC()
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-cs... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
return nil, fmt.Errorf("generating token: %w", err) | <mask>
<mask> var sess []byte
<mask> sess, err = newSessionToken()
<mask> if err != nil {
<mask> return "", err
<mask> }
<mask>
<mask> now := time.Now().UTC()
<mask>
<mask> a.addSession(sess, &session{
</s> Pull request: HOFTIX-csrf
Merge in DNS/adguard-home from HOFTIX-csrf to master
Squashed c... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
return &http.Cookie{
Name: sessionCookieName,
Value: hex.EncodeToString(sess),
Path: "/",
Expires: now.Add(cookieTTL),
HttpOnly: true,
SameSite: http.SameSiteLaxMode,
}, nil | <mask> userName: u.Name,
<mask> expire: uint32(now.Unix()) + a.sessionTTL,
<mask> })
<mask>
<mask> return fmt.Sprintf(
<mask> "%s=%s; Path=/; HttpOnly; Expires=%s",
<mask> sessionCookieName, hex.EncodeToString(sess),
<mask> cookieExpiryFormat(now.Add(cookieTTL)),
<mask> ), nil
<mask> }
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/756b14a61de138889130c239406dae43f1f115cb | internal/home/auth.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.