Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
319266a5
Unverified
Commit
319266a5
authored
Feb 14, 2020
by
Janoš Guljaš
Committed by
GitHub
Feb 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use only libp2p default security to avoid websockets data race (#19)
parent
0244bad5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
26 deletions
+19
-26
go.mod
go.mod
+2
-2
go.sum
go.sum
+1
-0
libp2p.go
pkg/p2p/libp2p/libp2p.go
+16
-17
libp2p_test.go
pkg/p2p/libp2p/libp2p_test.go
+0
-7
No files found.
go.mod
View file @
319266a5
...
...
@@ -13,8 +13,8 @@ require (
github.com/libp2p/go-libp2p-core v0.3.0
github.com/libp2p/go-libp2p-peerstore v0.1.4
github.com/libp2p/go-libp2p-quic-transport v0.2.2
github.com/libp2p/go-
libp2p-secio v0.2
.1
github.com/libp2p/go-
libp2p-tls v0.1.3
github.com/libp2p/go-
tcp-transport v0.1
.1
github.com/libp2p/go-
ws-transport v0.2.0
github.com/multiformats/go-multiaddr v0.2.0
github.com/multiformats/go-multistream v0.1.0
github.com/prometheus/client_golang v1.3.0
...
...
go.sum
View file @
319266a5
...
...
@@ -250,6 +250,7 @@ github.com/libp2p/go-libp2p-testing v0.0.4/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MB
github.com/libp2p/go-libp2p-testing v0.1.0/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-testing v0.1.1 h1:U03z3HnGI7Ni8Xx6ONVZvUFOAzWYmolWf5W5jAOPNmU=
github.com/libp2p/go-libp2p-testing v0.1.1/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-tls v0.1.1 h1:tjW7njTM8JX8FbEvqr8/VSKBdZYZ7CtGtv3i6NiFf10=
github.com/libp2p/go-libp2p-tls v0.1.1/go.mod h1:wZfuewxOndz5RTnCAxFliGjvYSDA40sKitV4c50uI1M=
github.com/libp2p/go-libp2p-tls v0.1.3 h1:twKMhMu44jQO+HgQK9X8NHO5HkeJu2QbhLzLJpa8oNM=
github.com/libp2p/go-libp2p-tls v0.1.3/go.mod h1:wZfuewxOndz5RTnCAxFliGjvYSDA40sKitV4c50uI1M=
...
...
pkg/p2p/libp2p/libp2p.go
View file @
319266a5
...
...
@@ -28,8 +28,8 @@ import (
protocol
"github.com/libp2p/go-libp2p-core/protocol"
"github.com/libp2p/go-libp2p-peerstore/pstoremem"
libp2pquic
"github.com/libp2p/go-libp2p-quic-transport"
secio
"github.com/libp2p/go-libp2p-secio
"
libp2ptls
"github.com/libp2p/go-libp2p-tls
"
"github.com/libp2p/go-tcp-transport
"
ws
"github.com/libp2p/go-ws-transport
"
ma
"github.com/multiformats/go-multiaddr"
"github.com/multiformats/go-multistream"
)
...
...
@@ -102,17 +102,12 @@ func New(ctx context.Context, o Options) (*Service, error) {
}
}
security
:=
libp2p
.
DefaultSecurity
libp2pPeerstore
:=
pstoremem
.
NewPeerstore
()
opts
:=
[]
libp2p
.
Option
{
// Multiple listen addresses
libp2p
.
ListenAddrStrings
(
listenAddrs
...
),
// support TLS connections
libp2p
.
Security
(
libp2ptls
.
ID
,
libp2ptls
.
New
),
// support secio connections
libp2p
.
Security
(
secio
.
ID
,
secio
.
New
),
// support any other default transports (TCP)
libp2p
.
DefaultTransports
,
security
,
// Attempt to open ports using uPNP for NATed hosts.
libp2p
.
NATPortMap
(),
// Use dedicated peerstore instead the global DefaultPeerstore
...
...
@@ -125,13 +120,20 @@ func New(ctx context.Context, o Options) (*Service, error) {
)
}
transports
:=
[]
libp2p
.
Option
{
libp2p
.
Transport
(
tcp
.
NewTCPTransport
),
}
if
!
o
.
DisableWS
{
transports
=
append
(
transports
,
libp2p
.
Transport
(
ws
.
New
))
}
if
!
o
.
DisableQUIC
{
opts
=
append
(
opts
,
// support QUIC - experimental
libp2p
.
Transport
(
libp2pquic
.
NewTransport
),
)
transports
=
append
(
transports
,
libp2p
.
Transport
(
libp2pquic
.
NewTransport
))
}
opts
=
append
(
opts
,
transports
...
)
h
,
err
:=
libp2p
.
New
(
ctx
,
opts
...
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -143,10 +145,7 @@ func New(ctx context.Context, o Options) (*Service, error) {
if
_
,
err
=
autonat
.
NewAutoNATService
(
ctx
,
h
,
// Support same non default security and transport options as
// original host.
libp2p
.
Security
(
libp2ptls
.
ID
,
libp2ptls
.
New
),
libp2p
.
Security
(
secio
.
ID
,
secio
.
New
),
libp2p
.
Transport
(
libp2pquic
.
NewTransport
),
libp2p
.
DefaultTransports
,
append
(
transports
,
security
)
...
,
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"autonat: %w"
,
err
)
}
...
...
pkg/p2p/libp2p/libp2p_test.go
View file @
319266a5
...
...
@@ -27,13 +27,6 @@ import (
func
newService
(
t
*
testing
.
T
,
o
libp2p
.
Options
)
(
s
*
libp2p
.
Service
,
overlay
swarm
.
Address
,
cleanup
func
())
{
t
.
Helper
()
// disable ws until the race condition in:
// github.com/gorilla/websocket@v1.4.1/conn.go:614
// github.com/gorilla/websocket@v1.4.1/conn.go:781
// using github.com/libp2p/go-libp2p-transport-upgrader@v0.1.1
// is solved
o
.
DisableWS
=
true
if
o
.
PrivateKey
==
nil
{
var
err
error
o
.
PrivateKey
,
err
=
crypto
.
GenerateSecp256k1Key
()
...
...
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