fix: 解决应用安装失败的问题 (#5319)

This commit is contained in:
ssongliu 2024-06-06 14:16:14 +08:00 committed by GitHub
parent 37de6aae66
commit 0e74acbec0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 31 deletions

View File

@ -840,11 +840,7 @@ func (a AppService) SyncAppListFromRemote() (err error) {
oldAppIds = append(oldAppIds, old.ID)
}
var transport *http.Transport
ok, transportItem := xpack.LoadRequestTransport()
if ok {
transport = transportItem
}
transport := xpack.LoadRequestTransport()
baseRemoteUrl := fmt.Sprintf("%s/%s/1panel", global.CONF.System.AppRepo, global.CONF.System.Mode)
appsMap := getApps(oldApps, list.Apps)

View File

@ -2,9 +2,7 @@ package http
import (
"context"
"crypto/tls"
"errors"
"net"
"net/http"
"strings"
"time"
@ -17,22 +15,8 @@ func GetHttpRes(url string) (*http.Response, error) {
client := &http.Client{
Timeout: time.Second * 300,
}
transportItem := &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,
}
ok, transport := xpack.LoadRequestTransport()
if ok {
transportItem.DialContext = transport.DialContext
transportItem.Proxy = transport.Proxy
}
client.Transport = transportItem
transport := xpack.LoadRequestTransport()
client.Transport = transport
req, err := http.NewRequestWithContext(context.Background(), "GET", url, nil)
if err != nil {

View File

@ -11,11 +11,7 @@ import (
)
func HandleGet(url, method string) (int, []byte, error) {
var transport *http.Transport
ok, transportItem := xpack.LoadRequestTransport()
if ok {
transport = transportItem
}
transport := xpack.LoadRequestTransport()
return HandleGetWithTransport(url, method, transport)
}

View File

@ -2,12 +2,26 @@
package xpack
import "net/http"
import (
"crypto/tls"
"net"
"net/http"
"time"
)
func RemoveTamper(website string) {}
func LoadRequestTransport() (bool, *http.Transport) {
return false, nil
func LoadRequestTransport() *http.Transport {
return &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,
}
}
func LoadGpuInfo() []interface{} {