brontide: decrease handshake timeout to 1s
This commit is contained in:
parent
138da98df6
commit
d82f67cc1d
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user