Commit 6ae4d511 authored by ginuerzh's avatar ginuerzh

fix peer config

parent 7c7a51ec
...@@ -19,9 +19,9 @@ const ( ...@@ -19,9 +19,9 @@ const (
) )
type peerConfig struct { type peerConfig struct {
Strategy string `json:"strategy"` Strategy string `json:"strategy"`
MaxFails int `json:"max_fails"` MaxFails int `json:"max_fails"`
FailTimeout time.Duration `json:"fail_timeout"` FailTimeout time.Duration
period time.Duration // the period for live reloading period time.Duration // the period for live reloading
Nodes []string `json:"nodes"` Nodes []string `json:"nodes"`
group *gost.NodeGroup group *gost.NodeGroup
......
...@@ -59,9 +59,12 @@ func (r *route) parseChain() (*gost.Chain, error) { ...@@ -59,9 +59,12 @@ func (r *route) parseChain() (*gost.Chain, error) {
gost.WithStrategy(gost.NewStrategy(nodes[0].Get("strategy"))), gost.WithStrategy(gost.NewStrategy(nodes[0].Get("strategy"))),
) )
cfg := nodes[0].Get("peer") if cfg := nodes[0].Get("peer"); cfg != "" {
f, err := os.Open(cfg) f, err := os.Open(cfg)
if err == nil { if err != nil {
return nil, err
}
peerCfg := newPeerConfig() peerCfg := newPeerConfig()
peerCfg.group = ngroup peerCfg.group = ngroup
peerCfg.baseNodes = nodes peerCfg.baseNodes = nodes
......
...@@ -716,6 +716,9 @@ func generateChallengeKey() (string, error) { ...@@ -716,6 +716,9 @@ func generateChallengeKey() (string, error) {
return base64.StdEncoding.EncodeToString(p), nil 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 { type websocketConn struct {
conn *websocket.Conn conn *websocket.Conn
rb []byte rb []byte
......
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