Add AsyncIO Support for DCC Connection Handling#239
Open
smeinecke wants to merge 5 commits into
Open
Conversation
added 2 commits
February 15, 2025 16:31
- Add DCCProtocol class - Add AIODCCConnection class - Add dcc_connection_class in AIO Reactor TODO: implement listen/passive DCC
- Fix typo: rector -> reactor - Use LineBuffer instead of DecodingLineBuffer for bytes compatibility - Catch connection errors and re-raise as DCCConnectionError - Guard disconnect() against missing transport - Guard send_bytes() against unconnected state and rename bytes parameter - Add AioSimpleIRCClient dcc_connect/dcc_listen overrides for async methods - Add comprehensive tests for AioDCCConnection connect, disconnect, send_bytes, process_data, and error handling
- Add DCCProtocol.connection_made() to handle passive DCC connections - Implement AioDCCConnection.listen() with configurable port/range * Supports single port int, (min,max) tuple range, or list of ports * Supports ipv6=True parameter * Tries each port until one binds, raises DCCConnectionError on failure - Update AioDCCConnection.disconnect() to close listening server - Remove NotImplementedError placeholders from process_data() - Add tests for listen, ipv6, specific port, port range, port list, range fallback, connection_made, and disconnect cleanup - Add example scripts dccsend-aio.py (passive) and dccreceive-aio.py (active)
- Remove "DCC chat has not yet been implemented" limitation from client_aio docstring - Add explicit `privmsg` method to `AioDCCConnection` for DCC CHAT sessions - Add tests for DCC chat and raw privmsg behavior - Add dccchat-aio.py example script
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.
While developing with this library, I noticed that DCC connections are not managed using the asyncio library, which causes issues with DCC handling when using the asynchronous (AIO) version of the library.
This pull request introduces the following changes:
Core asyncio DCC support:
DCCProtocolclass for asyncio-based DCC connectionsAioDCCConnectionclass with full async connect/listen/disconnect lifecycledcc_connection_classin the AIO ReactorAIODCCConnection→AioDCCConnectionfor consistencyPassive DCC listen with port configurability:
AioDCCConnection.listen()usingasyncio.create_server()int,(min, max)tuple range, or list of ports to tryipv6=TrueparameterDCCConnectionErrorif all failDCCProtocol.connection_made()handles passive accept, captures peer info, firesdcc_connectevent, and closes the listening server after a single connectiondisconnect()properly cleans up both the server and transportDCC CHAT support:
privmsg()method toAioDCCConnectionfor DCC CHAT sessions (auto-newline for chat, raw for other types)Example scripts:
scripts/dccsend-aio.py— passive DCC file sender usinglisten()with port range fallbackscripts/dccreceive-aio.py— active DCC file receiver usingconnect()scripts/dccchat-aio.py— asyncio DCC chat exampleTests: