* dnsfilter: windows: store rules in memory
* dnsfilter: ignore cosmetic rules
This commit is contained in:
parent
67f31ccf43
commit
6ba1d857ac
@ -13,6 +13,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -772,18 +773,31 @@ func (d *Dnsfilter) initFiltering(filters map[int]string) error {
|
|||||||
list = &urlfilter.StringRuleList{
|
list = &urlfilter.StringRuleList{
|
||||||
ID: 0,
|
ID: 0,
|
||||||
RulesText: dataOrFilePath,
|
RulesText: dataOrFilePath,
|
||||||
IgnoreCosmetic: false,
|
IgnoreCosmetic: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if !fileExists(dataOrFilePath) {
|
} else if !fileExists(dataOrFilePath) {
|
||||||
list = &urlfilter.StringRuleList{
|
list = &urlfilter.StringRuleList{
|
||||||
ID: id,
|
ID: id,
|
||||||
IgnoreCosmetic: false,
|
IgnoreCosmetic: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if runtime.GOOS == "windows" {
|
||||||
|
// On Windows we don't pass a file to urlfilter because
|
||||||
|
// it's difficult to update this file while it's being used.
|
||||||
|
data, err := ioutil.ReadFile(dataOrFilePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("ioutil.ReadFile(): %s: %s", dataOrFilePath, err)
|
||||||
|
}
|
||||||
|
list = &urlfilter.StringRuleList{
|
||||||
|
ID: id,
|
||||||
|
RulesText: string(data),
|
||||||
|
IgnoreCosmetic: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var err error
|
var err error
|
||||||
list, err = urlfilter.NewFileRuleList(id, dataOrFilePath, false)
|
list, err = urlfilter.NewFileRuleList(id, dataOrFilePath, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("urlfilter.NewFileRuleList(): %s: %s", dataOrFilePath, err)
|
return fmt.Errorf("urlfilter.NewFileRuleList(): %s: %s", dataOrFilePath, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user