base.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package proxy
  2. type Base struct {
  3. Name string `yaml:"name" json:"name"`
  4. Server string `yaml:"server" json:"server"`
  5. Port int `yaml:"port" json:"port"`
  6. Type string `yaml:"type" json:"type"`
  7. UDP bool `yaml:"udp,omitempty" json:"udp,omitempty"`
  8. country string `yaml:"country,omitempty" json:"country,omitempty"`
  9. useable bool `yaml:"useable,omitempty" json:"useable,omitempty"`
  10. }
  11. func (b *Base) TypeName() string {
  12. if b.Type == "" {
  13. return "unknown"
  14. }
  15. return b.Type
  16. }
  17. func (b *Base) SetName(name string) {
  18. b.Name = name
  19. }
  20. func (b *Base) SetIP(ip string) {
  21. b.Server = ip
  22. }
  23. func (b *Base) BaseInfo() *Base {
  24. return b
  25. }
  26. func (b *Base) Clone() Base {
  27. c := *b
  28. return c
  29. }
  30. func (b *Base) SetUseable(useable bool) {
  31. b.useable = useable
  32. }
  33. func (b *Base) Useable() bool {
  34. return b.useable
  35. }
  36. func (b *Base) SetCountry(country string) {
  37. b.country = country
  38. }
  39. func (b *Base) Country() string {
  40. return b.country
  41. }
  42. type Proxy interface {
  43. String() string
  44. ToClash() string
  45. ToSurge() string
  46. Link() string
  47. Identifier() string
  48. SetName(name string)
  49. SetIP(ip string)
  50. TypeName() string
  51. BaseInfo() *Base
  52. Clone() Proxy
  53. SetUseable(useable bool)
  54. Useable() bool
  55. SetCountry(country string)
  56. Country() string
  57. }