mirror of
https://github.com/libp2p/go-libp2p.git
synced 2025-09-26 20:21:26 +08:00
pnet: wrap underlying error when reading nonce fails (#2975)
This commit is contained in:
@@ -3,6 +3,7 @@ package pnet
|
||||
import (
|
||||
"crypto/cipher"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
|
||||
@@ -33,7 +34,7 @@ func (c *pskConn) Read(out []byte) (int, error) {
|
||||
nonce := make([]byte, 24)
|
||||
_, err := io.ReadFull(c.Conn, nonce)
|
||||
if err != nil {
|
||||
return 0, errShortNonce
|
||||
return 0, fmt.Errorf("%w: %w", errShortNonce, err)
|
||||
}
|
||||
c.readS20 = salsa20.New(c.psk, nonce)
|
||||
}
|
||||
|
Reference in New Issue
Block a user