Changed the way Pesterchum quits + TLS fix.

This commit is contained in:
Dpeta 2021-03-25 23:08:08 +01:00
parent 8be8cf9f07
commit e07e685522
7 changed files with 33 additions and 11 deletions

View file

@ -7,6 +7,7 @@
- Added styleing/markup to "PESTER" and "ADD GROUP" menu options and some other previously unstyled elements :) - Added styleing/markup to "PESTER" and "ADD GROUP" menu options and some other previously unstyled elements :)
- Added pesterchum.spec for use with pyinstaller. - Added pesterchum.spec for use with pyinstaller.
- Wrapped socket in SSL context and changed the port appropriately, hostname verification is turned off. - Wrapped socket in SSL context and changed the port appropriately, hostname verification is turned off.
- Pesterchum now sends a ``QUIT :reason`` to the server when shutting down instead of just quitting instantly.
### Changed ### Changed
- Transitioned to Python 3. - Transitioned to Python 3.
@ -17,6 +18,7 @@
### Fixed ### Fixed
- Fixed sRGB profile issue with certain images. - Fixed sRGB profile issue with certain images.
- Fixed issue where Pesterchum crashed if a quirk was malformed. - Fixed issue where Pesterchum crashed if a quirk was malformed.
- Fixed Pesterchum icon getting stuck on the system tray even after shutdown on windows.
### Deprecated ### Deprecated
- Removed update system (it seemed to be non-functional). - Removed update system (it seemed to be non-functional).

View file

@ -1,11 +1,12 @@
# TODO LIST : ) # TODO LIST : )
~~Crossed out~~ entries are completed :3c
## ADD ## ADD
- A proper prompt for choosing a server. - A proper prompt for choosing a server.
## FIX ## FIX
- Pesterchum gets stuck on the system tray even after shutdown on windows. - ~~Pesterchum gets stuck on the system tray even after shutdown on windows.~~
- Audio mixer slider in options doesn't always work. (Not working on linux?) - Audio mixer slider in options doesn't always work. (Not working on linux?)
- QUIT not send to server on shutdown. - ~~QUIT not send to server on shutdown.~~
- TLS randomly causing socket to break. - ~~TLS randomly causing socket to break.~~
- Make setup.py work with 32-bit python. - Make setup.py work with 32-bit python.
- Make setup.py work with py2app (might not be required if pyinstaller works better!!). - Make setup.py work with py2app (might not be required if pyinstaller works better!!).

2
irc.py
View file

@ -420,6 +420,8 @@ class PesterHandler(DefaultCommandHandler):
mychumhandle = self.mainwindow.profile().handle mychumhandle = self.mainwindow.profile().handle
mymood = self.mainwindow.profile().mood.value() mymood = self.mainwindow.profile().mood.value()
if not self.mainwindow.config.lowBandwidth(): if not self.mainwindow.config.lowBandwidth():
from time import sleep
sleep(0.5) # To prevent TLS from dying </3
helpers.join(self.client, "#pesterchum") helpers.join(self.client, "#pesterchum")
helpers.msg(self.client, "#pesterchum", "MOOD >%d" % (mymood)) helpers.msg(self.client, "#pesterchum", "MOOD >%d" % (mymood))

View file

@ -84,8 +84,8 @@ class IRCClient:
""" """
self.context = ssl.create_default_context() self.context = ssl.create_default_context()
self.context.check_hostname = False self.context.check_hostname = False
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.bare_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket = self.context.wrap_socket(self.socket) self.socket = self.context.wrap_socket(self.bare_socket)
self.nick = None self.nick = None
self.real_name = None self.real_name = None
self.host = None self.host = None
@ -221,9 +221,22 @@ class IRCClient:
# with extreme prejudice # with extreme prejudice
if self.socket: if self.socket:
logging.info('shutdown socket') logging.info('shutdown socket')
#print("shutdown socket")
self._end = True self._end = True
self.socket.shutdown(socket.SHUT_RDWR) self.socket.shutdown(socket.SHUT_WR)
self.socket.close()
def simple_send(self, message):
self.socket.send(bytes(message, "UTF-8"))
def quit(self, msg):
# I am going mad :)
# Why does this only work 33% of the time </3
# Somehow, kinda fixed :')
print("QUIT")
self.socket.send(bytes(msg + "\n", "UTF-8"))
class IRCApp: class IRCApp:
""" This class manages several IRCClient instances without the use of threads. """ This class manages several IRCClient instances without the use of threads.
(Non-threaded) Timer functionality is also included. (Non-threaded) Timer functionality is also included.

View file

@ -101,6 +101,7 @@ class CommandHandler(object):
return return
logging.debug('f %s' % f) logging.debug('f %s' % f)
#logging.info(*args)
# Because more than 5 arguments can be passed by channelmodeis # Because more than 5 arguments can be passed by channelmodeis
try: try:

View file

@ -77,9 +77,10 @@ def cs(cli, *args):
def identify(cli, passwd, authuser="NickServ"): def identify(cli, passwd, authuser="NickServ"):
msg(cli, authuser, "IDENTIFY %s" % passwd) msg(cli, authuser, "IDENTIFY %s" % passwd)
def quit(cli, msg='gone'): def quit(cli, msg):
#print(msg) msg = "QUIT :%s" % msg
cli.send("QUIT :%s" % msg) cli.quit(msg)
cli.close()
cli._end = 1 cli._end = 1
def user(cli, username, realname=None): def user(cli, username, realname=None):

View file

@ -2934,10 +2934,12 @@ class PesterWindow(MovingWindow):
# This seriously needs to be fixed but I don't feel like it </3 # This seriously needs to be fixed but I don't feel like it </3
pesterchum.irc.quit_dc() # Actually send QUIT to server pesterchum.irc.quit_dc() # Actually send QUIT to server
pesterchum.trayicon.hide() # Hopefully, pesterchum.trayicon.hide() # Hopefully,
pesterchum.app.quit() # stop the trayicon from sticking around :/ #pesterchum.app.quit() # stop the trayicon from sticking around :/
#from time import sleep
#sleep(5)
# Just in case. # Just in case.
sys.exit() sys.exit() # Actually, just gonna use this, 'cuz sockets are dumb :'3
pcUpdate = QtCore.pyqtSignal('QString', 'QString') pcUpdate = QtCore.pyqtSignal('QString', 'QString')
closeToTraySignal = QtCore.pyqtSignal() closeToTraySignal = QtCore.pyqtSignal()