Skip to content
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

IRC: Add option for SASL authentication. #793

Merged
merged 1 commit into from
Nov 15, 2023
Merged

IRC: Add option for SASL authentication. #793

merged 1 commit into from
Nov 15, 2023

Conversation

rht
Copy link
Contributor

@rht rht commented Oct 1, 2023

This reverts to using sync IRC client, because upstream https://github.com/jaraco/irc only supports it for the sync client.

@rht
Copy link
Contributor Author

rht commented Oct 1, 2023

cc: @asdf8dfafjk

@rht rht changed the title IRC: Update to use always SASL authentication. IRC: Update to always always SASL authentication. Oct 1, 2023
@rht rht changed the title IRC: Update to always always SASL authentication. IRC: Update to always use SASL authentication. Oct 1, 2023
@zulipbot zulipbot added size: M and removed size: S labels Oct 1, 2023
@timabbott
Copy link
Sponsor Member

Looks good, but looks like it has a merge conflict. @andersk feel free to rebase and merge if it helps you upgrade dependencies.

@rht
Copy link
Contributor Author

rht commented Nov 10, 2023

Rebased.

@andersk
Copy link
Member

andersk commented Nov 12, 2023

What’s the motivation here? Adding SASL support sounds good, but dropping non-SASL support sounds limiting?

@rht
Copy link
Contributor Author

rht commented Nov 12, 2023

I will add back the PLAIN authentication, so as not to restrict user's choice.

@rht rht force-pushed the irc-fix branch 2 times, most recently from 3d5958c to f1c095a Compare November 13, 2023 14:12
@rht
Copy link
Contributor Author

rht commented Nov 13, 2023

Rebased and the SASL authentication is now optional.

@rht rht changed the title IRC: Update to always use SASL authentication. IRC: Add option for SASL authentication. Nov 13, 2023

logging.basicConfig(level=logging.DEBUG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a temporary debugging measure that should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the log when I didn't specify the SASL password to Libera.Chat. This message wouldn't show up unless I set the level to logging.DEBUG.

DEBUG:irc.client:FROM SERVER: :sodium.libera.chat NOTICE zz_zulip :*** Notice -- SASL authentication to a NickServ account wi
th a verified email address is required to connect from your current network. Please see https://libera.chat/guides/sasl for
configuration assistance.
...
DEBUG:irc.client:FROM SERVER: ERROR :Closing Link: rein.zulipdev.org (SASL authentication to a NickServ account with a verifi
ed email address is required to connect from your current network. Please see https://libera.chat/guides/sasl for configurati
on assistance.)

Copy link
Member

@andersk andersk Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that’d be a side effect of logging all data sent from the server.

Instead, add an on_error handler to IRCBot.

    def on_error(self, connection: ServerConnection, event: Event) -> None:
        logging.error("error from server: %s", event.target)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added on_error that raises Exception for all errors. I'm not sure why there is no default on_error on the IRCBot that reports the errors.

Currently testing by running the bridge for some period of time, to see that there are errors that are recoverable.

@@ -1 +1 @@
irc==18.0
irc==20.3.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be >= 20.3.0 or ~= 20.3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to ~=20.3.

@rht rht force-pushed the irc-fix branch 5 times, most recently from 800a27c to fba82f5 Compare November 14, 2023 13:09
@@ -144,3 +144,6 @@ def on_dccchat(self, c: ServerConnection, e: Event) -> None:
except ValueError:
return
self.dcc_connect(address, port)

def on_error(self, c: ServerConnection, e: Event) -> None:
raise IRCError(e.target)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don’t steal someone else’s exception class like this. It’s intended to be raised by the library, so its constructor interface belongs to the library and could change at the library’s discretion. For example, its constructor could gain more required arguments, like the corresponding irc.server.IRCError already has.

This additionally reverts to using sync IRC client, because upstream
https://github.com/jaraco/irc only supports it for the sync client.
@andersk andersk merged commit 2814acc into zulip:main Nov 15, 2023
13 checks passed
@andersk
Copy link
Member

andersk commented Nov 15, 2023

Merged without the error handling change since that needs more work and should arguably be separate anyway. Feel free to open a new PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants