config.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package xray
  2. import (
  3. "bytes"
  4. "x-ui/util/json_util"
  5. )
  6. type Config struct {
  7. LogConfig json_util.RawMessage `json:"log"`
  8. RouterConfig json_util.RawMessage `json:"routing"`
  9. DNSConfig json_util.RawMessage `json:"dns"`
  10. InboundConfigs []InboundConfig `json:"inbounds"`
  11. OutboundConfigs json_util.RawMessage `json:"outbounds"`
  12. Transport json_util.RawMessage `json:"transport"`
  13. Policy json_util.RawMessage `json:"policy"`
  14. API json_util.RawMessage `json:"api"`
  15. Stats json_util.RawMessage `json:"stats"`
  16. Reverse json_util.RawMessage `json:"reverse"`
  17. FakeDNS json_util.RawMessage `json:"fakeDns"`
  18. }
  19. func (c *Config) Equals(other *Config) bool {
  20. if len(c.InboundConfigs) != len(other.InboundConfigs) {
  21. return false
  22. }
  23. for i, inbound := range c.InboundConfigs {
  24. if !inbound.Equals(&other.InboundConfigs[i]) {
  25. return false
  26. }
  27. }
  28. if !bytes.Equal(c.LogConfig, other.LogConfig) {
  29. return false
  30. }
  31. if !bytes.Equal(c.RouterConfig, other.RouterConfig) {
  32. return false
  33. }
  34. if !bytes.Equal(c.DNSConfig, other.DNSConfig) {
  35. return false
  36. }
  37. if !bytes.Equal(c.OutboundConfigs, other.OutboundConfigs) {
  38. return false
  39. }
  40. if !bytes.Equal(c.Transport, other.Transport) {
  41. return false
  42. }
  43. if !bytes.Equal(c.Policy, other.Policy) {
  44. return false
  45. }
  46. if !bytes.Equal(c.API, other.API) {
  47. return false
  48. }
  49. if !bytes.Equal(c.Stats, other.Stats) {
  50. return false
  51. }
  52. if !bytes.Equal(c.Reverse, other.Reverse) {
  53. return false
  54. }
  55. if !bytes.Equal(c.FakeDNS, other.FakeDNS) {
  56. return false
  57. }
  58. return true
  59. }