Skip to content

Don't send CAP END before SASL auth is complete #47

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion asyncirc/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ async def _internal_cap_handler(conn: 'IrcProtocol', message: 'Message'):
if enabled:
handlers = filter(None, conn.cap_handlers[cap.name])
await asyncio.gather(*[func(conn, cap) for func in handlers])

if all(val[1] is not None for val in conn.server.caps.values()):
conn.send("CAP END")
# If SASL is enabled, SASL negotiation should be complete before sending CAP END,
# so this is done in the SASL handler.
if conn.sasl_mech == SASLMechanism.NONE:
conn.send("CAP END")

elif message.parameters[1] == 'LIST':
if conn.logger:
conn.logger.info("Current Capabilities: %s", caplist)
Expand Down Expand Up @@ -117,6 +122,11 @@ async def _do_sasl(conn: 'IrcProtocol', cap):
# TODO log SASL response
await conn.wait_for('902', '903', '904', '905', '906', '907', '908', timeout=30)

# Send CAP END here, because it shouldn't be sent before SASL auth is complete
# NOTE: there is a (probably unlikely) race condition here, if CAP negotiation is
# incomplete by this point.
conn.send("CAP END")


async def _isupport_handler(conn: 'IrcProtocol', message: 'Message'):
tokens = message.parameters[1:-1] # Remove the nick and trailing ':are supported by this server' message
Expand Down