Fix: Rule with ipv6 address

This commit is contained in:
Dreamacro 2018-09-16 23:35:37 +08:00
parent 0724d4ea52
commit 1d0d5667fd

View File

@ -1,6 +1,7 @@
package config package config
import ( import (
"bufio"
"fmt" "fmt"
"os" "os"
"strconv" "strconv"
@ -74,7 +75,10 @@ func (c *Config) readConfig() (*ini.File, error) {
return nil, err return nil, err
} }
return ini.LoadSources( return ini.LoadSources(
ini.LoadOptions{AllowBooleanKeys: true}, ini.LoadOptions{
AllowBooleanKeys: true,
UnparseableSections: []string{"Rule"},
},
C.ConfigPath, C.ConfigPath,
) )
} }
@ -316,8 +320,14 @@ func (c *Config) parseRules(cfg *ini.File) error {
rulesConfig := cfg.Section("Rule") rulesConfig := cfg.Section("Rule")
// parse rules // parse rules
for _, key := range rulesConfig.Keys() { reader := bufio.NewReader(strings.NewReader(rulesConfig.Body()))
rule := strings.Split(key.Name(), ",") for {
line, _, err := reader.ReadLine()
if err != nil {
break
}
rule := strings.Split(string(line), ",")
if len(rule) < 3 { if len(rule) < 3 {
continue continue
} }