Add post-connection SASL authentication (not used rn)
This commit is contained in:
parent
f8c3dd3b35
commit
2a65361c92
2 changed files with 28 additions and 11 deletions
10
irc.py
10
irc.py
|
@ -206,8 +206,9 @@ class PesterIRC(QtCore.QThread):
|
||||||
# This should not be here.
|
# This should not be here.
|
||||||
profile = self.mainwindow.profile()
|
profile = self.mainwindow.profile()
|
||||||
# Do SASL!!
|
# Do SASL!!
|
||||||
if self.mainwindow.userprofile.getAutoIdentify():
|
|
||||||
self._send_irc.cap("REQ", "sasl")
|
self._send_irc.cap("REQ", "sasl")
|
||||||
|
if self.mainwindow.userprofile.getAutoIdentify():
|
||||||
|
# Send plain, send end later when 903 or 904 is received.
|
||||||
self._send_irc.authenticate("PLAIN")
|
self._send_irc.authenticate("PLAIN")
|
||||||
else:
|
else:
|
||||||
# Without SASL, end caps here.
|
# Without SASL, end caps here.
|
||||||
|
@ -539,6 +540,11 @@ class PesterIRC(QtCore.QThread):
|
||||||
def send_nick(self, nick: str):
|
def send_nick(self, nick: str):
|
||||||
self._send_irc.nick(nick)
|
self._send_irc.nick(nick)
|
||||||
|
|
||||||
|
@QtCore.pyqtSlot(str)
|
||||||
|
def send_authenticate(self, msg):
|
||||||
|
"""Called from main thread via signal, send requirements."""
|
||||||
|
self._send_irc.authenticate(msg)
|
||||||
|
|
||||||
def _notice(self, nick, chan, msg):
|
def _notice(self, nick, chan, msg):
|
||||||
"""Standard IRC 'NOTICE' message, primarily used for automated replies from services."""
|
"""Standard IRC 'NOTICE' message, primarily used for automated replies from services."""
|
||||||
handle = nick[0 : nick.find("!")]
|
handle = nick[0 : nick.find("!")]
|
||||||
|
@ -1042,10 +1048,12 @@ class PesterIRC(QtCore.QThread):
|
||||||
|
|
||||||
def _saslfail(self, *_msg):
|
def _saslfail(self, *_msg):
|
||||||
"""Handle 'RPL_SASLSUCCESS' reply from server, SASL authentication succeeded! woo yeah!!"""
|
"""Handle 'RPL_SASLSUCCESS' reply from server, SASL authentication succeeded! woo yeah!!"""
|
||||||
|
if not self.registered_irc:
|
||||||
self._send_irc.cap("END")
|
self._send_irc.cap("END")
|
||||||
|
|
||||||
def _saslsuccess(self, *_msg):
|
def _saslsuccess(self, *_msg):
|
||||||
"""Handle 'ERR_SASLFAIL' reply from server, SASL failed somehow."""
|
"""Handle 'ERR_SASLFAIL' reply from server, SASL failed somehow."""
|
||||||
|
if not self.registered_irc:
|
||||||
self._send_irc.cap("END")
|
self._send_irc.cap("END")
|
||||||
|
|
||||||
moodUpdated = QtCore.pyqtSignal(str, Mood)
|
moodUpdated = QtCore.pyqtSignal(str, Mood)
|
||||||
|
|
|
@ -2545,11 +2545,18 @@ class PesterWindow(MovingWindow):
|
||||||
self.waitingMessages.answerMessage()
|
self.waitingMessages.answerMessage()
|
||||||
|
|
||||||
def doAutoIdentify(self):
|
def doAutoIdentify(self):
|
||||||
pass
|
"""Identify to NickServ after we've already connected and are switching handle.
|
||||||
# if self.userprofile.getAutoIdentify():
|
|
||||||
# self.sendMessage.emit(
|
It'd be better to do this with only the AUTHENTICATE command even after connecting,
|
||||||
# "identify " + self.userprofile.getNickServPass(), "NickServ"
|
but UnrealIRCd doens't seem to support it yet? https://bugs.unrealircd.org/view.php?id=6084
|
||||||
# )
|
The protocol allows it though, so hopefully it'll be a thing in the future.
|
||||||
|
For now it's better to just msg too for backwards compatibility.
|
||||||
|
"""
|
||||||
|
if self.userprofile.getAutoIdentify():
|
||||||
|
# self.sendAuthenticate.emit("PLAIN")
|
||||||
|
self.sendMessage.emit(
|
||||||
|
f"identify {self.userprofile.getNickServPass()}", "NickServ"
|
||||||
|
)
|
||||||
|
|
||||||
def doAutoJoins(self):
|
def doAutoJoins(self):
|
||||||
if not self.autoJoinDone:
|
if not self.autoJoinDone:
|
||||||
|
@ -2563,7 +2570,6 @@ class PesterWindow(MovingWindow):
|
||||||
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
|
self.loadingscreen.done(QtWidgets.QDialog.DialogCode.Accepted)
|
||||||
self.loadingscreen = None
|
self.loadingscreen = None
|
||||||
|
|
||||||
self.doAutoIdentify()
|
|
||||||
self.doAutoJoins()
|
self.doAutoJoins()
|
||||||
|
|
||||||
# Start client --> server pings
|
# Start client --> server pings
|
||||||
|
@ -4245,6 +4251,7 @@ class PesterWindow(MovingWindow):
|
||||||
pingServer = QtCore.pyqtSignal()
|
pingServer = QtCore.pyqtSignal()
|
||||||
setAway = QtCore.pyqtSignal(bool)
|
setAway = QtCore.pyqtSignal(bool)
|
||||||
killSomeQuirks = QtCore.pyqtSignal(str, str)
|
killSomeQuirks = QtCore.pyqtSignal(str, str)
|
||||||
|
sendAuthenticate = QtCore.pyqtSignal(str)
|
||||||
|
|
||||||
|
|
||||||
class PesterTray(QtWidgets.QSystemTrayIcon):
|
class PesterTray(QtWidgets.QSystemTrayIcon):
|
||||||
|
@ -4403,8 +4410,9 @@ class MainProgram(QtCore.QObject):
|
||||||
self.widget.config.set("traymsg", False)
|
self.widget.config.set("traymsg", False)
|
||||||
|
|
||||||
def ircQtConnections(self, irc, widget):
|
def ircQtConnections(self, irc, widget):
|
||||||
# IRC --> Main window
|
|
||||||
return (
|
return (
|
||||||
|
# Connect widget signal to IRC slot/function. (IRC --> Widget)
|
||||||
|
# IRC runs on a different thread.
|
||||||
(widget.sendMessage, irc.send_message),
|
(widget.sendMessage, irc.send_message),
|
||||||
(widget.sendNotice, irc.send_notice),
|
(widget.sendNotice, irc.send_notice),
|
||||||
(widget.sendCTCP, irc.send_ctcp),
|
(widget.sendCTCP, irc.send_ctcp),
|
||||||
|
@ -4429,7 +4437,8 @@ class MainProgram(QtCore.QObject):
|
||||||
(widget.killSomeQuirks, irc.kill_some_quirks),
|
(widget.killSomeQuirks, irc.kill_some_quirks),
|
||||||
(widget.disconnectIRC, irc.disconnect_irc),
|
(widget.disconnectIRC, irc.disconnect_irc),
|
||||||
(widget.changeNick, irc.send_nick),
|
(widget.changeNick, irc.send_nick),
|
||||||
# Main window --> IRC
|
(widget.sendAuthenticate, irc.send_authenticate),
|
||||||
|
# Connect IRC signal to widget slot/function. (IRC --> Widget)
|
||||||
(irc.connected, widget.connected),
|
(irc.connected, widget.connected),
|
||||||
(irc.askToConnect, widget.connectAnyway),
|
(irc.askToConnect, widget.connectAnyway),
|
||||||
(irc.moodUpdated, widget.updateMoodSlot),
|
(irc.moodUpdated, widget.updateMoodSlot),
|
||||||
|
|
Loading…
Reference in a new issue