This commit is contained in:
nadoo 2017-09-04 23:32:12 +08:00
parent eb51142ebb
commit 1088bb19bc
3 changed files with 14 additions and 11 deletions

21
conf.go
View File

@ -37,7 +37,7 @@ func confInit() {
flag.StringSliceUniqVar(&conf.Listen, "listen", nil, "listen url, format: SCHEMA://[USER|METHOD:PASSWORD@][HOST]:PORT")
flag.StringSliceUniqVar(&conf.Forward, "forward", nil, "forward url, format: SCHEMA://[USER|METHOD:PASSWORD@][HOST]:PORT[,SCHEMA://[USER|METHOD:PASSWORD@][HOST]:PORT]")
flag.StringSliceUniqVar(&conf.RuleFile, "rulefile", nil, "rule file path")
flag.StringVar(&conf.RulesDir, "rules-dir", "rules.d", "rule file folder")
flag.StringVar(&conf.RulesDir, "rules-dir", "", "rule file folder")
flag.StringVar(&conf.DNS, "dns", "", "dns forwarder server listen address")
flag.StringSliceUniqVar(&conf.DNSServer, "dnsserver", []string{"8.8.8.8:53"}, "remote dns server")
@ -67,17 +67,20 @@ func confInit() {
conf.rules = append(conf.rules, rule)
}
conf.RulesDir = path.Join(flag.ConfDir(), conf.RulesDir)
ruleFolderFiles, _ := listDir(conf.RulesDir, ".rule")
if conf.RulesDir != "" {
conf.RulesDir = path.Join(flag.ConfDir(), conf.RulesDir)
ruleFolderFiles, _ := listDir(conf.RulesDir, ".rule")
for _, ruleFile := range ruleFolderFiles {
rule, err := NewRuleConfFromFile(ruleFile)
if err != nil {
log.Fatal(err)
for _, ruleFile := range ruleFolderFiles {
rule, err := NewRuleConfFromFile(ruleFile)
if err != nil {
log.Fatal(err)
}
conf.rules = append(conf.rules, rule)
}
conf.rules = append(conf.rules, rule)
}
}
// RuleConf , every ruleForwarder points to a rule file

View File

@ -9,7 +9,7 @@ import (
)
// VERSION .
const VERSION = "0.4.0"
const VERSION = "0.4.1"
func dialerFromConf() Dialer {
// global forwarders in xx.conf

View File

@ -139,7 +139,7 @@ func (s *SOCKS5) Dial(network, addr string) (net.Conn, error) {
return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network)
}
c, err := s.cDialer.Dial(s.network, s.addr)
c, err := s.cDialer.Dial(network, s.addr)
if err != nil {
logf("dial to %s error: %s", s.addr, err)
return nil, err