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{
|
||||
// from http.DefaultTransport
|
||||
MaxIdleConns: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
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) {
|
||||
wg := sync.WaitGroup{}
|
||||
for _, ruleProvider := range ruleProviders {
|
||||
ruleProvider := ruleProvider
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer func() { wg.Done() }()
|
||||
loadProvider(ruleProvider)
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func loadProxyProvider(ruleProviders map[string]provider.ProxyProvider) {
|
||||
for _, ruleProvider := range ruleProviders {
|
||||
loadProvider(ruleProvider)
|
||||
func loadProxyProvider(proxyProviders map[string]provider.ProxyProvider) {
|
||||
wg := sync.WaitGroup{}
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue