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) oldAppIds = append(oldAppIds, old.ID)
} }
var transport *http.Transport transport := xpack.LoadRequestTransport()
ok, transportItem := xpack.LoadRequestTransport()
if ok {
transport = transportItem
}
baseRemoteUrl := fmt.Sprintf("%s/%s/1panel", global.CONF.System.AppRepo, global.CONF.System.Mode) baseRemoteUrl := fmt.Sprintf("%s/%s/1panel", global.CONF.System.AppRepo, global.CONF.System.Mode)
appsMap := getApps(oldApps, list.Apps) appsMap := getApps(oldApps, list.Apps)

View File

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

View File

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

View File

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