surge.go 670 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package provider
  2. import (
  3. "strings"
  4. "github.com/zu1k/proxypool/pkg/proxy"
  5. )
  6. type Surge struct {
  7. Proxies proxy.ProxyList `yaml:"proxies"`
  8. }
  9. func (s Surge) Provide() string {
  10. var resultBuilder strings.Builder
  11. for _, p := range s.Proxies {
  12. if checkSurgeSupport(p) {
  13. resultBuilder.WriteString(p.ToSurge() + "\n")
  14. }
  15. }
  16. return resultBuilder.String()
  17. }
  18. func checkSurgeSupport(p proxy.Proxy) bool {
  19. switch p.(type) {
  20. case *proxy.ShadowsocksR:
  21. return false
  22. case *proxy.Vmess:
  23. return true
  24. case *proxy.Shadowsocks:
  25. ss := p.(*proxy.Shadowsocks)
  26. if checkInList(ssCipherList, ss.Cipher) {
  27. return true
  28. }
  29. default:
  30. return false
  31. }
  32. return false
  33. }