mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-16 04:56:36 +00:00
p2p: add I/O timeout for encrytion handshake
This commit is contained in:
parent
22ee366ed6
commit
7101f44998
1 changed files with 3 additions and 1 deletions
|
|
@ -17,6 +17,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
handshakeTimeout = 5 * time.Second
|
||||||
defaultDialTimeout = 10 * time.Second
|
defaultDialTimeout = 10 * time.Second
|
||||||
refreshPeersInterval = 30 * time.Second
|
refreshPeersInterval = 30 * time.Second
|
||||||
)
|
)
|
||||||
|
|
@ -344,7 +345,8 @@ func (srv *Server) findPeers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) startPeer(conn net.Conn, dest *discover.Node) {
|
func (srv *Server) startPeer(conn net.Conn, dest *discover.Node) {
|
||||||
// TODO: I/O timeout, handle/store session token
|
// TODO: handle/store session token
|
||||||
|
conn.SetDeadline(time.Now().Add(handshakeTimeout))
|
||||||
remoteID, _, err := srv.handshakeFunc(conn, srv.PrivateKey, dest)
|
remoteID, _, err := srv.handshakeFunc(conn, srv.PrivateKey, dest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue