20399d3c8f
- Add ValidateURLWithFetchSetting check before fetching MJ image URLs in RelayMidjourneyImage (unauthenticated endpoint) - Add ValidateURLWithFetchSetting check before fetching video URLs in VideoProxy (upstream-controlled URL) - Enable ApplyIPFilterForDomain by default to prevent DNS rebinding bypass of SSRF protection - Elevate FetchModels endpoint from AdminAuth to RootAuth - Update frontend: mark domain IP filtering as recommended, update description and i18n translations (zh-CN/zh-TW/en/fr/ja/ru/vi)
35 lines
1.5 KiB
Go
35 lines
1.5 KiB
Go
package system_setting
|
|
|
|
import "github.com/QuantumNous/new-api/setting/config"
|
|
|
|
type FetchSetting struct {
|
|
EnableSSRFProtection bool `json:"enable_ssrf_protection"` // 是否启用SSRF防护
|
|
AllowPrivateIp bool `json:"allow_private_ip"`
|
|
DomainFilterMode bool `json:"domain_filter_mode"` // 域名过滤模式,true: 白名单模式,false: 黑名单模式
|
|
IpFilterMode bool `json:"ip_filter_mode"` // IP过滤模式,true: 白名单模式,false: 黑名单模式
|
|
DomainList []string `json:"domain_list"` // domain format, e.g. example.com, *.example.com
|
|
IpList []string `json:"ip_list"` // CIDR format
|
|
AllowedPorts []string `json:"allowed_ports"` // port range format, e.g. 80, 443, 8000-9000
|
|
ApplyIPFilterForDomain bool `json:"apply_ip_filter_for_domain"` // 对域名启用IP过滤(实验性)
|
|
}
|
|
|
|
var defaultFetchSetting = FetchSetting{
|
|
EnableSSRFProtection: true, // 默认开启SSRF防护
|
|
AllowPrivateIp: false,
|
|
DomainFilterMode: false,
|
|
IpFilterMode: false,
|
|
DomainList: []string{},
|
|
IpList: []string{},
|
|
AllowedPorts: []string{"80", "443", "8080", "8443"},
|
|
ApplyIPFilterForDomain: true,
|
|
}
|
|
|
|
func init() {
|
|
// 注册到全局配置管理器
|
|
config.GlobalConfig.Register("fetch_setting", &defaultFetchSetting)
|
|
}
|
|
|
|
func GetFetchSetting() *FetchSetting {
|
|
return &defaultFetchSetting
|
|
}
|