fix: provider auto update

This commit is contained in:
Skyxim
2022-05-08 00:04:16 +08:00
parent 663bf4fbb0
commit 2fbbf7519f
6 changed files with 30 additions and 14 deletions

View File

@ -43,6 +43,14 @@ func (f *fetcher) Initial() (any, error) {
err error
isLocal bool
)
defer func() {
// pull proxies automatically
if f.ticker != nil {
go f.pullLoop()
}
}()
if stat, fErr := os.Stat(f.vehicle.Path()); fErr == nil {
buf, err = os.ReadFile(f.vehicle.Path())
modTime := stat.ModTime()
@ -84,11 +92,6 @@ func (f *fetcher) Initial() (any, error) {
f.hash = md5.Sum(buf)
// pull proxies automatically
if f.ticker != nil {
go f.pullLoop()
}
return proxies, nil
}

View File

@ -74,7 +74,7 @@ func (h *HTTPVehicle) Read() ([]byte, error) {
// from http.DefaultTransport
MaxIdleConns: 100,
IdleConnTimeout: 30 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
TLSHandshakeTimeout: 5 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
conn := inner.HandleTcp(address, uri.Hostname())