Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixed Ping (minor) #104

Merged
merged 2 commits into from
Sep 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions crypto/spipe/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ func (s *SecurePipe) handshake() error {
return err
}

// u.POut("sending encoded handshake\n")
s.insecure.Out <- encoded
// Send our Propose packet
select {
case s.insecure.Out <- encoded:
case <-s.ctx.Done():
return ErrClosed
}

// Parse their Propose packet and generate an Exchange packet.
// Exchange = (EphemeralPubKey, Signature)
Expand Down Expand Up @@ -137,7 +141,12 @@ func (s *SecurePipe) handshake() error {

exEncoded, err := proto.Marshal(exPacket)

s.insecure.Out <- exEncoded
// send out Exchange packet
select {
case s.insecure.Out <- exEncoded:
case <-s.ctx.Done():
return ErrClosed
}

// Parse their Exchange packet and generate a Finish packet.
// Finish = E('Finish')
Expand Down Expand Up @@ -182,7 +191,14 @@ func (s *SecurePipe) handshake() error {

finished := []byte("Finished")

s.Out <- finished
// send finished msg
select {
case <-s.ctx.Done():
return ErrClosed
case s.Out <- finished:
}

// recv finished msg
var resp2 []byte
select {
case <-s.ctx.Done():
Expand All @@ -194,7 +210,7 @@ func (s *SecurePipe) handshake() error {
return errors.New("Negotiation failed.")
}

u.DOut("[%s] identify: Got node id: %s\n", s.local.ID.Pretty(), s.remote.ID.Pretty())
u.DOut("[%s] handshake: Got node id: %s\n", s.local.ID.Pretty(), s.remote.ID.Pretty())
return nil
}

Expand Down
3 changes: 1 addition & 2 deletions routing/dht/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ func (dht *IpfsDHT) handlePutValue(p *peer.Peer, pmes *Message) (*Message, error

func (dht *IpfsDHT) handlePing(p *peer.Peer, pmes *Message) (*Message, error) {
u.DOut("[%s] Responding to ping from [%s]!\n", dht.self.ID.Pretty(), p.ID.Pretty())

return newMessage(pmes.GetType(), "", int(pmes.GetClusterLevel())), nil
return pmes, nil
}

func (dht *IpfsDHT) handleFindPeer(p *peer.Peer, pmes *Message) (*Message, error) {
Expand Down