mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-18 07:17:32 -05:00
Added Config for KCP connetions
This commit is contained in:
parent
77eee3ed37
commit
a8792b2b60
@ -1,12 +1,20 @@
|
|||||||
package transport
|
package transport
|
||||||
|
|
||||||
|
import "github.com/v2ray/v2ray-core/transport/hub/kcpv"
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ConnectionReuse bool
|
ConnectionReuse bool
|
||||||
|
enableKcp bool
|
||||||
|
kcpConfig *kcpv.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Config) Apply() error {
|
func (this *Config) Apply() error {
|
||||||
if this.ConnectionReuse {
|
if this.ConnectionReuse {
|
||||||
connectionReuse = true
|
connectionReuse = true
|
||||||
}
|
}
|
||||||
|
enableKcp = this.enableKcp
|
||||||
|
if enableKcp {
|
||||||
|
KcpConfig = this.kcpConfig
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,27 @@
|
|||||||
|
|
||||||
package transport
|
package transport
|
||||||
|
|
||||||
import "encoding/json"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/v2ray/v2ray-core/transport/hub/kcpv"
|
||||||
|
)
|
||||||
|
|
||||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||||
type JsonConfig struct {
|
type JsonConfig struct {
|
||||||
ConnectionReuse bool `json:"connectionReuse"`
|
ConnectionReuse bool `json:"connectionReuse"`
|
||||||
|
EnableKcp bool `json:"EnableKCP,omitempty"`
|
||||||
|
KcpConfig *kcpv.Config `json:"KcpConfig,omitempty"`
|
||||||
}
|
}
|
||||||
jsonConfig := &JsonConfig{
|
jsonConfig := &JsonConfig{
|
||||||
ConnectionReuse: true,
|
ConnectionReuse: true,
|
||||||
|
EnableKcp: false,
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
this.ConnectionReuse = jsonConfig.ConnectionReuse
|
this.ConnectionReuse = jsonConfig.ConnectionReuse
|
||||||
|
this.enableKcp = jsonConfig.EnableKcp
|
||||||
|
this.kcpConfig = kcpConfig
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
package transport
|
package transport
|
||||||
|
|
||||||
|
import "github.com/v2ray/v2ray-core/transport/hub/kcpv"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
connectionReuse = true
|
connectionReuse = true
|
||||||
|
enableKcp = false
|
||||||
|
KcpConfig *kcpv.Config
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsConnectionReusable() bool {
|
func IsConnectionReusable() bool {
|
||||||
return connectionReuse
|
return connectionReuse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsKcpEnabled() bool {
|
||||||
|
return enableKcp
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user