identify.go 559 Bytes
Newer Older
1 2 3 4 5 6
// The identify package handles how peers identify with eachother upon
// connection to the network
package identify

import (
	peer "github.com/jbenet/go-ipfs/peer"
7
	u "github.com/jbenet/go-ipfs/util"
8 9 10 11
)

// Perform initial communication with this peer to share node ID's and
// initiate communication
12
func Handshake(self, remote *peer.Peer, in, out chan []byte) error {
Jeromy's avatar
Jeromy committed
13
	// TODO: make this more... secure.
14 15 16
	out <- self.ID
	resp := <-in
	remote.ID = peer.ID(resp)
17
	u.DOut("[%s] identify: Got node id: %s", self.ID.Pretty(), remote.ID.Pretty())
18 19 20

	return nil
}