Merge branch 'master' into add_languages

This commit is contained in:
Ildar Kamalov 2018-11-26 15:44:07 +03:00
commit d1f5f781c9
8 changed files with 47 additions and 7 deletions

5
app.go
View File

@ -213,7 +213,10 @@ func promptAndGetPassword(prompt string) (string, error) {
} }
func askUsernamePasswordIfPossible() error { func askUsernamePasswordIfPossible() error {
configfile := filepath.Join(config.ourBinaryDir, config.ourConfigFilename) configfile := config.ourConfigFilename
if !filepath.IsAbs(configfile) {
configfile = filepath.Join(config.ourBinaryDir, config.ourConfigFilename)
}
_, err := os.Stat(configfile) _, err := os.Stat(configfile)
if !os.IsNotExist(err) { if !os.IsNotExist(err) {
// do nothing, file exists // do nothing, file exists

6
client/package-lock.json generated vendored
View File

@ -6588,7 +6588,7 @@
}, },
"html-webpack-plugin": { "html-webpack-plugin": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "http://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz", "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz",
"integrity": "sha1-sBq71yOsqqeze2r0SS69oD2d03s=", "integrity": "sha1-sBq71yOsqqeze2r0SS69oD2d03s=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -6638,7 +6638,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "1.0.34", "version": "1.0.34",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -15003,7 +15003,7 @@
}, },
"through": { "through": {
"version": "2.3.8", "version": "2.3.8",
"resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
"dev": true "dev": true
}, },

View File

@ -57,6 +57,24 @@ class Upstream extends Component {
</button> </button>
</div> </div>
</form> </form>
<hr/>
<div className="list leading-loose">
<Trans>examples_title</Trans>:
<ol className="leading-loose">
<li>
<code>1.1.1.1</code> - { t('example_upstream_regular') }
</li>
<li>
<code>tls://1dot1dot1dot1.cloudflare-dns.com</code> - <span dangerouslySetInnerHTML={{ __html: t('example_upstream_dot') }} />
</li>
<li>
<code>https://cloudflare-dns.com/dns-query</code> - <span dangerouslySetInnerHTML={{ __html: t('example_upstream_doh') }} />
</li>
<li>
<code>tcp://1.1.1.1</code> - { t('example_upstream_tcp') }
</li>
</ol>
</div>
</div> </div>
</div> </div>
</Card> </Card>

View File

@ -68,6 +68,8 @@ type coreDNSConfig struct {
ParentalSensitivity int `yaml:"parental_sensitivity"` ParentalSensitivity int `yaml:"parental_sensitivity"`
BlockedResponseTTL int `yaml:"blocked_response_ttl"` BlockedResponseTTL int `yaml:"blocked_response_ttl"`
QueryLogEnabled bool `yaml:"querylog_enabled"` QueryLogEnabled bool `yaml:"querylog_enabled"`
Ratelimit int `yaml:"-"`
RefuseAny bool `yaml:"-"`
Pprof string `yaml:"-"` Pprof string `yaml:"-"`
Cache string `yaml:"-"` Cache string `yaml:"-"`
Prometheus string `yaml:"-"` Prometheus string `yaml:"-"`
@ -102,6 +104,8 @@ var config = configuration{
SafeBrowsingEnabled: false, SafeBrowsingEnabled: false,
BlockedResponseTTL: 10, // in seconds BlockedResponseTTL: 10, // in seconds
QueryLogEnabled: true, QueryLogEnabled: true,
Ratelimit: 20,
RefuseAny: true,
BootstrapDNS: "8.8.8.8:53", BootstrapDNS: "8.8.8.8:53",
UpstreamDNS: defaultDNS, UpstreamDNS: defaultDNS,
Cache: "cache", Cache: "cache",
@ -253,7 +257,8 @@ const coreDNSConfigTemplate = `.:{{.Port}} {
{{end}} {{end}}
}{{end}} }{{end}}
{{.Pprof}} {{.Pprof}}
ratelimit {{if .RefuseAny}}refuseany{{end}}
{{if gt .Ratelimit 0}}ratelimit {{.Ratelimit}}{{end}}
hosts { hosts {
fallthrough fallthrough
} }

View File

@ -9,6 +9,7 @@ import (
_ "github.com/AdguardTeam/AdGuardHome/coredns_plugin" _ "github.com/AdguardTeam/AdGuardHome/coredns_plugin"
_ "github.com/AdguardTeam/AdGuardHome/coredns_plugin/ratelimit" _ "github.com/AdguardTeam/AdGuardHome/coredns_plugin/ratelimit"
_ "github.com/AdguardTeam/AdGuardHome/coredns_plugin/refuseany"
_ "github.com/AdguardTeam/AdGuardHome/upstream" _ "github.com/AdguardTeam/AdGuardHome/upstream"
"github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/coremain" "github.com/coredns/coredns/coremain"
@ -65,6 +66,7 @@ var directives = []string{
"prometheus", "prometheus",
"errors", "errors",
"log", "log",
"refuseany",
"ratelimit", "ratelimit",
"dnsfilter", "dnsfilter",
"dnstap", "dnstap",

View File

@ -27,8 +27,6 @@ func (p *plug) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
q := r.Question[0] q := r.Question[0]
if q.Qtype == dns.TypeANY { if q.Qtype == dns.TypeANY {
log.Printf("Got request with type ANY, will respond with NOTIMP\n")
state := request.Request{W: w, Req: r, Context: ctx} state := request.Request{W: w, Req: r, Context: ctx}
rcode := dns.RcodeNotImplemented rcode := dns.RcodeNotImplemented

View File

@ -474,6 +474,15 @@ func TestDnsFilterWhitelist(t *testing.T) {
d.checkMatch(t, "example.org") d.checkMatch(t, "example.org")
d.checkMatchEmpty(t, "test.example.org") d.checkMatchEmpty(t, "test.example.org")
d.checkMatchEmpty(t, "test.test.example.org") d.checkMatchEmpty(t, "test.test.example.org")
d.checkAddRule(t, "||googleadapis.l.google.com^|")
d.checkMatch(t, "googleadapis.l.google.com")
d.checkMatch(t, "test.googleadapis.l.google.com")
d.checkAddRule(t, "@@||googleadapis.l.google.com|")
d.checkMatchEmpty(t, "googleadapis.l.google.com")
d.checkMatchEmpty(t, "test.googleadapis.l.google.com")
} }
func TestDnsFilterImportant(t *testing.T) { func TestDnsFilterImportant(t *testing.T) {

View File

@ -72,6 +72,11 @@ func getSuffix(rule string) (bool, string) {
// last char was checked, eat it // last char was checked, eat it
rule = rule[:len(rule)-1] rule = rule[:len(rule)-1]
// it might also end with ^|
if rule[len(rule)-1] == '^' {
rule = rule[:len(rule)-1]
}
// check that it doesn't have any special characters inside // check that it doesn't have any special characters inside
for _, r := range rule { for _, r := range rule {
switch r { switch r {