From 6ae4d5114e3550dc75e86dea3b7585893d648263 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Wed, 16 Jan 2019 22:25:35 +0800 Subject: [PATCH] fix peer config --- cmd/gost/peer.go | 6 +++--- cmd/gost/route.go | 9 ++++++--- ws.go | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cmd/gost/peer.go b/cmd/gost/peer.go index cec083b..4ed2e45 100644 --- a/cmd/gost/peer.go +++ b/cmd/gost/peer.go @@ -19,9 +19,9 @@ const ( ) type peerConfig struct { - Strategy string `json:"strategy"` - MaxFails int `json:"max_fails"` - FailTimeout time.Duration `json:"fail_timeout"` + Strategy string `json:"strategy"` + MaxFails int `json:"max_fails"` + FailTimeout time.Duration period time.Duration // the period for live reloading Nodes []string `json:"nodes"` group *gost.NodeGroup diff --git a/cmd/gost/route.go b/cmd/gost/route.go index 2f0690a..17271b9 100644 --- a/cmd/gost/route.go +++ b/cmd/gost/route.go @@ -59,9 +59,12 @@ func (r *route) parseChain() (*gost.Chain, error) { gost.WithStrategy(gost.NewStrategy(nodes[0].Get("strategy"))), ) - cfg := nodes[0].Get("peer") - f, err := os.Open(cfg) - if err == nil { + if cfg := nodes[0].Get("peer"); cfg != "" { + f, err := os.Open(cfg) + if err != nil { + return nil, err + } + peerCfg := newPeerConfig() peerCfg.group = ngroup peerCfg.baseNodes = nodes diff --git a/ws.go b/ws.go index 477eaaa..7a5a3ea 100644 --- a/ws.go +++ b/ws.go @@ -716,6 +716,9 @@ func generateChallengeKey() (string, error) { return base64.StdEncoding.EncodeToString(p), nil } +// TODO: due to the concurrency control in the websocket.Conn, +// a data race may be met when using with multiplexing. +// See: https://godoc.org/gopkg.in/gorilla/websocket.v1#hdr-Concurrency type websocketConn struct { conn *websocket.Conn rb []byte