mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-18 18:18:40 +00:00
remove "enabled" option
This commit is contained in:
parent
f118855aae
commit
4ca6302ad4
6 changed files with 93 additions and 83 deletions
|
@ -700,13 +700,29 @@ type CustomSockoptConfig struct {
|
|||
}
|
||||
|
||||
type HappyEyeballsConfig struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
PrioritizeIPv6 bool `json:"prioritizeIPv6"`
|
||||
TryDelayMs uint64 `json:"tryDelayMs"`
|
||||
Interleave uint32 `json:"interleave"`
|
||||
MaxConcurrentTry uint32 `json:"maxConcurrentTry"`
|
||||
}
|
||||
|
||||
func (h *HappyEyeballsConfig) UnmarshalJSON(data []byte) error {
|
||||
var innerHappyEyeballsConfig = struct {
|
||||
PrioritizeIPv6 bool `json:"prioritizeIPv6"`
|
||||
TryDelayMs uint64 `json:"tryDelayMs"`
|
||||
Interleave uint32 `json:"interleave"`
|
||||
MaxConcurrentTry uint32 `json:"maxConcurrentTry"`
|
||||
}{PrioritizeIPv6: false, Interleave: 1, TryDelayMs: 250, MaxConcurrentTry: 4}
|
||||
if err := json.Unmarshal(data, &innerHappyEyeballsConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
h.PrioritizeIPv6 = innerHappyEyeballsConfig.PrioritizeIPv6
|
||||
h.TryDelayMs = innerHappyEyeballsConfig.TryDelayMs
|
||||
h.Interleave = innerHappyEyeballsConfig.Interleave
|
||||
h.MaxConcurrentTry = innerHappyEyeballsConfig.MaxConcurrentTry
|
||||
return nil
|
||||
}
|
||||
|
||||
type SocketConfig struct {
|
||||
Mark int32 `json:"mark"`
|
||||
TFO interface{} `json:"tcpFastOpen"`
|
||||
|
@ -818,19 +834,12 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
|
|||
return nil, errors.New("unsupported address and port strategy: ", c.AddressPortStrategy)
|
||||
}
|
||||
|
||||
var happyEyeballs = &internet.HappyEyeballsConfig{Enabled: true, Interleave: 1, PrioritizeIpv6: false, TryDelayMs: 250, MaxConcurrentTry: 4}
|
||||
var happyEyeballs = &internet.HappyEyeballsConfig{Interleave: 1, PrioritizeIpv6: false, TryDelayMs: 250, MaxConcurrentTry: 4}
|
||||
if c.HappyEyeballsSettings != nil {
|
||||
happyEyeballs.Enabled = c.HappyEyeballsSettings.Enabled
|
||||
happyEyeballs.PrioritizeIpv6 = c.HappyEyeballsSettings.PrioritizeIPv6
|
||||
if c.HappyEyeballsSettings.Interleave > 0 {
|
||||
happyEyeballs.Interleave = c.HappyEyeballsSettings.Interleave
|
||||
}
|
||||
if c.HappyEyeballsSettings.TryDelayMs > 0 {
|
||||
happyEyeballs.TryDelayMs = c.HappyEyeballsSettings.TryDelayMs
|
||||
}
|
||||
if c.HappyEyeballsSettings.MaxConcurrentTry > 0 {
|
||||
happyEyeballs.MaxConcurrentTry = c.HappyEyeballsSettings.MaxConcurrentTry
|
||||
}
|
||||
happyEyeballs.Interleave = c.HappyEyeballsSettings.Interleave
|
||||
happyEyeballs.TryDelayMs = c.HappyEyeballsSettings.TryDelayMs
|
||||
happyEyeballs.MaxConcurrentTry = c.HappyEyeballsSettings.MaxConcurrentTry
|
||||
}
|
||||
|
||||
return &internet.SocketConfig{
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestSocketConfig(t *testing.T) {
|
|||
Tfo: 256,
|
||||
DomainStrategy: internet.DomainStrategy_USE_IP,
|
||||
DialerProxy: "tag",
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Enabled: true, Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
}
|
||||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ func TestSocketConfig(t *testing.T) {
|
|||
expectedOutput = &internet.SocketConfig{
|
||||
Mark: 0,
|
||||
Tfo: -1,
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Enabled: true, Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
}
|
||||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ func TestSocketConfig(t *testing.T) {
|
|||
expectedOutput = &internet.SocketConfig{
|
||||
Mark: 0,
|
||||
Tfo: 65535,
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Enabled: true, Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
}
|
||||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ func TestSocketConfig(t *testing.T) {
|
|||
expectedOutput = &internet.SocketConfig{
|
||||
Mark: 0,
|
||||
Tfo: -65535,
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Enabled: true, Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
}
|
||||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ func TestSocketConfig(t *testing.T) {
|
|||
expectedOutput = &internet.SocketConfig{
|
||||
Mark: 0,
|
||||
Tfo: 0,
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Enabled: true, Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
}
|
||||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ func TestSocketConfig(t *testing.T) {
|
|||
expectedOutput = &internet.SocketConfig{
|
||||
Mark: 0,
|
||||
Tfo: 0,
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Enabled: true, Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
}
|
||||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ func TestSocketConfig(t *testing.T) {
|
|||
expectedOutput = &internet.SocketConfig{
|
||||
Mark: 0,
|
||||
Tfo: 0,
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Enabled: true, Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 250, PrioritizeIpv6: false, MaxConcurrentTry: 4},
|
||||
}
|
||||
runMultiTestCase(t, []TestCase{
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue