"crypto/rand"
"crypto/subtle"
"encoding/binary"
+ "io"
"log"
"time"
type Handshake struct {
addr string
- conn RemoteConn
+ conn io.Writer
LastPing time.Time
Conf *PeerConf
dsaPubH *[ed25519.PublicKeySize]byte
}
// Create new handshake state.
-func HandshakeNew(addr string, conn RemoteConn, conf *PeerConf) *Handshake {
+func NewHandshake(addr string, conn io.Writer, conf *PeerConf) *Handshake {
state := Handshake{
addr: addr,
conn: conn,
// Start handshake's procedure from the client. It is the entry point
// for starting the handshake procedure. // First handshake packet
// will be sent immediately.
-func HandshakeStart(addr string, conn RemoteConn, conf *PeerConf) *Handshake {
- state := HandshakeNew(addr, conn, conf)
+func HandshakeStart(addr string, conn io.Writer, conf *PeerConf) *Handshake {
+ state := NewHandshake(addr, conn, conf)
var dhPubRepr *[32]byte
state.dhPriv, dhPubRepr = dhKeypairGen()