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