Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat: support system proxy for remote API
Manx981baabb6c05d4
diff --git a/internal/models/chat/remote_api.go b/internal/models/chat/remote_api.goindex 44459127f..21d574190 100644--- a/internal/models/chat/remote_api.go+++ b/internal/models/chat/remote_api.go@@ -22,6 +22,7 @@ import (// Uses SSRFSafeDialContext to prevent DNS rebinding attacks at the connection layer.var rawHTTPClient = &http.Client{Transport: &http.Transport{+ Proxy: http.ProxyFromEnvironment,DialContext: secutils.SSRFSafeDialContext,TLSHandshakeTimeout: 10 * time.Second,IdleConnTimeout: 90 * time.Second,diff --git a/internal/utils/security.go b/internal/utils/security.goindex 4cb6d9ea3..f54e418a4 100644--- a/internal/utils/security.go+++ b/internal/utils/security.go@@ -14,6 +14,8 @@ import ("sync""time""unicode/utf8"++ "golang.org/x/net/http/httpproxy")// XSS 防护相关正则表达式@@ -781,7 +783,7 @@ func SSRFSafeDialContext(ctx context.Context, network, addr string) (net.Conn, e// Whitelisted hosts bypass all dial-time SSRF checks, consistent with// ValidateURLForSSRF which skips IsSSRFSafeURL for whitelisted hosts.- if IsSSRFWhitelisted(host) {+ if IsSystemProxy(addr) || IsSSRFWhitelisted(host) {dialer := &net.Dialer{Timeout: 30 * time.Second,KeepAlive: 30 * time.Second,@@ -978,3 +980,22 @@ func ValidateURLForSSRF(rawURL string) error {}return nil}++// IsSystemProxy 判断是否为系统代理+func IsSystemProxy(host string) bool {+ proxyCfg := httpproxy.FromEnvironment()+ for _, proxyUrl := range []string{+ proxyCfg.HTTPProxy,+ proxyCfg.HTTPSProxy,+ } {+ if proxyUrl == "" {+ continue+ }+ if parse, err := url.Parse(proxyUrl); err == nil {+ if parse.Host == host {+ return true+ }+ }+ }+ return false+}