From fa86c4f39ae1f0cc4be7723a8348a331513e70db Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:00:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Fixed=20an=20issue=20where=20the=20langu?= =?UTF-8?q?age=20pack=20initialization=20download=20f=E2=80=A6=20(#7375)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/init/lang/lang.go | 4 ++-- backend/utils/http/get.go | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/init/lang/lang.go b/backend/init/lang/lang.go index e5a041376..3f931480c 100644 --- a/backend/init/lang/lang.go +++ b/backend/init/lang/lang.go @@ -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 } diff --git a/backend/utils/http/get.go b/backend/utils/http/get.go index 4dd90da55..66a9aed1b 100644 --- a/backend/utils/http/get.go +++ b/backend/utils/http/get.go @@ -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 {