feat(canvas): 画布媒体工作流 - 支持批量连线、失败重试与模型能力增强
合并 PR #230。保留当前主线样式与组件结构,吸收批量连线、失败批次重试、媒体模型能力和相关后端增强,并修复集成检查发现的分辨率选择器启用条件与测试稳定性问题。
This commit is contained in:
1 parent
b0c3159f8e
commit
0e251c3c8f
48 files changed
+1582
-83
No files matched your search
@@ -13,6 +13,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/http/httpproxy"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -248,11 +250,16 @@ func blockedOutboundHeader(name string) bool {
|
||||
func newOutboundTransport(resolveHost func(context.Context, string) ([]net.IP, error)) *http.Transport {
|
||||
dialer := &net.Dialer{Timeout: 15 * time.Second, KeepAlive: 30 * time.Second}
|
||||
return &http.Transport{
|
||||
Proxy: outboundProxyFromEnvironment,
|
||||
DialContext: func(ctx context.Context, network string, address string) (net.Conn, error) {
|
||||
host, port, err := net.SplitHostPort(address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 代理地址由部署者通过环境变量配置;目标 URL 仍在请求前经过 SSRF 校验。
|
||||
if configuredProxyHost(host) {
|
||||
return dialer.DialContext(ctx, network, address)
|
||||
}
|
||||
addresses, err := resolveHost(ctx, host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -268,6 +275,31 @@ func newOutboundTransport(resolveHost func(context.Context, string) ([]net.IP, e
|
||||
}
|
||||
}
|
||||
|
||||
func outboundProxyFromEnvironment(req *http.Request) (*url.URL, error) {
|
||||
if req == nil || req.URL == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return httpproxy.FromEnvironment().ProxyFunc()(req.URL)
|
||||
}
|
||||
|
||||
func configuredProxyHost(host string) bool {
|
||||
host = normalizeOutboundHost(host)
|
||||
for _, name := range []string{"HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"} {
|
||||
raw := strings.TrimSpace(os.Getenv(name))
|
||||
if raw == "" {
|
||||
continue
|
||||
}
|
||||
if !strings.Contains(raw, "://") {
|
||||
raw = "http://" + raw
|
||||
}
|
||||
parsed, err := url.Parse(raw)
|
||||
if err == nil && normalizeOutboundHost(parsed.Hostname()) == host {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func validateOutboundHost(host string) error {
|
||||
_, err := resolveOutboundHost(context.Background(), host)
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user