Add a fiber-based relay manager#44
Merged
jheysel-r7 merged 7 commits intorapid7:masterfrom Dec 2, 2025
Merged
Conversation
Contributor
Author
|
Drafted as I still need to:
|
d1d297c to
eb7814a
Compare
11 tasks
65d936d to
e708dde
Compare
adfoster-r7
reviewed
Nov 6, 2025
baa30bb to
2221bd5
Compare
d14e6e5 to
dce52a0
Compare
jheysel-r7
approved these changes
Dec 2, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds a fiber-based relay manager and updates the socket abstraction code to use it. From my local and informal testing it propagates events slightly faster. This model though does allow a stream object that needs to relay from more than one source to both use the new
#monitor_sockmethod and do so without creating a thread for each new monitored socket. In the very near future, this will be used by theMsTds::Channelto relay to and from the IO abstraction that handles the TDS framing for SSL necessary to address rapid7/metasploit-framework#18745. I believe we may also be able to use it for services such as the SOCKS proxy to delagate relaying between sockets to the fiber instead of opening a thread per connection. This would offer a performance benefit when many connections are opened and established.Testing will be the easiest with a pending Metasploit Framework PR which will include the MsTds::Channel object and steps to ensure Meterpreter channels continue to work as necessary. The new close methods for local/remote were necessary to provide hinting to eliminate a deadlock in Meterpreter that would occur when socket was closed from the remote side (the Meterpreter instance sent a close command to Metasploit Framework) and Metasploit would attempt to close it again by sending a frame back to Meterpreter. This isn't necessary because of course Meterpreter already closed it and caused a dead lock where the Meterpreter instance would be unresponsive for about 15 seconds while the request timed out before it'd work just fine again. Now when the local or remote side wants to close the connection, the appropriate methods can be used to only alert the necessary parties on the other side of the relay.
Requires Ruby 3.0+ where non-blocking fibers were added.