mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
rule: use new concurrent sync.Map instead of old map
This commit is contained in:
1 parent
65f33beaa3
commit
1b400d984e
2 files changed
+48
-33
No files matched your search
@@ -26,15 +26,13 @@ func dialerFromConf() Dialer {
|
||||
forwarders = append(forwarders, forward)
|
||||
}
|
||||
|
||||
forwarder := NewStrategyDialer(conf.Strategy, forwarders, conf.CheckWebSite, conf.CheckDuration)
|
||||
|
||||
return NewRuleDialer(conf.rules, forwarder)
|
||||
return NewStrategyDialer(conf.Strategy, forwarders, conf.CheckWebSite, conf.CheckDuration)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
confInit()
|
||||
sDialer := dialerFromConf()
|
||||
sDialer := NewRuleDialer(conf.rules, dialerFromConf())
|
||||
|
||||
for _, listen := range conf.Listen {
|
||||
local, err := ServerFromURL(listen, sDialer)
|
||||
@@ -60,13 +58,8 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// test here
|
||||
dns.AddAnswerHandler(func(domain, ip string) error {
|
||||
if ip != "" {
|
||||
logf("domain: %s, ip: %s\n", domain, ip)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
// add a handler to update proxy rules when a domain resolved
|
||||
dns.AddAnswerHandler(sDialer.AddDomainIP)
|
||||
|
||||
go dns.ListenAndServe()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user