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-tls
Commits
35034eda
Commit
35034eda
authored
Feb 28, 2019
by
Marten Seemann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix duplicate import
parent
2e8087cb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
+13
-14
conn.go
conn.go
+5
-5
transport.go
transport.go
+2
-3
transport_test.go
transport_test.go
+6
-6
No files found.
conn.go
View file @
35034eda
...
...
@@ -4,7 +4,7 @@ import (
"crypto/tls"
cs
"github.com/libp2p/go-conn-security"
i
c
"github.com/libp2p/go-libp2p-crypto"
c
i
"github.com/libp2p/go-libp2p-crypto"
peer
"github.com/libp2p/go-libp2p-peer"
)
...
...
@@ -12,10 +12,10 @@ type conn struct {
*
tls
.
Conn
localPeer
peer
.
ID
privKey
i
c
.
PrivKey
privKey
c
i
.
PrivKey
remotePeer
peer
.
ID
remotePubKey
i
c
.
PubKey
remotePubKey
c
i
.
PubKey
}
var
_
cs
.
Conn
=
&
conn
{}
...
...
@@ -24,7 +24,7 @@ func (c *conn) LocalPeer() peer.ID {
return
c
.
localPeer
}
func
(
c
*
conn
)
LocalPrivateKey
()
i
c
.
PrivKey
{
func
(
c
*
conn
)
LocalPrivateKey
()
c
i
.
PrivKey
{
return
c
.
privKey
}
...
...
@@ -32,6 +32,6 @@ func (c *conn) RemotePeer() peer.ID {
return
c
.
remotePeer
}
func
(
c
*
conn
)
RemotePublicKey
()
i
c
.
PubKey
{
func
(
c
*
conn
)
RemotePublicKey
()
c
i
.
PubKey
{
return
c
.
remotePubKey
}
transport.go
View file @
35034eda
...
...
@@ -9,7 +9,6 @@ import (
cs
"github.com/libp2p/go-conn-security"
ci
"github.com/libp2p/go-libp2p-crypto"
ic
"github.com/libp2p/go-libp2p-crypto"
peer
"github.com/libp2p/go-libp2p-peer"
)
...
...
@@ -101,7 +100,7 @@ func (t *Transport) handshake(
}
// Should be ready by this point, don't block.
var
remotePubKey
i
c
.
PubKey
var
remotePubKey
c
i
.
PubKey
select
{
case
remotePubKey
=
<-
keyCh
:
default
:
...
...
@@ -118,7 +117,7 @@ func (t *Transport) handshake(
return
conn
,
nil
}
func
(
t
*
Transport
)
setupConn
(
tlsConn
*
tls
.
Conn
,
remotePubKey
i
c
.
PubKey
)
(
cs
.
Conn
,
error
)
{
func
(
t
*
Transport
)
setupConn
(
tlsConn
*
tls
.
Conn
,
remotePubKey
c
i
.
PubKey
)
(
cs
.
Conn
,
error
)
{
if
remotePubKey
==
nil
{
return
nil
,
errors
.
New
(
"go-libp2p-tls BUG: expected remote pub key to be set"
)
}
...
...
transport_test.go
View file @
35034eda
...
...
@@ -17,7 +17,7 @@ import (
"github.com/onsi/gomega/gbytes"
cs
"github.com/libp2p/go-conn-security"
i
c
"github.com/libp2p/go-libp2p-crypto"
c
i
"github.com/libp2p/go-libp2p-crypto"
peer
"github.com/libp2p/go-libp2p-peer"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
...
...
@@ -31,21 +31,21 @@ type transform struct {
var
_
=
Describe
(
"Transport"
,
func
()
{
var
(
serverKey
,
clientKey
i
c
.
PrivKey
serverKey
,
clientKey
c
i
.
PrivKey
serverID
,
clientID
peer
.
ID
)
createPeer
:=
func
()
(
peer
.
ID
,
i
c
.
PrivKey
)
{
var
priv
i
c
.
PrivKey
createPeer
:=
func
()
(
peer
.
ID
,
c
i
.
PrivKey
)
{
var
priv
c
i
.
PrivKey
if
mrand
.
Int
()
%
2
==
0
{
fmt
.
Fprintf
(
GinkgoWriter
,
" using an ECDSA key: "
)
var
err
error
priv
,
_
,
err
=
i
c
.
GenerateECDSAKeyPair
(
rand
.
Reader
)
priv
,
_
,
err
=
c
i
.
GenerateECDSAKeyPair
(
rand
.
Reader
)
Expect
(
err
)
.
ToNot
(
HaveOccurred
())
}
else
{
fmt
.
Fprintf
(
GinkgoWriter
,
" using an RSA key: "
)
var
err
error
priv
,
_
,
err
=
i
c
.
GenerateRSAKeyPair
(
1024
,
rand
.
Reader
)
priv
,
_
,
err
=
c
i
.
GenerateRSAKeyPair
(
1024
,
rand
.
Reader
)
Expect
(
err
)
.
ToNot
(
HaveOccurred
())
}
id
,
err
:=
peer
.
IDFromPrivateKey
(
priv
)
...
...
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