Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-secio
Commits
60cfa732
Commit
60cfa732
authored
Jun 06, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid holding the message writer longer than necessary
We only need it for the handshake.
parent
3175340d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
protocol.go
protocol.go
+6
-7
No files found.
protocol.go
View file @
60cfa732
...
...
@@ -50,8 +50,7 @@ const nonceSize = 16
type
secureSession
struct
{
msgio
.
ReadWriteCloser
insecure
net
.
Conn
insecureM
msgio
.
ReadWriter
insecure
net
.
Conn
localKey
ci
.
PrivKey
localPeer
peer
.
ID
...
...
@@ -88,7 +87,6 @@ func newSecureSession(ctx context.Context, local peer.ID, key ci.PrivKey, insecu
}
s
.
insecure
=
insecure
s
.
insecureM
=
msgio
.
NewReadWriter
(
insecure
)
s
.
remotePeer
=
remotePeer
handshakeCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
HandshakeTimeout
)
// remove
...
...
@@ -135,6 +133,7 @@ func (s *secureSession) runHandshake(ctx context.Context) error {
}
func
(
s
*
secureSession
)
runHandshakeSync
()
error
{
insecureM
:=
msgio
.
NewReadWriter
(
s
.
insecure
)
// =============================================================================
// step 1. Propose -- propose cipher suite + send pubkeys + nonce
...
...
@@ -169,11 +168,11 @@ func (s *secureSession) runHandshakeSync() error {
}
// Send Propose packet and Receive their Propose packet
proposeInBytes
,
err
:=
readWriteMsg
(
s
.
insecureM
,
proposeOutBytes
)
proposeInBytes
,
err
:=
readWriteMsg
(
insecureM
,
proposeOutBytes
)
if
err
!=
nil
{
return
err
}
defer
s
.
insecureM
.
ReleaseMsg
(
proposeInBytes
)
defer
insecureM
.
ReleaseMsg
(
proposeInBytes
)
// Parse their propose packet
proposeIn
:=
new
(
pb
.
Propose
)
...
...
@@ -280,11 +279,11 @@ func (s *secureSession) runHandshakeSync() error {
}
// Send Exchange packet and receive their Exchange packet
exchangeInBytes
,
err
:=
readWriteMsg
(
s
.
insecureM
,
exchangeOutBytes
)
exchangeInBytes
,
err
:=
readWriteMsg
(
insecureM
,
exchangeOutBytes
)
if
err
!=
nil
{
return
err
}
defer
s
.
insecureM
.
ReleaseMsg
(
exchangeInBytes
)
defer
insecureM
.
ReleaseMsg
(
exchangeInBytes
)
// Parse their Exchange packet.
exchangeIn
:=
new
(
pb
.
Exchange
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment