diff --git a/conf.go b/conf.go index bfd3866..7b2ac9e 100644 --- a/conf.go +++ b/conf.go @@ -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 diff --git a/main.go b/main.go index 6ffed3a..b57fd36 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( ) // VERSION . -const VERSION = "0.4.0" +const VERSION = "0.4.1" func dialerFromConf() Dialer { // global forwarders in xx.conf diff --git a/socks5.go b/socks5.go index 1922f5e..5b6326f 100644 --- a/socks5.go +++ b/socks5.go @@ -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