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,14 +1,18 @@
package mmdb
import (
"github.com/oschwald/geoip2-golang"
"context"
"io"
"net/http"
"os"
"sync"
"time"
clashHttp "github.com/Dreamacro/clash/component/http"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/log"
"github.com/oschwald/geoip2-golang"
)
var (
@ -47,7 +51,9 @@ func Instance() *geoip2.Reader {
}
func DownloadMMDB(path string) (err error) {
resp, err := http.Get(C.MmdbUrl)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*90)
defer cancel()
resp, err := clashHttp.HttpRequest(ctx, C.MmdbUrl, http.MethodGet, http.Header{"User-Agent": {"clash"}}, nil)
if err != nil {
return
}