Commit d695429e authored by ginuerzh's avatar ginuerzh

fix data race in kcp

parent dc4c78ca
...@@ -66,7 +66,7 @@ func (c *KCPConfig) Init() { ...@@ -66,7 +66,7 @@ func (c *KCPConfig) Init() {
var ( var (
// DefaultKCPConfig is the default KCP config. // DefaultKCPConfig is the default KCP config.
DefaultKCPConfig = &KCPConfig{ DefaultKCPConfig = KCPConfig{
Key: "it's a secrect", Key: "it's a secrect",
Crypt: "aes", Crypt: "aes",
Mode: "fast", Mode: "fast",
...@@ -99,7 +99,8 @@ type kcpTransporter struct { ...@@ -99,7 +99,8 @@ type kcpTransporter struct {
// KCPTransporter creates a Transporter that is used by KCP proxy client. // KCPTransporter creates a Transporter that is used by KCP proxy client.
func KCPTransporter(config *KCPConfig) Transporter { func KCPTransporter(config *KCPConfig) Transporter {
if config == nil { if config == nil {
config = DefaultKCPConfig config = &KCPConfig{}
*config = DefaultKCPConfig
} }
config.Init() config.Init()
...@@ -227,7 +228,8 @@ type kcpListener struct { ...@@ -227,7 +228,8 @@ type kcpListener struct {
// KCPListener creates a Listener for KCP proxy server. // KCPListener creates a Listener for KCP proxy server.
func KCPListener(addr string, config *KCPConfig) (Listener, error) { func KCPListener(addr string, config *KCPConfig) (Listener, error) {
if config == nil { if config == nil {
config = DefaultKCPConfig config = &KCPConfig{}
*config = DefaultKCPConfig
} }
config.Init() config.Init()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment