allan716 преди 3 години
родител
ревизия
acd19ded94

+ 4 - 0
internal/backend/controllers/base/proxy.go

@@ -54,6 +54,10 @@ func (cb *ControllerBase) CheckProxyHandler(c *gin.Context) {
 
 	defer func() {
 		// 还原
+		err = cb.fileDownloader.Settings.AdvancedSettings.ProxySettings.CloseLocalHttpProxyServer()
+		if err != nil {
+			return
+		}
 		cb.fileDownloader.Settings.AdvancedSettings.ProxySettings = bkProxySettings
 	}()
 

+ 4 - 0
internal/pkg/local_http_proxy_server/local_http_proxy_server.go

@@ -76,6 +76,8 @@ func (l *LocalHttpProxyServer) Start(settings []string, localHttpProxyServerPort
 			if err := l.srv.ListenAndServe(); err != http.ErrServerClosed {
 				panic(fmt.Sprintln("ListenAndServe() http proxy:", err))
 			}
+
+			println("http proxy closed")
 		}()
 
 		l.isRunning = true
@@ -125,6 +127,8 @@ func (l *LocalHttpProxyServer) Start(settings []string, localHttpProxyServerPort
 			if err := l.srv.ListenAndServe(); err != http.ErrServerClosed {
 				panic(fmt.Sprintln("ListenAndServe() socks5 proxy:", err))
 			}
+
+			println("socks5 proxy closed")
 		}()
 
 		l.isRunning = true

+ 5 - 1
internal/pkg/url_connectedness_helper/url_connectedness_helper.go

@@ -1,6 +1,7 @@
 package url_connectedness_helper
 
 import (
+	"crypto/tls"
 	"errors"
 	"net/http"
 	"net/url"
@@ -32,8 +33,11 @@ func UrlConnectednessTest(testUrl, proxyAddr string) (bool, int64, error) {
 		// 设置网络传输
 		netTransport := &http.Transport{
 			Proxy:                 http.ProxyURL(proxy),
-			MaxIdleConnsPerHost:   10,
+			MaxIdleConnsPerHost:   1000,
 			ResponseHeaderTimeout: time.Second * time.Duration(testUrlTimeOut),
+			TLSClientConfig: &tls.Config{
+				InsecureSkipVerify: true,
+			},
 		}
 		// 创建连接客户端
 		httpClient = http.Client{