mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
统一 domainStrategy
行为. (#2720)
* 统一 `domainStrategy` 行为. * Update proto --------- Co-authored-by: rui0572 <125641819+rui0572@users.noreply.github.com>
This commit is contained in:
parent
d9fd3f8eb1
commit
7523f7f440
5 changed files with 135 additions and 50 deletions
|
@ -12,6 +12,21 @@ var (
|
|||
globalTransportSettings []*TransportConfig
|
||||
)
|
||||
|
||||
var strategy = [][]byte{
|
||||
// name strategy, prefer, fallback
|
||||
{0, 0, 0}, // AsIs none, /, /
|
||||
{1, 0, 0}, // UseIP use, both, none
|
||||
{1, 4, 0}, // UseIPv4 use, 4, none
|
||||
{1, 6, 0}, // UseIPv6 use, 6, none
|
||||
{1, 4, 6}, // UseIPv4v6 use, 4, 6
|
||||
{1, 6, 4}, // UseIPv6v4 use, 6, 4
|
||||
{2, 0, 0}, // ForceIP force, both, none
|
||||
{2, 4, 0}, // ForceIPv4 force, 4, none
|
||||
{2, 6, 0}, // ForceIPv6 force, 6, none
|
||||
{2, 4, 6}, // ForceIPv4v6 force, 4, 6
|
||||
{2, 6, 4}, // ForceIPv6v4 force, 6, 4
|
||||
}
|
||||
|
||||
const unknownProtocol = "unknown"
|
||||
|
||||
func transportProtocolToString(protocol TransportProtocol) string {
|
||||
|
@ -122,3 +137,31 @@ func (c *ProxyConfig) HasTag() bool {
|
|||
func (m SocketConfig_TProxyMode) IsEnabled() bool {
|
||||
return m != SocketConfig_Off
|
||||
}
|
||||
|
||||
func (s DomainStrategy) hasStrategy() bool {
|
||||
return strategy[s][0] != 0
|
||||
}
|
||||
|
||||
func (s DomainStrategy) forceIP() bool {
|
||||
return strategy[s][0] == 2
|
||||
}
|
||||
|
||||
func (s DomainStrategy) preferIP4() bool {
|
||||
return strategy[s][1] == 4 || strategy[s][1] == 0
|
||||
}
|
||||
|
||||
func (s DomainStrategy) preferIP6() bool {
|
||||
return strategy[s][1] == 6 || strategy[s][1] == 0
|
||||
}
|
||||
|
||||
func (s DomainStrategy) hasFallback() bool {
|
||||
return strategy[s][2] != 0
|
||||
}
|
||||
|
||||
func (s DomainStrategy) fallbackIP4() bool {
|
||||
return strategy[s][2] == 4
|
||||
}
|
||||
|
||||
func (s DomainStrategy) fallbackIP6() bool {
|
||||
return strategy[s][2] == 6
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue