Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement support for PROXY Protocol (#246)
* Implement Logic & Test for PROXY protocol * Take PROXY protocol detection out of main _handle_client loop * Extract PROXY handling to its own module * Remove unused class & constant * Add constants for protocol * Implement testing for v2 * Implement testing for ProxyData class itself * Make sure all copyrightable files have license snippet * Catch exception during parsing * Successful use of attrs * Add random test for TCP4 * Make alias for hairy-looking markers * Combine some IPv6 tests into a parametrized one * Implement TLV parser * V2_ constants are now Enums * Add tlv prop to ProxyData * Add tests for tlv prop of ProxyData * Change import * to explicit * Record proxy data in session * Add annotation for SMTP.session and SMTP.envelope * Change _proxy_result to session.proxy_data * Docstring for Session.proxy_data * Fix typo in __slots__ * Change equality test to None * Remove special env flags for Python Version * Remove unused try..except * Add small test for coverage 100% * Add test for tlv property in ProxyData * Defensive assert to ensure PROXY protocol activated * Workaround for ConnectionAborted not raised in Linux * Add test that server is still connectable after timeout * Add some asyncio.sleep() in smtp.py to ensure all transport.close() related processing have taken place * Add test for streaming hiccup * Extract test contants to module * Add test abt extraneous non PROXYv2 data * Add some PROXYv2 tests * Add timeout test for v2 * Update NEWS.rst * Also okay if ConnectionResetError * Tune CSS * Title Case * Change :boldital: to full-fledged py:attribute:: * Update concepts.rst with new attribs in Session * Deprecate Session.login_data * Move _static into docs * More CSS Tuning * Now uses a lot of Sphinx's py domain roles * This reactivates modindex * The whole AUTH system moved to its own page because it's getting unwieldy * Public classes/functions added to several pages * Fetch master only if not in master * Make sure that "run" with "if" is by bash * Redo ProxyTLV class * Now inherits from dict * parse() extracted from from_raw() * parse() can now do partial parsing * New name_to_num() classmethod * TestProxyProtocol{V1,V2}Controller are merged into a common Test Class with parametrized test cases * ... and use a better name for the class * Add simple test for Accept/Reject based on handle_PROXY return value * Also add test for new name_to_map() classmethod * Add logging to PROXY Protocol handling in smtp.py * Add checks on proxy_protocol_timeout values * Add documentation * Fix test for log entry * Add ability to raise exception * General Improvement on ProxyTLV * Rewrite parse() to use Accumulator Pattern. This is needed to properly implement "partial parsing" ability * parse() now also generates "TLV Location". This is to support CRC32C calculation (even though CRC32C calculation will NOT be implemented in proxy_protocol.py due to deps restriction) * parse() now gains "strict" parameter * New UnknownTypeTLV exception to support parse(strict=True) * from_raw() adapted to new parse() retval + gains "strict" param, too * __init__() now requires _tlv_loc * __slots__ corrected * Add test cases for "partial parsing" and "strict" * Add whole_raw attrib to ProxyData * Add test to ensure no log.warning for timeout >= 3.0 * Add reflink to standard doc * Slight tidying up of test data * Fix qa complaint * Increase Timeout Multiplier to 1.5 * Expect raising of ConnectionError * Fix pytype complaints * Fix LGTM Alert * Fix duplicate rst ref in docs * Fix NEWS.rst formatting * Add tlv_start attribute to ProxyData * Add doc about CRC32C Calculation / Validation * Use the desired CaseStyling for products * Use v2.3.0 tag instead of SHA hash * Also record whole_raw for PROXYv1 * Normalize AF and PROTO for v1 & v2 * Add _raises to ProxyData.same_attribs * Add test of public PROXYv1 examples * Reword about HAProxy v2.3.0 * Use internal func to get a field piecemeal using read() instead of readexactly(). This allows rapid response to Connection Lost instead of waiting for timeout. Also, introduces more points where cooperative concurrency context switching can take place. * Pepper the func with lots of log.debug to help troubleshooting. * Rename "rest" to "tail_part" * Totally rewrite _get_v1 * Add option to skip adding prefix to log message * A bunch of documentation/annotation improvements * Extend the "hiccup" delay * Remove a pragma * Use log.warning instead of warnings.warn * Remove unused f * Implement 4th arg for handle_PROXY * Add test for get_proxy unrecognized signature * Rename some methods and classes * Up version to 1.4.0a1 * Remove last vestiges of aiosmtpd.smtp.__version__ * Add Unicode accoutrements to housekeep.py
- Loading branch information