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 |
|---|---|---|---|---|
func TestSerialize(t *testing.T) {
const reportFmt = "expected %s but got %s"
testCases := []struct {
name string
opts options
ss []string
}{{
name: "empty",
opts: options{},
ss: []string{},
}, {
name: "config_filename",
opts: options{configFilename: "path"},
ss: []string{"-c", "path"},
},... | <mask> testParseErr(t, "unknown plus", "+x")
<mask> testParseErr(t, "unknown dash", "-")
<mask> }
<mask>
<mask> func testSerialize(t *testing.T, o options, ss ...string) {
<mask> result := serialize(o)
<mask> if len(result) != len(ss) {
<mask> t.Fatalf("expected %s but got %s", ss, result)
<mask> }
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/dfdbfee4fd89047c49777841a70654480f1e67ea | internal/home/options_test.go |
<mask> t.Fatalf("expected %s but got %s", ss, result)
<mask> }
<mask> }
<mask> }
<mask>
<mask> func TestSerializeEmpty(t *testing.T) {
<mask> testSerialize(t, options{})
<mask> }
<mask>
<mask> func TestSerializeConfigFilename(t *testing.T) {
<mask> testSerialize(t, options{configFilename: "path"}, ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/AdguardTeam/AdGuardHome/commit/dfdbfee4fd89047c49777841a70654480f1e67ea | internal/home/options_test.go | |
require.Nil(t, err) | <mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> timestamp, err := time.Parse(time.RFC3339Nano, tc.time)
<mask> assert.Nil(t, err)
<mask>
<mask> if tc.name == "first" {
<mask> assert.True(t, true)
<mask> }
<mask>
<mask> err = r.SeekTS(tim... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/dfdbfee4fd89047c49777841a70654480f1e67ea | internal/querylog/qlogreader_test.go |
require.Nil(t, err) | <mask>
<mask> for _, tc := range testCases {
<mask> t.Run(tc.name, func(t *testing.T) {
<mask> err := r.SeekStart()
<mask> assert.Nil(t, err, err)
<mask>
<mask> for i := 1; i < tc.start; i++ {
<mask> _, err := r.ReadNext()
<mask> assert.Nil(t, err)
<mask> }
</s> Pull request: 2639 us... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/dfdbfee4fd89047c49777841a70654480f1e67ea | internal/querylog/qlogreader_test.go |
require.Nil(t, err) | <mask> assert.Nil(t, err, err)
<mask>
<mask> for i := 1; i < tc.start; i++ {
<mask> _, err := r.ReadNext()
<mask> assert.Nil(t, err)
<mask> }
<mask>
<mask> _, err = r.ReadNext()
<mask> assert.Equal(t, tc.want, err)
<mask> })
</s> Pull request: 2639 use testify require vol.4
Merge ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/dfdbfee4fd89047c49777841a70654480f1e67ea | internal/querylog/qlogreader_test.go |
github.com/AdguardTeam/dnsproxy v0.39.4
github.com/AdguardTeam/golibs v0.9.2 | <mask>
<mask> go 1.16
<mask>
<mask> require (
<mask> github.com/AdguardTeam/dnsproxy v0.39.2
<mask> github.com/AdguardTeam/golibs v0.9.1
<mask> github.com/AdguardTeam/urlfilter v0.14.6
<mask> github.com/NYTimes/gziphandler v1.1.1
<mask> github.com/ameshkov/dnscrypt/v2 v2.2.1
<mask> github.com/digineo/... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | go.mod |
github.com/AdguardTeam/dnsproxy v0.39.4 h1:vjcogr0qpSTvRYzbXabBXblfzYpx+LOn91kjtnYgcrU=
github.com/AdguardTeam/dnsproxy v0.39.4/go.mod h1:JZUxXM70BUlAmMaJEPa6Wh+Tz7eBAQx6DM1GMt+Ff5E= | <mask> dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
<mask> git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
<mask> github.com/AdguardTeam/dhcp v0.0.0-20210519141215-51808c73c0bf ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | go.sum |
github.com/AdguardTeam/golibs v0.9.2 h1:H3BDFkaosxvb+UgFlNVyN66GZ+JglcZULnJ7z7PukyQ=
github.com/AdguardTeam/golibs v0.9.2/go.mod h1:fCAMwPBJ8S7YMYbTWvYS+eeTLblP5E04IDtNAo7y7IY= | <mask> github.com/AdguardTeam/dnsproxy v0.39.2 h1:GqsR1S4fFfVsVCSrdrfa0RfsQ2u+MeNUMqDkxdTD3gU=
<mask> github.com/AdguardTeam/dnsproxy v0.39.2/go.mod h1:aNXKNdTyKfgAG2OS712SYSaGIM9AasZsZxfiY4YiR/0=
<mask> github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
<mask> github.com/Ad... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | go.sum |
<mask> golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
<mask> golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
<mask> golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
<mask> golang.org/x/text ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | go.sum | |
"github.com/AdguardTeam/AdGuardHome/internal/aghtime" | <mask> "sort"
<mask> "strings"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering"
<mask> "github.com/AdguardTeam/dnsproxy/proxy"
<mask> "github.com/AdguardTeam/dnsproxy/upstream"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/dnsforward/config.go |
// FastestTimeout replaces the default timeout for dialing IP addresses
// when FastestAddr is true.
FastestTimeout aghtime.Duration `yaml:"fastest_timeout"` | <mask> UpstreamDNSFileName string `yaml:"upstream_dns_file"`
<mask> BootstrapDNS []string `yaml:"bootstrap_dns"` // a list of bootstrap DNS for DoH and DoT (plain DNS only)
<mask> AllServers bool `yaml:"all_servers"` // if true, parallel queries to all configured upstream servers are enabl... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/dnsforward/config.go |
proxyConfig.FastestPingTimeout = s.conf.FastestTimeout.Duration | <mask> } else if s.conf.FastestAddr {
<mask> proxyConfig.UpstreamMode = proxy.UModeFastestAddr
<mask> }
<mask>
<mask> if len(s.conf.BogusNXDomain) > 0 {
<mask> for _, s := range s.conf.BogusNXDomain {
<mask> ip := net.ParseIP(s)
<mask> if ip == nil {
</s> Pull request: 1992 configurable timeouts
... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/dnsforward/config.go |
"github.com/AdguardTeam/AdGuardHome/internal/aghtime" | <mask> "path/filepath"
<mask> "sync"
<mask> "time"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/dhcpd"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/querylog... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/config.go |
"github.com/AdguardTeam/dnsproxy/fastip" | <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/querylog"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/stats"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/version"
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.co... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/config.go |
QueryLogInterval aghtime.Duration `yaml:"querylog_interval"`
QueryLogMemSize uint32 `yaml:"querylog_size_memory"` // number of entries kept in memory before they are flushed to disk
AnonymizeClientIP bool `yaml:"anonymize_client_ip"` // anonymize clients' IP addresses in logs and stats | <mask>
<mask> QueryLogEnabled bool `yaml:"querylog_enabled"` // if true, query log is enabled
<mask> QueryLogFileEnabled bool `yaml:"querylog_file_enabled"` // if true, query log will be written to a file
<mask> // QueryLogInterval is the interval for query log's files rotation.
<mask> QueryLogInterv... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/config.go |
UpstreamTimeout aghtime.Duration `yaml:"upstream_timeout"` | <mask> FiltersUpdateIntervalHours uint32 `yaml:"filters_update_interval"` // time period to update filters (in hours)
<mask> DnsfilterConf filtering.Config `yaml:",inline"`
<mask>
<mask> // UpstreamTimeout is the timeout for querying upstream servers.
<mask> UpstreamTimeout Duration `ya... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/config.go |
FastestTimeout: aghtime.Duration{
Duration: fastip.DefaultPingWaitTimeout,
}, | <mask> Ratelimit: 20,
<mask> RefuseAny: true,
<mask> AllServers: false,
<mask>
<mask> TrustedProxies: []string{"127.0.0.0/8", "::1/128"},
<mask>
<mask> // set default maximum concurrent queries to 300
<mask> // we introduced a default limit due to this:
<mask> /... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/config.go |
UpstreamTimeout: aghtime.Duration{Duration: dnsforward.DefaultTimeout}, | <mask> MaxGoroutines: 300,
<mask> },
<mask> FilteringEnabled: true, // whether or not use filter lists
<mask> FiltersUpdateIntervalHours: 24,
<mask> UpstreamTimeout: Duration{Duration: dnsforward.DefaultTimeout},
<mask> LocalDomainName: "lan",
<mask> ResolveClients:... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/config.go |
config.DNS.QueryLogInterval = aghtime.Duration{Duration: 90 * 24 * time.Hour} | <mask> config.WebSessionTTLHours = 30 * 24
<mask>
<mask> config.DNS.QueryLogEnabled = true
<mask> config.DNS.QueryLogFileEnabled = true
<mask> config.DNS.QueryLogInterval = Duration{Duration: 90 * 24 * time.Hour}
<mask> config.DNS.QueryLogMemSize = 1000
<mask>
<mask> config.DNS.CacheSize = 4 * 1024 * 10... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/config.go |
config.DNS.UpstreamTimeout = aghtime.Duration{Duration: dnsforward.DefaultTimeout} | <mask> config.DNS.FiltersUpdateIntervalHours = 24
<mask> }
<mask>
<mask> if config.DNS.UpstreamTimeout.Duration == 0 {
<mask> config.DNS.UpstreamTimeout = Duration{Duration: dnsforward.DefaultTimeout}
<mask> }
<mask>
<mask> return nil
<mask> }
<mask>
</s> Pull request: 1992 configurable timeouts
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/config.go |
config.DNS.QueryLogInterval = aghtime.Duration{Duration: dc.RotationIvl} | <mask> dc := querylog.Config{}
<mask> Context.queryLog.WriteDiskConfig(&dc)
<mask> config.DNS.QueryLogEnabled = dc.Enabled
<mask> config.DNS.QueryLogFileEnabled = dc.FileEnabled
<mask> config.DNS.QueryLogInterval = Duration{Duration: dc.RotationIvl}
<mask> config.DNS.QueryLogMemSize = dc.MemSize
<mas... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/config.go |
"github.com/AdguardTeam/AdGuardHome/internal/aghtime" | <mask> "time"
<mask>
<mask> "github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/golibs/netutil"
<mask> "github.com/google/renameio/maybe"
<mask> "golang.org/x/crypto/bcrypt"
<mask> yaml "gopkg.in/yaml.v2"
</s> Pull request: 1992 configurable ... | [
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/upgrade.go |
dns[field] = aghtime.Duration{Duration: time.Duration(qlogIvl) * 24 * time.Hour} | <mask> return fmt.Errorf("unexpected type of %s: %T", field, qlogIvlVal)
<mask> }
<mask> }
<mask>
<mask> dns[field] = Duration{Duration: time.Duration(qlogIvl) * 24 * time.Hour}
<mask>
<mask> return nil
<mask> }
<mask>
<mask> // TODO(a.garipov): Replace with log.Output when we port it to our loggin... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/upgrade.go |
"github.com/AdguardTeam/AdGuardHome/internal/aghtime" | <mask> "testing"
<mask> "time"
<mask>
<mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
</s> Pull request: 1992 configurable timeouts
Merge in DNS/adguard-home from 1992-conf-timeouts to master
Updates #1992.
Squashed commit of the following:
comm... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/upgrade_test.go |
want: aghtime.Duration{Duration: 24 * time.Hour}, | <mask> wantErr string
<mask> name string
<mask> }{{
<mask> ivl: 1,
<mask> want: Duration{Duration: 24 * time.Hour},
<mask> wantErr: "",
<mask> name: "success",
<mask> }, {
<mask> ivl: 0.25,
<mask> want: 0,
</s> Pull request: 1992 configurable timeouts
Merge in DNS/adgua... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/upgrade_test.go |
var newIvl aghtime.Duration
newIvl, ok = newDNSConf["querylog_interval"].(aghtime.Duration) | <mask> var newDNSConf yobj
<mask> newDNSConf, ok = dnsVal.(yobj)
<mask> require.True(t, ok)
<mask>
<mask> var newIvl Duration
<mask> newIvl, ok = newDNSConf["querylog_interval"].(Duration)
<mask> require.True(t, ok)
<mask>
<mask> assert.Equal(t, tc.want, newIvl)
<mask> })
<mask> }
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/upgrade_test.go |
var ivlVal aghtime.Duration
ivlVal, ok = ivl.(aghtime.Duration) | <mask> var ivl interface{}
<mask> ivl, ok = dnsVal["querylog_interval"]
<mask> require.True(t, ok)
<mask>
<mask> var ivlVal Duration
<mask> ivlVal, ok = ivl.(Duration)
<mask> require.True(t, ok)
<mask>
<mask> assert.Equal(t, 90*24*time.Hour, ivlVal.Duration)
<mask> })
<mask> }
</s> Pull req... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e064e0f27786ce941e823c8d52aadb0972319afa | internal/home/upgrade_test.go |
"access_allowed_desc": "A list of CIDRs, IP addresses, or client IDs. If configured, AdGuard Home will accept requests only from these clients.", | <mask> "auto_clients_desc": "Data on the clients that use AdGuard Home, but not stored in the configuration",
<mask> "access_title": "Access settings",
<mask> "access_desc": "Here you can configure access rules for the AdGuard Home DNS server.",
<mask> "access_allowed_title": "Allowed clients",
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | client/src/__locales/en.json |
"access_disallowed_desc": "A list of CIDRs, IP addresses, or client IDs. If configured, AdGuard Home will drop requests from these clients. If allowed clients are configured, this field is ignored.", | <mask> "access_desc": "Here you can configure access rules for the AdGuard Home DNS server.",
<mask> "access_allowed_title": "Allowed clients",
<mask> "access_allowed_desc": "A list of CIDR or IP addresses. If configured, AdGuard Home will accept requests from these IP addresses only.",
<mask> "acce... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | client/src/__locales/en.json |
import { BLOCK_ACTIONS, STATUS_COLORS } from '../../helpers/constants'; | <mask> import Card from '../ui/Card';
<mask> import Cell from '../ui/Cell';
<mask>
<mask> import { getPercent, sortIp } from '../../helpers/helpers';
<mask> import { BLOCK_ACTIONS, R_CLIENT_ID, STATUS_COLORS } from '../../helpers/constants';
<mask> import { toggleClientBlock } from '../../actions/access';
<mask... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | client/src/components/Dashboard/Clients.js |
<mask> return <Cell value={value} percent={percent} color={percentColor} search={ip} />;
<mask> };
<mask>
<mask> const renderBlockingButton = (ip, disallowed, disallowed_rule) => {
<mask> if (R_CLIENT_ID.test(ip)) {
<mask> return null;
<mask> }
<mask>
<mask> const dispatch = useDispat... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | client/src/components/Dashboard/Clients.js | |
github.com/AdguardTeam/dnsproxy v0.38.0 | <mask>
<mask> go 1.16
<mask>
<mask> require (
<mask> github.com/AdguardTeam/dnsproxy v0.37.7
<mask> github.com/AdguardTeam/golibs v0.8.0
<mask> github.com/AdguardTeam/urlfilter v0.14.6
<mask> github.com/NYTimes/gziphandler v1.1.1
<mask> github.com/ameshkov/dnscrypt/v2 v2.1.3
<mask> github.com/digineo/... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | go.mod |
github.com/AdguardTeam/dnsproxy v0.38.0 h1:7GyyNJOieIVOgdnhu47exqWjHPQro7wQhqzvQjaZt6M=
github.com/AdguardTeam/dnsproxy v0.38.0/go.mod h1:xMfevPAwpK1ULoLO0CARg/OiUsPH92kfyliXhPTc62M= | <mask> dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
<mask> git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
<mask> github.com/AdguardTeam/dhcp v0.0.0-20210519141215-51808c73c0bf ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | go.sum |
// tableReverse is the IP-to-hosts map. The type of the values in the
// map is []string.
tableReverse *IPMap | <mask> // lock protects table and tableReverse.
<mask> lock sync.RWMutex
<mask> // table is the host-to-IPs map.
<mask> table map[string][]net.IP
<mask> // tableReverse is the IP-to-hosts map.
<mask> //
<mask> // TODO(a.garipov): Make better use of newtypes. Perhaps a custom map.
<mask> tableReverse ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Error("etchosts: %s", err) | <mask>
<mask> var err error
<mask> ehc.watcher, err = fsnotify.NewWatcher()
<mask> if err != nil {
<mask> log.Error("etchostscontainer: %s", err)
<mask> }
<mask> }
<mask>
<mask> // Start - start module
<mask> func (ehc *EtcHostsContainer) Start() {
</s> Pull request: all: allow clientid in access set... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Debug("etchosts: answer: %s -> %v", host, ipsCopy) | <mask> ipsCopy = make([]net.IP, len(ips))
<mask> copy(ipsCopy, ips)
<mask> }
<mask>
<mask> log.Debug("etchostscontainer: answer: %s -> %v", host, ipsCopy)
<mask> return ipsCopy
<mask> }
<mask>
<mask> // ProcessReverse processes a PTR request. It returns nil if nothing is found.
<mask> func (ehc *Etc... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
ip := UnreverseAddr(addr)
if ip == nil { | <mask> if qtype != dns.TypePTR {
<mask> return nil
<mask> }
<mask>
<mask> ipReal := UnreverseAddr(addr)
<mask> if ipReal == nil {
<mask> return nil
<mask> }
<mask>
<mask> ipStr := ipReal.String()
<mask>
</s> Pull request: all: allow clientid in access settings
Updates #2624.
Updates #3162.
Sq... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
<mask> if ipReal == nil {
<mask> return nil
<mask> }
<mask>
<mask> ipStr := ipReal.String()
<mask>
<mask> ehc.lock.RLock()
<mask> defer ehc.lock.RUnlock()
<mask>
<mask> hosts = ehc.tableReverse[ipStr]
<mask>
</s> Pull request: all: allow clientid in access settings
Updates #2624.
Updates #3162.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go | |
v, ok := ehc.tableReverse.Get(ip)
if !ok {
return nil
}
hosts, ok = v.([]string)
if !ok {
log.Error("etchosts: bad type %T in tableReverse for %s", v, ip) | <mask>
<mask> ehc.lock.RLock()
<mask> defer ehc.lock.RUnlock()
<mask>
<mask> hosts = ehc.tableReverse[ipStr]
<mask>
<mask> if len(hosts) == 0 {
<mask> return nil // not found
<mask> }
<mask>
</s> Pull request: all: allow clientid in access settings
Updates #2624.
Updates #3162.
Squashed commit o... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
return nil
} else if len(hosts) == 0 {
return nil | <mask> defer ehc.lock.RUnlock()
<mask>
<mask> hosts = ehc.tableReverse[ipStr]
<mask>
<mask> if len(hosts) == 0 {
<mask> return nil // not found
<mask> }
<mask>
<mask> log.Debug("etchostscontainer: reverse-lookup: %s -> %s", addr, hosts)
<mask>
<mask> return hosts
</s> Pull request: all: allow cl... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Debug("etchosts: reverse-lookup: %s -> %s", addr, hosts) | <mask> if len(hosts) == 0 {
<mask> return nil // not found
<mask> }
<mask>
<mask> log.Debug("etchostscontainer: reverse-lookup: %s -> %s", addr, hosts)
<mask>
<mask> return hosts
<mask> }
<mask>
<mask> // List returns an IP-to-hostnames table. It is safe for concurrent use.
</s> Pull request: all: ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
// List returns an IP-to-hostnames table. The type of the values in the map is
// []string. It is safe for concurrent use.
func (ehc *EtcHostsContainer) List() (ipToHosts *IPMap) { | <mask>
<mask> return hosts
<mask> }
<mask>
<mask> // List returns an IP-to-hostnames table. It is safe for concurrent use.
<mask> func (ehc *EtcHostsContainer) List() (ipToHosts map[string][]string) {
<mask> ehc.lock.RLock()
<mask> defer ehc.lock.RUnlock()
<mask>
<mask> ipToHosts = make(map[string][]s... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
return ehc.tableReverse.ShallowClone() | <mask> func (ehc *EtcHostsContainer) List() (ipToHosts map[string][]string) {
<mask> ehc.lock.RLock()
<mask> defer ehc.lock.RUnlock()
<mask>
<mask> ipToHosts = make(map[string][]string, len(ehc.tableReverse))
<mask> for k, v := range ehc.tableReverse {
<mask> ipToHosts[k] = v
<mask> }
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Debug("etchosts: added %s -> %s", ipAddr, host) | <mask> table[host] = []net.IP{ipAddr}
<mask> ok = true
<mask> }
<mask> if ok {
<mask> log.Debug("etchostscontainer: added %s -> %s", ipAddr, host)
<mask> }
<mask> }
<mask>
<mask> // updateTableRev updates the reverse address table.
<mask> func (ehc *EtcHostsContainer) updateTableRev(tableRev map[str... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
func (ehc *EtcHostsContainer) updateTableRev(tableRev *IPMap, newHost string, ip net.IP) {
v, ok := tableRev.Get(ip) | <mask> }
<mask> }
<mask>
<mask> // updateTableRev updates the reverse address table.
<mask> func (ehc *EtcHostsContainer) updateTableRev(tableRev map[string][]string, newHost string, ipAddr net.IP) {
<mask> ipStr := ipAddr.String()
<mask> hosts, ok := tableRev[ipStr]
<mask> if !ok {
<mask> tableRev[ipSt... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
tableRev.Set(ip, []string{newHost})
log.Debug("etchosts: added reverse-address %s -> %s", ip, newHost) | <mask> func (ehc *EtcHostsContainer) updateTableRev(tableRev map[string][]string, newHost string, ipAddr net.IP) {
<mask> ipStr := ipAddr.String()
<mask> hosts, ok := tableRev[ipStr]
<mask> if !ok {
<mask> tableRev[ipStr] = []string{newHost}
<mask> log.Debug("etchostscontainer: added reverse-address %s -> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
hosts, _ := v.([]string) | <mask>
<mask> return
<mask> }
<mask>
<mask> for _, host := range hosts {
<mask> if host == newHost {
<mask> return
<mask> }
</s> Pull request: all: allow clientid in access settings
Updates #2624.
Updates #3162.
Squashed commit of the following:
commit 68860da717a23a0bfeba14b7fe10b5e4ad38726d
A... | [
"keep",
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
hosts = append(hosts, newHost)
tableRev.Set(ip, hosts)
log.Debug("etchosts: added reverse-address %s -> %s", ip, newHost) | <mask> return
<mask> }
<mask> }
<mask>
<mask> tableRev[ipStr] = append(tableRev[ipStr], newHost)
<mask> log.Debug("etchostscontainer: added reverse-address %s -> %s", ipStr, newHost)
<mask> }
<mask>
<mask> // parseHostsLine parses hosts from the fields.
<mask> func parseHostsLine(fields []string) (h... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
tableRev *IPMap, | <mask> // load reads IP-hostname pairs from the hosts file. Multiple hostnames per
<mask> // line for one IP are supported.
<mask> func (ehc *EtcHostsContainer) load(
<mask> table map[string][]net.IP,
<mask> tableRev map[string][]string,
<mask> fn string,
<mask> ) {
<mask> f, err := os.Open(fn)
<mask> if... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Error("etchosts: %s", err) | <mask> fn string,
<mask> ) {
<mask> f, err := os.Open(fn)
<mask> if err != nil {
<mask> log.Error("etchostscontainer: %s", err)
<mask>
<mask> return
<mask> }
<mask>
<mask> defer func() {
</s> Pull request: all: allow clientid in access settings
Updates #2624.
Updates #3162.
Squashed commit of th... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Error("etchosts: closing file: %s", err) | <mask>
<mask> defer func() {
<mask> derr := f.Close()
<mask> if derr != nil {
<mask> log.Error("etchostscontainer: closing file: %s", err)
<mask> }
<mask> }()
<mask>
<mask> log.Debug("etchostscontainer: loading hosts from file %s", fn)
<mask>
</s> Pull request: all: allow clientid in access se... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Debug("etchosts: loading hosts from file %s", fn) | <mask> log.Error("etchostscontainer: closing file: %s", err)
<mask> }
<mask> }()
<mask>
<mask> log.Debug("etchostscontainer: loading hosts from file %s", fn)
<mask>
<mask> s := bufio.NewScanner(f)
<mask> for s.Scan() {
<mask> line := strings.TrimSpace(s.Text())
<mask> fields := strings.Fields(l... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Error("etchosts: %s", err) | <mask> }
<mask>
<mask> err = s.Err()
<mask> if err != nil {
<mask> log.Error("etchostscontainer: %s", err)
<mask> }
<mask> }
<mask>
<mask> // onlyWrites is a filter for (*fsnotify.Watcher).Events.
<mask> func (ehc *EtcHostsContainer) onlyWrites() {
</s> Pull request: all: allow clientid in access set... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Debug("etchosts: modified: %s", event.Name) | <mask> }
<mask> }
<mask>
<mask> if event.Op&fsnotify.Write == fsnotify.Write {
<mask> log.Debug("etchostscontainer: modified: %s", event.Name)
<mask> ehc.updateHosts()
<mask> }
<mask>
<mask> case err, ok := <-ehc.watcher.Errors:
<mask> if !ok {
</s> Pull request: all: allow client... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Error("etchosts: %s", err) | <mask> case err, ok := <-ehc.watcher.Errors:
<mask> if !ok {
<mask> return
<mask> }
<mask> log.Error("etchostscontainer: %s", err)
<mask> }
<mask> }
<mask> }
<mask>
<mask> // updateHosts - loads system hosts
</s> Pull request: all: allow clientid in access settings
Updates #2624.
Updates ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
tableRev := NewIPMap(0) | <mask>
<mask> // updateHosts - loads system hosts
<mask> func (ehc *EtcHostsContainer) updateHosts() {
<mask> table := make(map[string][]net.IP)
<mask> tableRev := make(map[string][]string)
<mask>
<mask> ehc.load(table, tableRev, ehc.hostsFn)
<mask>
<mask> for _, dir := range ehc.hostsDirs {
<mask> d... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
log.Error("etchosts: Opening directory: %q: %s", dir, err) | <mask> for _, dir := range ehc.hostsDirs {
<mask> des, err := os.ReadDir(dir)
<mask> if err != nil {
<mask> if !errors.Is(err, os.ErrNotExist) {
<mask> log.Error("etchostscontainer: Opening directory: %q: %s", dir, err)
<mask> }
<mask>
<mask> continue
<mask> }
<mask>
</s> Pull request: ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer.go |
names, ok := ehc.List().Get(net.IP{127, 0, 0, 1}) | <mask> assert.Nil(t, ips)
<mask> })
<mask>
<mask> t.Run("hosts_file", func(t *testing.T) {
<mask> names, ok := ehc.List()["127.0.0.1"]
<mask> require.True(t, ok)
<mask> assert.Equal(t, []string{"host", "localhost"}, names)
<mask> })
<mask>
<mask> t.Run("ptr", func(t *testing.T) {
</s> Pull requ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/aghnet/etchostscontainer_test.go |
<mask> "fmt"
<mask> "net"
<mask> "net/http"
<mask> "strings"
<mask> "sync"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghstrings"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/urlfilter"
<mask> "github.com/AdguardTeam/urlfilter/filterlist"
</s> Pull reque... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go | |
"github.com/AdguardTeam/AdGuardHome/internal/aghnet" | <mask> "net/http"
<mask> "strings"
<mask>
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghstrings"
<mask> "github.com/AdguardTeam/golibs/log"
<mask> "github.com/AdguardTeam/urlfilter"
<mask> "github.com/AdguardTeam/urlfilter/filterlist"
<mask> )
<mask>
</s> Pull request: all: allow clientid in ... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
// accessCtx controls IP and client blocking that takes place before all other
// processing. An accessCtx is safe for concurrent use. | <mask> "github.com/AdguardTeam/urlfilter/filterlist"
<mask> )
<mask>
<mask> type accessCtx struct {
<mask> allowedIPs *aghnet.IPMap
<mask> blockedIPs *aghnet.IPMap
<mask>
<mask> allowedClientIDs *aghstrings.Set
<mask> blockedClientIDs *aghstrings.Set
</s> Pull request: all: allow clientid in access set... | [
"keep",
"keep",
"add",
"keep",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
allowedIPs *aghnet.IPMap
blockedIPs *aghnet.IPMap | <mask> "github.com/AdguardTeam/urlfilter/filterlist"
<mask> )
<mask>
<mask> type accessCtx struct {
<mask> lock sync.Mutex
<mask>
<mask> // allowedClients are the IP addresses of clients in the allowlist.
<mask> allowedClients *aghstrings.Set
<mask>
<mask> // disallowedClients are the IP addresses of ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
allowedClientIDs *aghstrings.Set
blockedClientIDs *aghstrings.Set | <mask>
<mask> type accessCtx struct {
<mask> lock sync.Mutex
<mask>
<mask> // allowedClients are the IP addresses of clients in the allowlist.
<mask> allowedClients *aghstrings.Set
<mask>
<mask> // disallowedClients are the IP addresses of clients in the blocklist.
<mask> disallowedClients *aghstrings.... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
blockedHostsEng *urlfilter.DNSEngine | <mask>
<mask> // allowedClients are the IP addresses of clients in the allowlist.
<mask> allowedClients *aghstrings.Set
<mask>
<mask> // disallowedClients are the IP addresses of clients in the blocklist.
<mask> disallowedClients *aghstrings.Set
<mask>
<mask> allowedClientsIPNet []net.IPNet // CIDRs ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
// TODO(a.garipov): Create a type for a set of IP networks.
// aghnet.IPNetSet?
allowedNets []*net.IPNet
blockedNets []*net.IPNet
}
// unit is a convenient alias for struct{}
type unit = struct{}
// processAccessClients is a helper for processing a list of client strings,
// which may be an IP address, a CIDR, or... | <mask>
<mask> // disallowedClients are the IP addresses of clients in the blocklist.
<mask> disallowedClients *aghstrings.Set
<mask>
<mask> allowedClientsIPNet []net.IPNet // CIDRs of whitelist clients
<mask> disallowedClientsIPNet []net.IPNet // CIDRs of clients that should be blocked
<mask>
<mask> ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
return nil | <mask>
<mask> allowedClientsIPNet []net.IPNet // CIDRs of whitelist clients
<mask> disallowedClientsIPNet []net.IPNet // CIDRs of clients that should be blocked
<mask>
<mask> blockedHostsEngine *urlfilter.DNSEngine // finds hosts that should be blocked
<mask> }
<mask>
<mask> func newAccessCtx(allowedCl... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
// newAccessCtx creates a new accessCtx.
func newAccessCtx(allowed, blocked, blockedHosts []string) (a *accessCtx, err error) { | <mask>
<mask> blockedHostsEngine *urlfilter.DNSEngine // finds hosts that should be blocked
<mask> }
<mask>
<mask> func newAccessCtx(allowedClients, disallowedClients, blockedHosts []string) (a *accessCtx, err error) {
<mask> a = &accessCtx{
<mask> allowedClients: aghstrings.NewSet(),
<mask> disallow... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
allowedIPs: aghnet.NewIPMap(0),
blockedIPs: aghnet.NewIPMap(0),
allowedClientIDs: aghstrings.NewSet(),
blockedClientIDs: aghstrings.NewSet(), | <mask> }
<mask>
<mask> func newAccessCtx(allowedClients, disallowedClients, blockedHosts []string) (a *accessCtx, err error) {
<mask> a = &accessCtx{
<mask> allowedClients: aghstrings.NewSet(),
<mask> disallowedClients: aghstrings.NewSet(),
<mask> }
<mask>
<mask> err = processIPCIDRArray(a.allowedC... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
err = processAccessClients(allowed, a.allowedIPs, &a.allowedNets, a.allowedClientIDs) | <mask> allowedClients: aghstrings.NewSet(),
<mask> disallowedClients: aghstrings.NewSet(),
<mask> }
<mask>
<mask> err = processIPCIDRArray(a.allowedClients, &a.allowedClientsIPNet, allowedClients)
<mask> if err != nil {
<mask> return nil, fmt.Errorf("processing allowed clients: %w", err)
<mask> }
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
return nil, fmt.Errorf("adding allowed: %w", err) | <mask> }
<mask>
<mask> err = processIPCIDRArray(a.allowedClients, &a.allowedClientsIPNet, allowedClients)
<mask> if err != nil {
<mask> return nil, fmt.Errorf("processing allowed clients: %w", err)
<mask> }
<mask>
<mask> err = processIPCIDRArray(a.disallowedClients, &a.disallowedClientsIPNet, disallowe... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
err = processAccessClients(blocked, a.blockedIPs, &a.blockedNets, a.blockedClientIDs) | <mask> if err != nil {
<mask> return nil, fmt.Errorf("processing allowed clients: %w", err)
<mask> }
<mask>
<mask> err = processIPCIDRArray(a.disallowedClients, &a.disallowedClientsIPNet, disallowedClients)
<mask> if err != nil {
<mask> return nil, fmt.Errorf("processing disallowed clients: %w", err)
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
return nil, fmt.Errorf("adding blocked: %w", err) | <mask> }
<mask>
<mask> err = processIPCIDRArray(a.disallowedClients, &a.disallowedClientsIPNet, disallowedClients)
<mask> if err != nil {
<mask> return nil, fmt.Errorf("processing disallowed clients: %w", err)
<mask> }
<mask>
<mask> b := &strings.Builder{}
<mask> for _, s := range blockedHosts {
<ma... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
for _, h := range blockedHosts {
aghstrings.WriteToBuilder(b, strings.ToLower(h), "\n") | <mask> return nil, fmt.Errorf("processing disallowed clients: %w", err)
<mask> }
<mask>
<mask> b := &strings.Builder{}
<mask> for _, s := range blockedHosts {
<mask> aghstrings.WriteToBuilder(b, strings.ToLower(s), "\n")
<mask> }
<mask>
<mask> listArray := []filterlist.RuleList{}
<mask> list := &f... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
lists := []filterlist.RuleList{
&filterlist.StringRuleList{
ID: int(0),
RulesText: b.String(),
IgnoreCosmetic: true,
}, | <mask> for _, s := range blockedHosts {
<mask> aghstrings.WriteToBuilder(b, strings.ToLower(s), "\n")
<mask> }
<mask>
<mask> listArray := []filterlist.RuleList{}
<mask> list := &filterlist.StringRuleList{
<mask> ID: int(0),
<mask> RulesText: b.String(),
<mask> IgnoreCosmetic: true... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
rulesStrg, err := filterlist.NewRuleStorage(lists) | <mask> ID: int(0),
<mask> RulesText: b.String(),
<mask> IgnoreCosmetic: true,
<mask> }
<mask> listArray = append(listArray, list)
<mask> rulesStorage, err := filterlist.NewRuleStorage(listArray)
<mask> if err != nil {
<mask> return nil, fmt.Errorf("filterlist.NewRuleStorage(): %w", ... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
return nil, fmt.Errorf("adding blocked hosts: %w", err) | <mask> }
<mask> listArray = append(listArray, list)
<mask> rulesStorage, err := filterlist.NewRuleStorage(listArray)
<mask> if err != nil {
<mask> return nil, fmt.Errorf("filterlist.NewRuleStorage(): %w", err)
<mask> }
<mask> a.blockedHostsEngine = urlfilter.NewDNSEngine(rulesStorage)
<mask>
<mask> r... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
a.blockedHostsEng = urlfilter.NewDNSEngine(rulesStrg) | <mask> rulesStorage, err := filterlist.NewRuleStorage(listArray)
<mask> if err != nil {
<mask> return nil, fmt.Errorf("filterlist.NewRuleStorage(): %w", err)
<mask> }
<mask> a.blockedHostsEngine = urlfilter.NewDNSEngine(rulesStorage)
<mask>
<mask> return a, nil
<mask> }
<mask>
<mask> // Split array o... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
// allowlistMode returns true if this *accessCtx is in the allowlist mode.
func (a *accessCtx) allowlistMode() (ok bool) {
return a.allowedIPs.Len() != 0 || a.allowedClientIDs.Len() != 0 || len(a.allowedNets) != 0
} | <mask>
<mask> return a, nil
<mask> }
<mask>
<mask> // Split array of IP or CIDR into 2 containers for fast search
<mask> func processIPCIDRArray(dst *aghstrings.Set, dstIPNet *[]net.IPNet, src []string) error {
<mask> for _, s := range src {
<mask> ip := net.ParseIP(s)
<mask> if ip != nil {
<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/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
// isBlockedClientID returns true if the ClientID should be blocked.
func (a *accessCtx) isBlockedClientID(id string) (ok bool) {
allowlistMode := a.allowlistMode()
if id == "" {
// In allowlist mode, consider requests without client IDs
// blocked by default.
return allowlistMode
} | <mask>
<mask> continue
<mask> }
<mask>
<mask> _, ipnet, err := net.ParseCIDR(s)
<mask> if err != nil {
<mask> return err
<mask> }
<mask>
<mask> *dstIPNet = append(*dstIPNet, *ipnet)
<mask> }
<mask>
<mask> return nil
</s> Pull request: all: allow clientid in access settings
Updates #... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
if allowlistMode {
return !a.allowedClientIDs.Has(id) | <mask> if err != nil {
<mask> return err
<mask> }
<mask>
<mask> *dstIPNet = append(*dstIPNet, *ipnet)
<mask> }
<mask>
<mask> return nil
<mask> }
<mask>
</s> Pull request: all: allow clientid in access settings
Updates #2624.
Updates #3162.
Squashed commit of the following:
commit 68860da717a... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
return a.blockedClientIDs.Has(id) | <mask>
<mask> *dstIPNet = append(*dstIPNet, *ipnet)
<mask> }
<mask>
<mask> return nil
<mask> }
<mask>
<mask> // IsBlockedIP - return TRUE if this client should be blocked
<mask> // Returns the item from the "disallowedClients" list that lead to blocking IP.
<mask> // If it returns TRUE and an empty str... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
// isBlockedHost returns true if host should be blocked.
func (a *accessCtx) isBlockedHost(host string) (ok bool) {
_, ok = a.blockedHostsEng.Match(strings.ToLower(host)) | <mask>
<mask> return nil
<mask> }
<mask>
<mask> // IsBlockedIP - return TRUE if this client should be blocked
<mask> // Returns the item from the "disallowedClients" list that lead to blocking IP.
<mask> // If it returns TRUE and an empty string, it means that the "allowedClients" is not empty,
<mask> // but... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
return ok
} | <mask> // but the ip does not belong to it.
<mask> func (a *accessCtx) IsBlockedIP(ip net.IP) (bool, string) {
<mask> ipStr := ip.String()
<mask>
<mask> a.lock.Lock()
<mask> defer a.lock.Unlock()
<mask>
<mask> if a.allowedClients.Len() != 0 || len(a.allowedClientsIPNet) != 0 {
<mask> if a.allowedClient... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
// isBlockedIP returns the status of the IP address blocking as well as the rule
// that blocked it.
func (a *accessCtx) isBlockedIP(ip net.IP) (blocked bool, rule string) {
blocked = true
ips := a.blockedIPs
ipnets := a.blockedNets | <mask>
<mask> a.lock.Lock()
<mask> defer a.lock.Unlock()
<mask>
<mask> if a.allowedClients.Len() != 0 || len(a.allowedClientsIPNet) != 0 {
<mask> if a.allowedClients.Has(ipStr) {
<mask> return false, ""
<mask> }
<mask>
<mask> if len(a.allowedClientsIPNet) != 0 {
<mask> for _, ipnet := range... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
if a.allowlistMode() {
// Enable allowlist mode and use the allowlist sets.
blocked = false
ips = a.allowedIPs
ipnets = a.allowedNets | <mask> if a.allowedClients.Has(ipStr) {
<mask> return false, ""
<mask> }
<mask>
<mask> if len(a.allowedClientsIPNet) != 0 {
<mask> for _, ipnet := range a.allowedClientsIPNet {
<mask> if ipnet.Contains(ip) {
<mask> return false, ""
<mask> }
<mask> }
<mask> }
<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/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
if _, ok := ips.Get(ip); ok {
return blocked, ip.String() | <mask>
<mask> return true, ""
<mask> }
<mask>
<mask> if a.disallowedClients.Has(ipStr) {
<mask> return true, ipStr
<mask> }
<mask>
<mask> if len(a.disallowedClientsIPNet) != 0 {
<mask> for _, ipnet := range a.disallowedClientsIPNet {
<mask> if ipnet.Contains(ip) {
</s> Pull request: all: all... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
for _, ipnet := range ipnets {
if ipnet.Contains(ip) {
return blocked, ipnet.String() | <mask> if a.disallowedClients.Has(ipStr) {
<mask> return true, ipStr
<mask> }
<mask>
<mask> if len(a.disallowedClientsIPNet) != 0 {
<mask> for _, ipnet := range a.disallowedClientsIPNet {
<mask> if ipnet.Contains(ip) {
<mask> return true, ipnet.String()
<mask> }
<mask> }
<mask> }
<mask>... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
return !blocked, "" | <mask> }
<mask> }
<mask> }
<mask>
<mask> return false, ""
<mask> }
<mask>
<mask> // IsBlockedDomain - return TRUE if this domain should be blocked
<mask> func (a *accessCtx) IsBlockedDomain(host string) (ok bool) {
<mask> a.lock.Lock()
<mask> defer a.lock.Unlock()
<mask>
<mask> _, ok = a.block... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
httpError(r, w, http.StatusInternalServerError, "encoding response: %s", err) | <mask>
<mask> w.Header().Set("Content-Type", "application/json")
<mask> err := json.NewEncoder(w).Encode(j)
<mask> if err != nil {
<mask> httpError(r, w, http.StatusInternalServerError, "json.Encode: %s", err)
<mask> return
<mask> }
<mask> }
<mask>
<mask> func checkIPCIDRArray(src []string) error {
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
return | <mask> return
<mask> }
<mask> }
<mask>
<mask> func checkIPCIDRArray(src []string) error {
<mask> for _, s := range src {
<mask> ip := net.ParseIP(s)
<mask> if ip != nil {
<mask> continue
<mask> }
<mask>
<mask> _, _, err := net.ParseCIDR(s)
<mask> if err != nil {
<mask> return err
<m... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
<mask> if err != nil {
<mask> return err
<mask> }
<mask> }
<mask>
<mask> return nil
<mask> }
<mask>
<mask> func (s *Server) handleAccessSet(w http.ResponseWriter, r *http.Request) {
<mask> j := accessListJSON{}
<mask> err := json.NewDecoder(r.Body).Decode(&j)
</s> Pull request: all: allow clien... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go | |
list := accessListJSON{}
err := json.NewDecoder(r.Body).Decode(&list) | <mask> return nil
<mask> }
<mask>
<mask> func (s *Server) handleAccessSet(w http.ResponseWriter, r *http.Request) {
<mask> j := accessListJSON{}
<mask> err := json.NewDecoder(r.Body).Decode(&j)
<mask> if err != nil {
<mask> httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err)
<mask> return
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
httpError(r, w, http.StatusBadRequest, "decoding request: %s", err) | <mask> func (s *Server) handleAccessSet(w http.ResponseWriter, r *http.Request) {
<mask> j := accessListJSON{}
<mask> err := json.NewDecoder(r.Body).Decode(&j)
<mask> if err != nil {
<mask> httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err)
<mask> return
<mask> }
<mask>
<mask> err = check... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
<mask> httpError(r, w, http.StatusBadRequest, "json.Decode: %s", err)
<mask> return
<mask> }
<mask>
<mask> err = checkIPCIDRArray(j.AllowedClients)
<mask> if err == nil {
<mask> err = checkIPCIDRArray(j.DisallowedClients)
<mask> }
<mask> if err != nil {
<mask> httpError(r, w, http.StatusBadReque... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go | |
a, err = newAccessCtx(list.AllowedClients, list.DisallowedClients, list.BlockedHosts) | <mask> return
<mask> }
<mask>
<mask> var a *accessCtx
<mask> a, err = newAccessCtx(j.AllowedClients, j.DisallowedClients, j.BlockedHosts)
<mask> if err != nil {
<mask> httpError(r, w, http.StatusBadRequest, "creating access ctx: %s", err)
<mask>
<mask> return
<mask> }
</s> Pull request: all: all... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
defer log.Debug(
"access: updated lists: %d, %d, %d",
len(list.AllowedClients),
len(list.DisallowedClients),
len(list.BlockedHosts),
) | <mask>
<mask> return
<mask> }
<mask>
<mask> defer log.Debug("Access: updated lists: %d, %d, %d",
<mask> len(j.AllowedClients), len(j.DisallowedClients), len(j.BlockedHosts))
<mask>
<mask> defer s.conf.ConfigModified()
<mask>
<mask> s.serverLock.Lock()
<mask> defer s.serverLock.Unlock()
</s> Pul... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
s.conf.AllowedClients = list.AllowedClients
s.conf.DisallowedClients = list.DisallowedClients
s.conf.BlockedHosts = list.BlockedHosts | <mask>
<mask> s.serverLock.Lock()
<mask> defer s.serverLock.Unlock()
<mask>
<mask> s.conf.AllowedClients = j.AllowedClients
<mask> s.conf.DisallowedClients = j.DisallowedClients
<mask> s.conf.BlockedHosts = j.BlockedHosts
<mask> s.access = a
<mask> }
</s> Pull request: all: allow clientid in access se... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access.go |
func TestIsBlockedClientID(t *testing.T) {
clientID := "client-1"
clients := []string{clientID} | <mask> "github.com/stretchr/testify/assert"
<mask> "github.com/stretchr/testify/require"
<mask> )
<mask>
<mask> func TestIsBlockedIP(t *testing.T) {
<mask> const (
<mask> ip int = iota
<mask> cidr
<mask> )
<mask>
<mask> rules := []string{
<mask> ip: "1.1.1.1",
<mask> cidr: "2.2.0.0/16",
<... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"replace",
"re... | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access_test.go |
a, err := newAccessCtx(clients, nil, nil)
require.NoError(t, err) | <mask> if !tc.allowed {
<mask> prefix = "disallowed_"
<mask> }
<mask>
<mask> t.Run(prefix+tc.name, func(t *testing.T) {
<mask> allowedRules := rules
<mask> var disallowedRules []string
<mask>
<mask> if !tc.allowed {
<mask> allowedRules, disallowedRules = disallowedRules, allowedRules
... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access_test.go |
assert.False(t, a.isBlockedClientID(clientID)) | <mask> t.Run(prefix+tc.name, func(t *testing.T) {
<mask> allowedRules := rules
<mask> var disallowedRules []string
<mask>
<mask> if !tc.allowed {
<mask> allowedRules, disallowedRules = disallowedRules, allowedRules
<mask> }
<mask>
<mask> aCtx, err := newAccessCtx(allowedRules, disallowed... | [
"keep",
"keep",
"keep",
"keep",
"replace",
"replace",
"replace",
"keep",
"keep",
"keep",
"keep",
"keep"
] | https://github.com/AdguardTeam/AdGuardHome/commit/e08a64ebe4919579275130e5a0c2e3f7c7ff070e | internal/dnsforward/access_test.go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.