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-ws-transport
Commits
8cb6edcf
Commit
8cb6edcf
authored
Apr 02, 2020
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: restrict dials to IP + TCP
That is, forbid DNS. See
https://github.com/libp2p/go-libp2p/issues/841
parent
ef8a962d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
websocket.go
websocket.go
+6
-2
No files found.
websocket.go
View file @
8cb6edcf
...
...
@@ -18,7 +18,7 @@ import (
var
WsProtocol
=
ma
.
ProtocolWithCode
(
ma
.
P_WS
)
// WsFmt is multiaddr formatter for WsProtocol
var
WsFmt
=
mafmt
.
And
(
mafmt
.
TCP
,
mafmt
.
Base
(
WsProtocol
.
Code
))
var
WsFmt
=
mafmt
.
And
(
mafmt
.
TCP
,
mafmt
.
Base
(
ma
.
P_WS
))
// WsCodec is the multiaddr-net codec definition for the websocket transport
var
WsCodec
=
&
manet
.
NetCodec
{
...
...
@@ -28,6 +28,10 @@ var WsCodec = &manet.NetCodec{
ParseNetAddr
:
ParseWebsocketNetAddr
,
}
// This is _not_ WsFmt because we want the transport to stick to dialing fully
// resolved addresses.
var
dialMatcher
=
mafmt
.
And
(
mafmt
.
IP
,
mafmt
.
Base
(
ma
.
P_TCP
),
mafmt
.
Base
(
ma
.
P_WS
))
func
init
()
{
manet
.
RegisterNetCodec
(
WsCodec
)
}
...
...
@@ -44,7 +48,7 @@ func New(u *tptu.Upgrader) *WebsocketTransport {
}
func
(
t
*
WebsocketTransport
)
CanDial
(
a
ma
.
Multiaddr
)
bool
{
return
WsFmt
.
Matches
(
a
)
return
dialMatcher
.
Matches
(
a
)
}
func
(
t
*
WebsocketTransport
)
Protocols
()
[]
int
{
...
...
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