fetch_setting.go 969 B

12345678910111213141516171819202122232425262728
  1. package system_setting
  2. import "one-api/setting/config"
  3. type FetchSetting struct {
  4. EnableSSRFProtection bool `json:"enable_ssrf_protection"` // 是否启用SSRF防护
  5. AllowPrivateIp bool `json:"allow_private_ip"`
  6. WhitelistDomains []string `json:"whitelist_domains"` // domain format, e.g. example.com, *.example.com
  7. WhitelistIps []string `json:"whitelist_ips"` // CIDR format
  8. AllowedPorts []string `json:"allowed_ports"` // port range format, e.g. 80, 443, 8000-9000
  9. }
  10. var defaultFetchSetting = FetchSetting{
  11. EnableSSRFProtection: true, // 默认开启SSRF防护
  12. AllowPrivateIp: false,
  13. WhitelistDomains: []string{},
  14. WhitelistIps: []string{},
  15. AllowedPorts: []string{"80", "443", "8080", "8443"},
  16. }
  17. func init() {
  18. // 注册到全局配置管理器
  19. config.GlobalConfig.Register("fetch_setting", &defaultFetchSetting)
  20. }
  21. func GetFetchSetting() *FetchSetting {
  22. return &defaultFetchSetting
  23. }