chore: download geoX use inner

This commit is contained in:
Larvan2
2023-04-10 21:03:31 +08:00
parent 4d12ed491c
commit 304b4d9bcb
3 changed files with 33 additions and 12 deletions

View File

@ -1,15 +1,20 @@
package config
import (
"context"
"fmt"
"github.com/Dreamacro/clash/component/geodata"
_ "github.com/Dreamacro/clash/component/geodata/standard"
C "github.com/Dreamacro/clash/constant"
"github.com/oschwald/geoip2-golang"
"io"
"net/http"
"os"
"runtime"
"time"
"github.com/Dreamacro/clash/component/geodata"
_ "github.com/Dreamacro/clash/component/geodata/standard"
clashHttp "github.com/Dreamacro/clash/component/http"
C "github.com/Dreamacro/clash/constant"
"github.com/oschwald/geoip2-golang"
)
func UpdateGeoDatabases() error {
@ -69,7 +74,9 @@ func UpdateGeoDatabases() error {
}
func downloadForBytes(url string) ([]byte, error) {
resp, err := http.Get(url)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*90)
defer cancel()
resp, err := clashHttp.HttpRequest(ctx, url, http.MethodGet, http.Header{"User-Agent": {"clash"}}, nil)
if err != nil {
return nil, err
}