diff options
author | Felix Lange <fjl@twurst.com> | 2015-02-13 21:49:49 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-02-13 22:06:47 +0800 |
commit | 7101f4499873fbf6a68cbe08a45797ff8ec71e74 (patch) | |
tree | 580a6919e225096c5038f366352d5bf8b059509b /p2p | |
parent | 22ee366ed6419516eece4436c9f7b5b63ea8a713 (diff) | |
download | dexon-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar dexon-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.gz dexon-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.bz2 dexon-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.lz dexon-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.xz dexon-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.zst dexon-7101f4499873fbf6a68cbe08a45797ff8ec71e74.zip |
p2p: add I/O timeout for encrytion handshake
Diffstat (limited to 'p2p')
-rw-r--r-- | p2p/server.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/p2p/server.go b/p2p/server.go index f61bb897e..b93340150 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -17,6 +17,7 @@ import ( ) const ( + handshakeTimeout = 5 * time.Second defaultDialTimeout = 10 * time.Second refreshPeersInterval = 30 * time.Second ) @@ -344,7 +345,8 @@ func (srv *Server) findPeers() { } 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) if err != nil { conn.Close() |