inbound.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package xray
  2. import (
  3. "bytes"
  4. "github.com/mhsanaei/3x-ui/v2/util/json_util"
  5. )
  6. // InboundConfig represents an Xray inbound configuration.
  7. // It defines how Xray accepts incoming connections including protocol, port, and settings.
  8. type InboundConfig struct {
  9. Listen json_util.RawMessage `json:"listen"` // listen cannot be an empty string
  10. Port int `json:"port"`
  11. Protocol string `json:"protocol"`
  12. Settings json_util.RawMessage `json:"settings"`
  13. StreamSettings json_util.RawMessage `json:"streamSettings"`
  14. Tag string `json:"tag"`
  15. Sniffing json_util.RawMessage `json:"sniffing"`
  16. }
  17. // Equals compares two InboundConfig instances for deep equality.
  18. func (c *InboundConfig) Equals(other *InboundConfig) bool {
  19. if !bytes.Equal(c.Listen, other.Listen) {
  20. return false
  21. }
  22. if c.Port != other.Port {
  23. return false
  24. }
  25. if c.Protocol != other.Protocol {
  26. return false
  27. }
  28. if !bytes.Equal(c.Settings, other.Settings) {
  29. return false
  30. }
  31. if !bytes.Equal(c.StreamSettings, other.StreamSettings) {
  32. return false
  33. }
  34. if c.Tag != other.Tag {
  35. return false
  36. }
  37. if !bytes.Equal(c.Sniffing, other.Sniffing) {
  38. return false
  39. }
  40. return true
  41. }