github.com/xmplusdev/xray-core@v1.8.10/proxy/freedom/config.go (about) 1 package freedom 2 3 var strategy = [][]byte{ 4 // name strategy, prefer, fallback 5 {0, 0, 0}, // AsIs none, /, / 6 {1, 0, 0}, // UseIP use, both, none 7 {1, 4, 0}, // UseIPv4 use, 4, none 8 {1, 6, 0}, // UseIPv6 use, 6, none 9 {1, 4, 6}, // UseIPv4v6 use, 4, 6 10 {1, 6, 4}, // UseIPv6v4 use, 6, 4 11 {2, 0, 0}, // ForceIP force, both, none 12 {2, 4, 0}, // ForceIPv4 force, 4, none 13 {2, 6, 0}, // ForceIPv6 force, 6, none 14 {2, 4, 6}, // ForceIPv4v6 force, 4, 6 15 {2, 6, 4}, // ForceIPv6v4 force, 6, 4 16 } 17 18 func (c *Config) hasStrategy() bool { 19 return strategy[c.DomainStrategy][0] != 0 20 } 21 22 func (c *Config) forceIP() bool { 23 return strategy[c.DomainStrategy][0] == 2 24 } 25 26 func (c *Config) preferIP4() bool { 27 return strategy[c.DomainStrategy][1] == 4 || strategy[c.DomainStrategy][1] == 0 28 } 29 30 func (c *Config) preferIP6() bool { 31 return strategy[c.DomainStrategy][1] == 6 || strategy[c.DomainStrategy][1] == 0 32 } 33 34 func (c *Config) hasFallback() bool { 35 return strategy[c.DomainStrategy][2] != 0 36 } 37 38 func (c *Config) fallbackIP4() bool { 39 return strategy[c.DomainStrategy][2] == 4 40 } 41 42 func (c *Config) fallbackIP6() bool { 43 return strategy[c.DomainStrategy][2] == 6 44 }