mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
fix #10
This commit is contained in:
parent
eb51142ebb
commit
1088bb19bc
21
conf.go
21
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.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.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.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.StringVar(&conf.DNS, "dns", "", "dns forwarder server listen address")
|
||||||
flag.StringSliceUniqVar(&conf.DNSServer, "dnsserver", []string{"8.8.8.8:53"}, "remote dns server")
|
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.rules = append(conf.rules, rule)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.RulesDir = path.Join(flag.ConfDir(), conf.RulesDir)
|
if conf.RulesDir != "" {
|
||||||
ruleFolderFiles, _ := listDir(conf.RulesDir, ".rule")
|
conf.RulesDir = path.Join(flag.ConfDir(), conf.RulesDir)
|
||||||
|
ruleFolderFiles, _ := listDir(conf.RulesDir, ".rule")
|
||||||
|
|
||||||
for _, ruleFile := range ruleFolderFiles {
|
for _, ruleFile := range ruleFolderFiles {
|
||||||
rule, err := NewRuleConfFromFile(ruleFile)
|
rule, err := NewRuleConfFromFile(ruleFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.rules = append(conf.rules, rule)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.rules = append(conf.rules, rule)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RuleConf , every ruleForwarder points to a rule file
|
// RuleConf , every ruleForwarder points to a rule file
|
||||||
|
2
main.go
2
main.go
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// VERSION .
|
// VERSION .
|
||||||
const VERSION = "0.4.0"
|
const VERSION = "0.4.1"
|
||||||
|
|
||||||
func dialerFromConf() Dialer {
|
func dialerFromConf() Dialer {
|
||||||
// global forwarders in xx.conf
|
// global forwarders in xx.conf
|
||||||
|
@ -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)
|
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 {
|
if err != nil {
|
||||||
logf("dial to %s error: %s", s.addr, err)
|
logf("dial to %s error: %s", s.addr, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user