|
4 | 4 | __author__ = 'Simon Robinson' |
5 | 5 | __copyright__ = 'Copyright (c) 2022 Simon Robinson' |
6 | 6 | __license__ = 'Apache 2.0' |
7 | | -__version__ = '2022-10-24' # ISO 8601 (YYYY-MM-DD) |
| 7 | +__version__ = '2022-11-01' # ISO 8601 (YYYY-MM-DD) |
8 | 8 |
|
9 | 9 | import argparse |
10 | 10 | import base64 |
@@ -412,6 +412,11 @@ def get_account_with_catch_all_fallback(option): |
412 | 412 | AppConfig.save() |
413 | 413 |
|
414 | 414 | 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) |
415 | 420 | access_token = None # avoid trying invalid (or soon to be) tokens |
416 | 421 | else: |
417 | 422 | access_token = OAuth2Helper.decrypt(fernet, access_token) |
@@ -1350,7 +1355,7 @@ def process_data(self, byte_data): |
1350 | 1355 | # if authentication succeeds (or fails), remove our proxy from the client and ignore all further communication |
1351 | 1356 | # don't use a regex here as the tag must match exactly; RFC 3501 specifies uppercase 'OK', so startswith is fine |
1352 | 1357 | 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 ]') |
1354 | 1359 | self.client_connection.authenticated = True |
1355 | 1360 | elif str_response.startswith('%s NO' % self.client_connection.authentication_tag): |
1356 | 1361 | 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): |
1443 | 1448 |
|
1444 | 1449 | elif self.client_connection.connection_state is POPOAuth2ClientConnection.STATE.XOAUTH2_CREDENTIALS_SENT: |
1445 | 1450 | 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 ]') |
1447 | 1452 | self.client_connection.authenticated = True |
1448 | 1453 | super().process_data(byte_data) |
1449 | 1454 | else: |
@@ -1539,7 +1544,7 @@ def process_data(self, byte_data): |
1539 | 1544 |
|
1540 | 1545 | elif self.client_connection.connection_state is SMTPOAuth2ClientConnection.STATE.XOAUTH2_CREDENTIALS_SENT: |
1541 | 1546 | 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 ]') |
1543 | 1548 | self.client_connection.authenticated = True |
1544 | 1549 | super().process_data(byte_data) |
1545 | 1550 | else: |
@@ -2377,7 +2382,7 @@ def load_and_start_servers(self, icon=None, reload=True): |
2377 | 2382 | new_proxy.start() |
2378 | 2383 | self.proxies.append(new_proxy) |
2379 | 2384 | 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)) |
2381 | 2386 | server_start_error = True |
2382 | 2387 |
|
2383 | 2388 | if server_start_error or server_load_error or len(self.proxies) <= 0: |
|
0 commit comments