mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-01-06 01:37:12 +01:00
Print an error if a block/allow rule contains more than a pattern
... and it is not a time range.
This commit is contained in:
parent
31f4d7aa03
commit
6e8628f796
@ -43,10 +43,14 @@ func (plugin *PluginAllowName) Init(proxy *Proxy) error {
|
||||
parts := strings.Split(line, "@")
|
||||
timeRangeName := ""
|
||||
if len(parts) == 2 {
|
||||
line = strings.TrimSpace(parts[0])
|
||||
timeRangeName = strings.TrimSpace(parts[1])
|
||||
if timeRangeParts := strings.Split(parts[1], "@"); len(timeRangeParts) == 2 {
|
||||
timeRangeName = strings.TrimSpace(timeRangeParts[1])
|
||||
} else {
|
||||
dlog.Errorf("Syntax error in allowed names at line %d", 1+lineNo)
|
||||
continue
|
||||
}
|
||||
} else if len(parts) > 2 {
|
||||
dlog.Errorf("Syntax error in allowed names at line %d -- Unexpected @ character", 1+lineNo)
|
||||
dlog.Errorf("Syntax error in allowed names at line %d", 1+lineNo)
|
||||
continue
|
||||
}
|
||||
var weeklyRanges *WeeklyRanges
|
||||
|
@ -97,13 +97,17 @@ func (plugin *PluginBlockName) Init(proxy *Proxy) error {
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
}
|
||||
parts := strings.Split(line, "@")
|
||||
parts := strings.Fields(line)
|
||||
timeRangeName := ""
|
||||
if len(parts) == 2 {
|
||||
line = strings.TrimSpace(parts[0])
|
||||
timeRangeName = strings.TrimSpace(parts[1])
|
||||
if timeRangeParts := strings.Split(parts[1], "@"); len(timeRangeParts) == 2 {
|
||||
timeRangeName = strings.TrimSpace(timeRangeParts[1])
|
||||
} else {
|
||||
dlog.Errorf("Syntax error in block rules at line %d", 1+lineNo)
|
||||
continue
|
||||
}
|
||||
} else if len(parts) > 2 {
|
||||
dlog.Errorf("Syntax error in block rules at line %d -- Unexpected @ character", 1+lineNo)
|
||||
dlog.Errorf("Syntax error in block rules at line %d", 1+lineNo)
|
||||
continue
|
||||
}
|
||||
var weeklyRanges *WeeklyRanges
|
||||
|
Loading…
Reference in New Issue
Block a user