brontide: decrease handshake timeout to 1s

This commit is contained in:
Olaoluwa Osuntokun 2018-04-02 15:56:41 -07:00
parent 138da98df6
commit d82f67cc1d
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
3 changed files with 13 additions and 6 deletions

View File

@ -59,9 +59,9 @@ func Dial(localPriv *btcec.PrivateKey, netAddr *lnwire.NetAddress,
}
// We'll ensure that we get ActTwo from the remote peer in a timely
// manner. If they don't respond within 15 seconds, then we'll kill the
// manner. If they don't respond within 1s, then we'll kill the
// connection.
conn.SetReadDeadline(time.Now().Add(time.Second * 15))
conn.SetReadDeadline(time.Now().Add(handshakeReadTimeout))
// If the first act was successful (we know that address is actually
// remotePub), then read the second act after which we'll be able to

View File

@ -104,9 +104,9 @@ func (l *Listener) doHandshake(conn net.Conn) {
}
// We'll ensure that we get ActOne from the remote peer in a timely
// manner. If they don't respond within 15 seconds, then we'll kill the
// manner. If they don't respond within 1s, then we'll kill the
// connection.
conn.SetReadDeadline(time.Now().Add(time.Second * 15))
conn.SetReadDeadline(time.Now().Add(handshakeReadTimeout))
// Attempt to carry out the first act of the handshake protocol. If the
// connecting node doesn't know our long-term static public key, then
@ -144,9 +144,9 @@ func (l *Listener) doHandshake(conn net.Conn) {
}
// We'll ensure that we get ActTwo from the remote peer in a timely
// manner. If they don't respond within 15 seconds, then we'll kill the
// manner. If they don't respond within 1 second, then we'll kill the
// connection.
conn.SetReadDeadline(time.Now().Add(time.Second * 15))
conn.SetReadDeadline(time.Now().Add(handshakeReadTimeout))
// Finally, finish the handshake processes by reading and decrypting
// the connection peer's static public key. If this succeeds then both

View File

@ -8,6 +8,7 @@ import (
"fmt"
"io"
"math"
"time"
"golang.org/x/crypto/chacha20poly1305"
"golang.org/x/crypto/hkdf"
@ -33,6 +34,12 @@ const (
// keyRotationInterval is the number of messages sent on a single
// cipher stream before the keys are rotated forwards.
keyRotationInterval = 1000
// handshakeReadTimeout is a read timeout that will be enforced when
// waiting for data payloads during the various acts of Brontide. If
// the remote party fails to deliver the proper payload within this
// time frame, then we'll fail the connection.
handshakeReadTimeout = time.Second * 1
)
var (