-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(tcpreuse): add options for sharing TCP listeners amongst TCP, WS and WSS transports #2984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
6281130
feat(tcpreuse): add options for sharing TCP listeners amongst TCP, WS…
aschmahmann 2ae20f4
add tests for listener
sukunrt 05ee445
create conn scope early to prevent DoS attacks
sukunrt 3457a7b
add fx option, move rcmgr and upgrader to sharedtcp
sukunrt ac8b478
make fewer concurrent connections in test, it breaks mac and windows
sukunrt 6d5fa53
add some comments
sukunrt 0115a62
Add OS specific sampledconn
MarcoPolo cdbf16c
Return net.Conn unwrapped if possible
MarcoPolo 7f4f875
feat(tcpreuse): add Windows sampledconn
aschmahmann 00c9403
Add test for metrics+unix
MarcoPolo 2c053d8
tcp transport: Parameterize metrics collector in TCP
MarcoPolo 7e34d05
simplify demultiplex a bit
MarcoPolo e465b29
transport-testsuite(old): Parameterize subtests
MarcoPolo 677222a
tcp-transport: selectively run only 1conn tests
MarcoPolo 8c334af
sampledconn: update tests to be manet aware
MarcoPolo b686b80
Remove unused interface
MarcoPolo a28a244
sampledconn: Add test case back in
MarcoPolo a39490f
Comment nits
MarcoPolo 76f560b
tcpreuse: flip reuseport bool
MarcoPolo c314a2a
tcpreuse: return an error on multiple listeners for the same addr+con…
MarcoPolo 56dabd4
websocket: return consistent error
MarcoPolo 9ebfc89
Remove todo
MarcoPolo a722a7c
tcp: revert parameterize metrics collector
MarcoPolo 85be1f5
typo
MarcoPolo 18af914
PR review
MarcoPolo f9f39b7
typo
MarcoPolo 9ca4ae7
add timeout
MarcoPolo 3d26583
pr nit
MarcoPolo 3487369
remove unused option
MarcoPolo 74e9c05
Expand comment
MarcoPolo fd53643
remove 0x160304 magic byte match
MarcoPolo ccd1609
Fix test to handle existing listener error
MarcoPolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// go:build: unix | ||
|
||
package tcp | ||
|
||
import ( | ||
"testing" | ||
|
||
tptu "github.com/libp2p/go-libp2p/p2p/net/upgrader" | ||
"github.com/libp2p/go-libp2p/p2p/transport/tcpreuse" | ||
ttransport "github.com/libp2p/go-libp2p/p2p/transport/testsuite" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestTcpTransportCollectsMetricsWithSharedTcpSocket(t *testing.T) { | ||
|
||
peerA, ia := makeInsecureMuxer(t) | ||
_, ib := makeInsecureMuxer(t) | ||
|
||
sharedTCPSocketA := tcpreuse.NewConnMgr(false, nil, nil) | ||
sharedTCPSocketB := tcpreuse.NewConnMgr(false, nil, nil) | ||
|
||
ua, err := tptu.New(ia, muxers, nil, nil, nil) | ||
require.NoError(t, err) | ||
ta, err := NewTCPTransport(ua, nil, sharedTCPSocketA, WithMetrics()) | ||
require.NoError(t, err) | ||
ub, err := tptu.New(ib, muxers, nil, nil, nil) | ||
require.NoError(t, err) | ||
tb, err := NewTCPTransport(ub, nil, sharedTCPSocketB, WithMetrics()) | ||
require.NoError(t, err) | ||
|
||
zero := "/ip4/127.0.0.1/tcp/0" | ||
|
||
// Not running any test that needs more than 1 conn because the testsuite | ||
// opens multiple conns via multiple listeners, which is not expected to work | ||
// with the shared TCP socket. | ||
subtestsToRun := []ttransport.TransportSubTestFn{ | ||
ttransport.SubtestProtocols, | ||
ttransport.SubtestBasic, | ||
ttransport.SubtestCancel, | ||
ttransport.SubtestPingPong, | ||
|
||
// Stolen from the stream muxer test suite. | ||
ttransport.SubtestStress1Conn1Stream1Msg, | ||
ttransport.SubtestStress1Conn1Stream100Msg, | ||
ttransport.SubtestStress1Conn100Stream100Msg, | ||
ttransport.SubtestStress1Conn1000Stream10Msg, | ||
ttransport.SubtestStress1Conn100Stream100Msg10MB, | ||
ttransport.SubtestStreamOpenStress, | ||
ttransport.SubtestStreamReset, | ||
} | ||
|
||
ttransport.SubtestTransportWithFs(t, ta, tb, zero, peerA, subtestsToRun) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.