aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/server.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-02-13 21:49:49 +0800
committerFelix Lange <fjl@twurst.com>2015-02-13 22:06:47 +0800
commit7101f4499873fbf6a68cbe08a45797ff8ec71e74 (patch)
tree580a6919e225096c5038f366352d5bf8b059509b /p2p/server.go
parent22ee366ed6419516eece4436c9f7b5b63ea8a713 (diff)
downloadgo-tangerine-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar
go-tangerine-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.gz
go-tangerine-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.bz2
go-tangerine-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.lz
go-tangerine-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.xz
go-tangerine-7101f4499873fbf6a68cbe08a45797ff8ec71e74.tar.zst
go-tangerine-7101f4499873fbf6a68cbe08a45797ff8ec71e74.zip
p2p: add I/O timeout for encrytion handshake
Diffstat (limited to 'p2p/server.go')
-rw-r--r--p2p/server.go4
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()