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
dms3
go-dms3
Commits
76f3395e
Commit
76f3395e
authored
Dec 01, 2020
by
Adin Schmahmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p-proxy: earlier peerID validation check
parent
a329e4fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
core/corehttp/p2p_proxy.go
core/corehttp/p2p_proxy.go
+5
-0
test/sharness/t0184-http-proxy-over-p2p.sh
test/sharness/t0184-http-proxy-over-p2p.sh
+6
-1
No files found.
core/corehttp/p2p_proxy.go
View file @
76f3395e
...
...
@@ -9,6 +9,7 @@ import (
"strings"
core
"github.com/ipfs/go-ipfs/core"
peer
"github.com/libp2p/go-libp2p-core/peer"
protocol
"github.com/libp2p/go-libp2p-core/protocol"
p2phttp
"github.com/libp2p/go-libp2p-http"
...
...
@@ -60,6 +61,10 @@ func parseRequest(request *http.Request) (*proxyRequest, error) {
return
nil
,
fmt
.
Errorf
(
"Invalid request path '%s'"
,
path
)
}
if
_
,
err
:=
peer
.
Decode
(
split
[
2
]);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Invalid request path '%s'"
,
path
)
}
if
split
[
3
]
==
"http"
{
return
&
proxyRequest
{
split
[
2
],
protocol
.
ID
(
"/http"
),
split
[
4
]},
nil
}
...
...
test/sharness/t0184-http-proxy-over-p2p.sh
View file @
76f3395e
...
...
@@ -194,7 +194,12 @@ test_expect_success 'handle proxy http request invalid request' '
'
test_expect_success
'handle proxy http request unknown proxy peer '
'
curl_check_response_code 502 p2p/unknown_peer/http/index.txt
UNKNOWN_PEER="k51qzi5uqu5dlmbel1sd8rs4emr3bfosk9bm4eb42514r4lakt4oxw3a3fa2tm" &&
curl_check_response_code 502 p2p/$UNKNOWN_PEER/http/index.txt
'
test_expect_success
'handle proxy http request to invalid proxy peer '
'
curl_check_response_code 400 p2p/invalid_peer/http/index.txt
'
test_expect_success
'handle proxy http request to custom protocol'
'
...
...
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