Skip to content

Commit ecea051

Browse files
committed
Clarify error message text
1 parent fbf4546 commit ecea051

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

emailproxy.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__author__ = 'Simon Robinson'
55
__copyright__ = 'Copyright (c) 2022 Simon Robinson'
66
__license__ = 'Apache 2.0'
7-
__version__ = '2022-10-24' # ISO 8601 (YYYY-MM-DD)
7+
__version__ = '2022-11-01' # ISO 8601 (YYYY-MM-DD)
88

99
import argparse
1010
import base64
@@ -412,6 +412,11 @@ def get_account_with_catch_all_fallback(option):
412412
AppConfig.save()
413413

414414
else:
415+
# we used to keep tokens until the last possible moment here, but it is simpler to just obtain a
416+
# new one within TOKEN_EXPIRY_MARGIN, particularly when in CCG or ROPCG flow modes where getting
417+
# a new token involves no user interaction (note that in interactive mode it would be better to
418+
# request a new token via the user before discarding the existing one, but since this happens
419+
# very infrequently, we don't add the extra complexity for just 10 extra minutes of token life)
415420
access_token = None # avoid trying invalid (or soon to be) tokens
416421
else:
417422
access_token = OAuth2Helper.decrypt(fernet, access_token)
@@ -1350,7 +1355,7 @@ def process_data(self, byte_data):
13501355
# if authentication succeeds (or fails), remove our proxy from the client and ignore all further communication
13511356
# don't use a regex here as the tag must match exactly; RFC 3501 specifies uppercase 'OK', so startswith is fine
13521357
if str_response.startswith('%s OK' % self.client_connection.authentication_tag):
1353-
Log.info(self.info_string(), '[ Successfully authenticated IMAP connection - removing proxy ]')
1358+
Log.info(self.info_string(), '[ Successfully authenticated IMAP connection - releasing session ]')
13541359
self.client_connection.authenticated = True
13551360
elif str_response.startswith('%s NO' % self.client_connection.authentication_tag):
13561361
super().process_data(byte_data) # an error occurred - just send to the client and exit
@@ -1443,7 +1448,7 @@ def process_data(self, byte_data):
14431448

14441449
elif self.client_connection.connection_state is POPOAuth2ClientConnection.STATE.XOAUTH2_CREDENTIALS_SENT:
14451450
if str_data.startswith('+OK'):
1446-
Log.info(self.info_string(), '[ Successfully authenticated POP connection - removing proxy ]')
1451+
Log.info(self.info_string(), '[ Successfully authenticated POP connection - releasing session ]')
14471452
self.client_connection.authenticated = True
14481453
super().process_data(byte_data)
14491454
else:
@@ -1539,7 +1544,7 @@ def process_data(self, byte_data):
15391544

15401545
elif self.client_connection.connection_state is SMTPOAuth2ClientConnection.STATE.XOAUTH2_CREDENTIALS_SENT:
15411546
if str_data.startswith('235'):
1542-
Log.info(self.info_string(), '[ Successfully authenticated SMTP connection - removing proxy ]')
1547+
Log.info(self.info_string(), '[ Successfully authenticated SMTP connection - releasing session ]')
15431548
self.client_connection.authenticated = True
15441549
super().process_data(byte_data)
15451550
else:
@@ -2377,7 +2382,7 @@ def load_and_start_servers(self, icon=None, reload=True):
23772382
new_proxy.start()
23782383
self.proxies.append(new_proxy)
23792384
except Exception as e:
2380-
Log.error('Error: unable to start server:', Log.error_string(e))
2385+
Log.error('Error: unable to start', match.string, 'server:', Log.error_string(e))
23812386
server_start_error = True
23822387

23832388
if server_start_error or server_load_error or len(self.proxies) <= 0:

0 commit comments

Comments
 (0)