base.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package proxy
  2. type Base struct {
  3. Name string `yaml:"name" json:"name" gorm:"index"`
  4. Server string `yaml:"server" json:"server" gorm:"index"`
  5. Port int `yaml:"port" json:"port" gorm:"index"`
  6. Type string `yaml:"type" json:"type" gorm:"index"`
  7. UDP bool `yaml:"udp,omitempty" json:"udp,omitempty"`
  8. Country string `yaml:"country,omitempty" json:"country,omitempty" gorm:"index"`
  9. Useable bool `yaml:"useable,omitempty" json:"useable,omitempty" gorm:"index"`
  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) SetCountry(country string) {
  34. b.Country = country
  35. }
  36. type Proxy interface {
  37. String() string
  38. ToClash() string
  39. ToSurge() string
  40. Link() string
  41. Identifier() string
  42. SetName(name string)
  43. SetIP(ip string)
  44. TypeName() string
  45. BaseInfo() *Base
  46. Clone() Proxy
  47. SetUseable(useable bool)
  48. SetCountry(country string)
  49. }