mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
fix: Fixed an issue where the language pack initialization download f… (#7375)
This commit is contained in:
parent
7f3cc784cd
commit
fa86c4f39a
@ -108,7 +108,7 @@ func loadRestorePath(upgradeDir string) (string, error) {
|
|||||||
|
|
||||||
func downloadLangFromRemote(fileOp files.FileOp) {
|
func downloadLangFromRemote(fileOp files.FileOp) {
|
||||||
path := fmt.Sprintf("%s/language/lang.tar.gz", global.CONF.System.RepoUrl)
|
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)
|
global.LOG.Errorf("download lang.tar.gz failed, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ func downloadLangFromRemote(fileOp files.FileOp) {
|
|||||||
func downloadGeoFromRemote(fileOp files.FileOp, targetPath string) {
|
func downloadGeoFromRemote(fileOp files.FileOp, targetPath string) {
|
||||||
_ = os.MkdirAll(path.Dir(targetPath), os.ModePerm)
|
_ = os.MkdirAll(path.Dir(targetPath), os.ModePerm)
|
||||||
pathItem := fmt.Sprintf("%s/geo/GeoIP.mmdb", global.CONF.System.RepoUrl)
|
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)
|
global.LOG.Errorf("download geo ip failed, err: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,30 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/xpack"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetHttpRes(url string) (*http.Response, error) {
|
func GetHttpRes(url string) (*http.Response, error) {
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: time.Second * 300,
|
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)
|
req, err := http.NewRequestWithContext(context.Background(), "GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user