refactor: provider init order
This commit is contained in:
parent
535528c8bd
commit
adcad74452
2 changed files with 21 additions and 5 deletions
|
@ -73,7 +73,7 @@ func (h *HTTPVehicle) Read() ([]byte, error) {
|
||||||
transport := &http.Transport{
|
transport := &http.Transport{
|
||||||
// from http.DefaultTransport
|
// from http.DefaultTransport
|
||||||
MaxIdleConns: 100,
|
MaxIdleConns: 100,
|
||||||
IdleConnTimeout: 90 * time.Second,
|
IdleConnTimeout: 30 * time.Second,
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
ExpectContinueTimeout: 1 * time.Second,
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||||
|
|
|
@ -203,15 +203,31 @@ func loadProvider(pv provider.Provider) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadRuleProvider(ruleProviders map[string]provider.RuleProvider) {
|
func loadRuleProvider(ruleProviders map[string]provider.RuleProvider) {
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
for _, ruleProvider := range ruleProviders {
|
for _, ruleProvider := range ruleProviders {
|
||||||
loadProvider(ruleProvider)
|
ruleProvider := ruleProvider
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer func() { wg.Done() }()
|
||||||
|
loadProvider(ruleProvider)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadProxyProvider(ruleProviders map[string]provider.ProxyProvider) {
|
func loadProxyProvider(proxyProviders map[string]provider.ProxyProvider) {
|
||||||
for _, ruleProvider := range ruleProviders {
|
wg := sync.WaitGroup{}
|
||||||
loadProvider(ruleProvider)
|
for _, proxyProvider := range proxyProviders {
|
||||||
|
proxyProvider := proxyProvider
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer func() { wg.Done() }()
|
||||||
|
loadProvider(proxyProvider)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateTun(tun *config.Tun, dns *config.DNS) {
|
func updateTun(tun *config.Tun, dns *config.DNS) {
|
||||||
|
|
Loading…
Reference in a new issue