1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 05:58:06 +08:00

fix: Fixed an issue where the language pack initialization download f… (#7375)

This commit is contained in:
ssongliu 2024-12-16 17:00:10 +08:00 committed by GitHub
parent 7f3cc784cd
commit fa86c4f39a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View File

@ -108,7 +108,7 @@ func loadRestorePath(upgradeDir string) (string, error) {
func downloadLangFromRemote(fileOp files.FileOp) {
path := fmt.Sprintf("%s/language/lang.tar.gz", global.CONF.System.RepoUrl)
if err := fileOp.DownloadFileWithProxy(path, "/usr/local/bin/lang.tar.gz"); err != nil {
if err := fileOp.DownloadFile(path, "/usr/local/bin/lang.tar.gz"); err != nil {
global.LOG.Errorf("download lang.tar.gz failed, err: %v", err)
return
}
@ -127,7 +127,7 @@ func downloadLangFromRemote(fileOp files.FileOp) {
func downloadGeoFromRemote(fileOp files.FileOp, targetPath string) {
_ = os.MkdirAll(path.Dir(targetPath), os.ModePerm)
pathItem := fmt.Sprintf("%s/geo/GeoIP.mmdb", global.CONF.System.RepoUrl)
if err := fileOp.DownloadFileWithProxy(pathItem, targetPath); err != nil {
if err := fileOp.DownloadFile(pathItem, targetPath); err != nil {
global.LOG.Errorf("download geo ip failed, err: %v", err)
return
}

View File

@ -2,21 +2,30 @@ package http
import (
"context"
"crypto/tls"
"errors"
"net"
"net/http"
"strings"
"time"
"github.com/1Panel-dev/1Panel/backend/buserr"
"github.com/1Panel-dev/1Panel/backend/utils/xpack"
)
func GetHttpRes(url string) (*http.Response, error) {
client := &http.Client{
Timeout: time.Second * 300,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
DialContext: (&net.Dialer{
Timeout: 60 * time.Second,
KeepAlive: 60 * time.Second,
}).DialContext,
TLSHandshakeTimeout: 5 * time.Second,
ResponseHeaderTimeout: 10 * time.Second,
IdleConnTimeout: 15 * time.Second,
},
}
transport := xpack.LoadRequestTransport()
client.Transport = transport
req, err := http.NewRequestWithContext(context.Background(), "GET", url, nil)
if err != nil {