config.go 1.8 KB

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