fetch_setting.go 1.3 KB

1234567891011121314151617181920212223242526272829303132
  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. DomainFilterMode bool `json:"domain_filter_mode"` // 域名过滤模式,true: 白名单模式,false: 黑名单模式
  7. IpFilterMode bool `json:"ip_filter_mode"` // IP过滤模式,true: 白名单模式,false: 黑名单模式
  8. DomainList []string `json:"domain_list"` // domain format, e.g. example.com, *.example.com
  9. IpList []string `json:"ip_list"` // CIDR format
  10. AllowedPorts []string `json:"allowed_ports"` // port range format, e.g. 80, 443, 8000-9000
  11. }
  12. var defaultFetchSetting = FetchSetting{
  13. EnableSSRFProtection: true, // 默认开启SSRF防护
  14. AllowPrivateIp: false,
  15. DomainFilterMode: true,
  16. IpFilterMode: true,
  17. DomainList: []string{},
  18. IpList: []string{},
  19. AllowedPorts: []string{"80", "443", "8080", "8443"},
  20. }
  21. func init() {
  22. // 注册到全局配置管理器
  23. config.GlobalConfig.Register("fetch_setting", &defaultFetchSetting)
  24. }
  25. func GetFetchSetting() *FetchSetting {
  26. return &defaultFetchSetting
  27. }