|
@ -90,8 +90,8 @@ type PeerConfig struct { |
|
|
|
|
|
|
|
|
MConfig *tmconn.MConnConfig `mapstructure:"connection"` |
|
|
MConfig *tmconn.MConnConfig `mapstructure:"connection"` |
|
|
|
|
|
|
|
|
Fail bool `mapstructure:"fail"` // for testing
|
|
|
|
|
|
Fuzz bool `mapstructure:"fuzz"` // fuzz connection (for testing)
|
|
|
|
|
|
|
|
|
DialFail bool `mapstructure:"dial_fail"` // for testing
|
|
|
|
|
|
Fuzz bool `mapstructure:"fuzz"` // fuzz connection (for testing)
|
|
|
FuzzConfig *FuzzConnConfig `mapstructure:"fuzz_config"` |
|
|
FuzzConfig *FuzzConnConfig `mapstructure:"fuzz_config"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -102,7 +102,7 @@ func DefaultPeerConfig() *PeerConfig { |
|
|
HandshakeTimeout: 20, // * time.Second,
|
|
|
HandshakeTimeout: 20, // * time.Second,
|
|
|
DialTimeout: 3, // * time.Second,
|
|
|
DialTimeout: 3, // * time.Second,
|
|
|
MConfig: tmconn.DefaultMConnConfig(), |
|
|
MConfig: tmconn.DefaultMConnConfig(), |
|
|
Fail: false, |
|
|
|
|
|
|
|
|
DialFail: false, |
|
|
Fuzz: false, |
|
|
Fuzz: false, |
|
|
FuzzConfig: DefaultFuzzConnConfig(), |
|
|
FuzzConfig: DefaultFuzzConnConfig(), |
|
|
} |
|
|
} |
|
@ -339,7 +339,11 @@ func (p *peer) String() string { |
|
|
//------------------------------------------------------------------
|
|
|
//------------------------------------------------------------------
|
|
|
// helper funcs
|
|
|
// helper funcs
|
|
|
|
|
|
|
|
|
var dial = func(addr *NetAddress, config *PeerConfig) (net.Conn, error) { |
|
|
|
|
|
|
|
|
func dial(addr *NetAddress, config *PeerConfig) (net.Conn, error) { |
|
|
|
|
|
if config.DialFail { |
|
|
|
|
|
return nil, fmt.Errorf("dial err (peerConfig.DialFail == true)") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
conn, err := addr.DialTimeout(config.DialTimeout * time.Second) |
|
|
conn, err := addr.DialTimeout(config.DialTimeout * time.Second) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|