config.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. Observatory json_util.RawMessage `json:"observatory"`
  19. }
  20. func (c *Config) Equals(other *Config) bool {
  21. if len(c.InboundConfigs) != len(other.InboundConfigs) {
  22. return false
  23. }
  24. for i, inbound := range c.InboundConfigs {
  25. if !inbound.Equals(&other.InboundConfigs[i]) {
  26. return false
  27. }
  28. }
  29. if !bytes.Equal(c.LogConfig, other.LogConfig) {
  30. return false
  31. }
  32. if !bytes.Equal(c.RouterConfig, other.RouterConfig) {
  33. return false
  34. }
  35. if !bytes.Equal(c.DNSConfig, other.DNSConfig) {
  36. return false
  37. }
  38. if !bytes.Equal(c.OutboundConfigs, other.OutboundConfigs) {
  39. return false
  40. }
  41. if !bytes.Equal(c.Transport, other.Transport) {
  42. return false
  43. }
  44. if !bytes.Equal(c.Policy, other.Policy) {
  45. return false
  46. }
  47. if !bytes.Equal(c.API, other.API) {
  48. return false
  49. }
  50. if !bytes.Equal(c.Stats, other.Stats) {
  51. return false
  52. }
  53. if !bytes.Equal(c.Reverse, other.Reverse) {
  54. return false
  55. }
  56. if !bytes.Equal(c.FakeDNS, other.FakeDNS) {
  57. return false
  58. }
  59. return true
  60. }