Skip to content

Commit 5290d57

Browse files
authored
fix: 🐛 修复 proxy_url SOCKS scheme 验证及 fetch-model 未传递 channel_proxy (#197)
* fix: 🐛 proxy_url 验证增加 socks5 scheme 支持 setting.go 验证白名单只有 socks,但 golang.org/x/net/proxy.FromURL() 只认 socks5,导致 SOCKS 代理无论怎么填都无法使用。 增加 socks5 到验证白名单。 * fix: 🐛 fetch-model 请求传递 channel_proxy 字段 FetchModelRequest 类型缺少 channel_proxy 字段,导致 fetch-model 请求不传该值,后端 ChannelProxy 始终为 nil,即使渠道已配置 channel_proxy 也会回退到系统代理并报 proxy url is empty。 fix #185 fix #186
1 parent fe78790 commit 5290d57

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

internal/model/setting.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ func (s *Setting) Validate() error {
6464
return fmt.Errorf("proxy URL is invalid: %w", err)
6565
}
6666
validSchemes := map[string]bool{
67-
"http": true,
68-
"https": true,
69-
"socks": true,
67+
"http": true,
68+
"https": true,
69+
"socks": true,
70+
"socks5": true,
7071
}
7172
if !validSchemes[parsedURL.Scheme] {
72-
return fmt.Errorf("proxy URL scheme must be http, https, or socks")
73+
return fmt.Errorf("proxy URL scheme must be http, https, socks, or socks5")
7374
}
7475
if parsedURL.Host == "" {
7576
return fmt.Errorf("proxy URL must have a host")

web/src/api/endpoints/channel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export type FetchModelRequest = {
124124
base_urls: BaseUrl[];
125125
keys: Array<Pick<ChannelKey, 'enabled' | 'channel_key'>>;
126126
proxy?: boolean;
127+
channel_proxy?: string | null;
127128
match_regex?: string | null;
128129
custom_header?: CustomHeader[];
129130
};

web/src/components/modules/channel/Form.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export function ChannelForm({
121121
.filter((k) => k.channel_key.trim())
122122
.map((k) => ({ enabled: k.enabled, channel_key: k.channel_key.trim() })),
123123
proxy: formData.proxy,
124+
channel_proxy: formData.channel_proxy?.trim() || null,
124125
match_regex: formData.match_regex.trim() || null,
125126
custom_header: formData.custom_header,
126127
},

0 commit comments

Comments
 (0)