diff --git a/brontide/conn.go b/brontide/conn.go index f28591738..cee04f4ca 100644 --- a/brontide/conn.go +++ b/brontide/conn.go @@ -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 diff --git a/brontide/listener.go b/brontide/listener.go index 603a6b1a8..4f6ee70f4 100644 --- a/brontide/listener.go +++ b/brontide/listener.go @@ -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 diff --git a/brontide/noise.go b/brontide/noise.go index 2bc309698..a1d857459 100644 --- a/brontide/noise.go +++ b/brontide/noise.go @@ -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 (