// Dial generates a private/public key pair,
// connects to the server, perform the handshake
// and return a reader/writer.
Dial generates a private/public key pair,
connects to the server, perform the handshake
and return a reader/writer.
// Dial generates a private / public key pair // connects to the server perform the handshake // and return a reader / writer .
func Dial(addr string) (io.ReadWriteCloser, error) {
	kp, err := generateKeyPair()
	if err != nil {
		return nil, err
	}
	conn, err := net.Dial("tcp", addr)
	if err != nil {
		return nil, err
	}
	hs := &handshake{
		localPublicKey: *kp.public,
	}
	err = negotiate(conn, hs)
	if err != nil {
		return nil, err
	}
	return &secureReadWriteCloser{
		NewSecureReader(conn, kp.private, &hs.remotePublicKey),
		NewSecureWriter(conn, kp.private, &hs.remotePublicKey),
	}, nil
}
func Dial ( addr string ) ( io . ReadWriteCloser , error ) { kp , err := generateKeyPair ( ) if err != nil { return nil , err } conn , err := net . Dial ( " " , addr ) if err != nil { return nil , err } hs := & handshake { localPublicKey : * kp . public , } err = negotiate ( conn , hs ) if err != nil { return nil , err } return & secureReadWriteCloser { NewSecureReader ( conn , kp . private , & hs . remotePublicKey ) , NewSecureWriter ( conn , kp . private , & hs . remotePublicKey ) , } , nil }
Dial generates a private/public key pair,
connects to the server, perform the handshake
and return a reader/writer.
Dial generates a private / public key pair connects to the server perform the handshake and return a reader / writer .
// generate a private/public key pair // connect to the server // perform the handshake // return a reader/writer