2025-09-13 17:34:22 +08:00
|
|
|
|
package system_setting
|
|
|
|
|
|
|
2025-10-11 15:30:09 +08:00
|
|
|
|
import "github.com/QuantumNous/new-api/setting/config"
|
2025-09-13 17:34:22 +08:00
|
|
|
|
|
|
|
|
|
|
type FetchSetting struct {
|
2025-09-17 23:46:04 +08:00
|
|
|
|
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过滤(实验性)
|
2025-09-13 17:34:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var defaultFetchSetting = FetchSetting{
|
2025-09-17 23:46:04 +08:00
|
|
|
|
EnableSSRFProtection: true, // 默认开启SSRF防护
|
|
|
|
|
|
AllowPrivateIp: false,
|
2025-09-18 13:40:52 +08:00
|
|
|
|
DomainFilterMode: false,
|
|
|
|
|
|
IpFilterMode: false,
|
2025-09-17 23:46:04 +08:00
|
|
|
|
DomainList: []string{},
|
|
|
|
|
|
IpList: []string{},
|
|
|
|
|
|
AllowedPorts: []string{"80", "443", "8080", "8443"},
|
|
|
|
|
|
ApplyIPFilterForDomain: false,
|
2025-09-13 17:34:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
// 注册到全局配置管理器
|
|
|
|
|
|
config.GlobalConfig.Register("fetch_setting", &defaultFetchSetting)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func GetFetchSetting() *FetchSetting {
|
|
|
|
|
|
return &defaultFetchSetting
|
|
|
|
|
|
}
|