Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support connections through SOCKS5 proxies #2169

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Commits on Nov 16, 2020

  1. Support connections through SOCKS5 proxies

    Implement support for SOCKS5 proxies. Implement a new proxy wrapper
    that handles SOCKS5 connection, authentication and requesting
    connections to the actual Kafka broker endpoints.
    
    The proxy can be configured via a new keyword argument `socks5_proxy`
    to consumers, producers or admin client. The value is URL with optional
    username and password. E.g.
    `socks5://user:secret@proxy.example.com:10800`
    
    The implementation is done in state machine that makes progress on
    repeated calls to connect_ex. The rationale with this bit strange
    design is to minimize amount of changes on the actual BrokerConnection
    object.
    hnousiainen committed Nov 16, 2020
    Configuration menu
    Copy the full SHA
    b77202d View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2024

  1. Configuration menu
    Copy the full SHA
    b95e46d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    78c74c0 View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2024

  1. Configuration menu
    Copy the full SHA
    e796019 View commit details
    Browse the repository at this point in the history
  2. Reconfigure tests to complete in a more timely manner and skip some i…

    …terations for Kafka 0.8.2 and Python 3.12 (dpkp#159)
    
    * skip failing tests for PyPy since they work locally
    
    * Reconfigure tests for PyPy and 3.12
    
    * Skip partitioner tests in test_partitioner.py if 3.12 and 0.8.2
    
    * Update test_partitioner.py
    
    * Update test_producer.py
    
    * Timeout tests after ten minutes
    
    * Set 0.8.2.2 to be experimental from hereon
    
    * Formally support PyPy 3.9
    wbarnha authored Mar 8, 2024
    Configuration menu
    Copy the full SHA
    38e159a View commit details
    Browse the repository at this point in the history

Commits on Mar 9, 2024

  1. Test Kafka 0.8.2.2 using Python 3.10 in the meantime (dpkp#161)

    * Test Kafka 0.8.2.2 using Python 3.11 in the meantime
    
    * Override PYTHON_LATEST conditionally in python-package.yml
    
    * Update python-package.yml
    
    * add python annotation to kafka version test matrix
    
    * Update python-package.yml
    
    * try python 3.10
    wbarnha authored Mar 9, 2024
    Configuration menu
    Copy the full SHA
    e762321 View commit details
    Browse the repository at this point in the history
  2. Remove support for EOL'ed versions of Python (dpkp#160)

    * Remove support for EOL'ed versions of Python
    
    * Update setup.py
    wbarnha authored Mar 9, 2024
    Configuration menu
    Copy the full SHA
    00750aa View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    641a76d View commit details
    Browse the repository at this point in the history
  4. Stop testing Python 3.13 in python-package.yml (dpkp#162)

    Too many MRs to review... so little time.
    wbarnha authored Mar 9, 2024
    Configuration menu
    Copy the full SHA
    5bd1323 View commit details
    Browse the repository at this point in the history
  5. Avoid 100% CPU usage while socket is closed (dpkp#156)

    After stop/start kafka service, kafka-python may use 100% CPU caused by
    busy-retry while the socket was closed. This fix the issue by unregister
    the socket if the fd is negative.
    
    Co-authored-by: Orange Kao <orange@aiven.io>
    wbarnha and orange-kao authored Mar 9, 2024
    Configuration menu
    Copy the full SHA
    cda8f81 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    eee0e01 View commit details
    Browse the repository at this point in the history
  7. Fix DescribeConfigsResponse_v1 config_source (dpkp#150)

    Co-authored-by: Ryar Nyah <ryarnyah@gmail.com>
    wbarnha and ryarnyah authored Mar 9, 2024
    Configuration menu
    Copy the full SHA
    c02df08 View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2024

  1. Fix base class of DescribeClientQuotasResponse_v0 (dpkp#144)

    Co-authored-by: Denis Otkidach <denis.otkidach@gmail.com>
    wbarnha and ods authored Mar 10, 2024
    Configuration menu
    Copy the full SHA
    65eacfb View commit details
    Browse the repository at this point in the history
  2. Update license_file to license_files (dpkp#131)

    The former has been deprecated since setuptools 56
    
    Co-authored-by: micwoj92 <45581170+micwoj92@users.noreply.github.com>
    wbarnha and micwoj92 authored Mar 10, 2024
    Configuration menu
    Copy the full SHA
    e0ebe5d View commit details
    Browse the repository at this point in the history
  3. Update some RST documentation syntax (dpkp#130)

    * docs: Update syntax in README.rst
    
    * docs: Update code block syntax in docs/index.rst
    
    ---------
    
    Co-authored-by: HalfSweet <60973476+HalfSweet@users.noreply.github.com>
    wbarnha and HalfSweet authored Mar 10, 2024
    Configuration menu
    Copy the full SHA
    26bb3eb View commit details
    Browse the repository at this point in the history
  4. Fix crc32c's __main__ for Python 3 (dpkp#142)

    * Fix crc32c's __main__ for Python 3
    
    * Remove TODO from _crc32c.py
    
    ---------
    
    Co-authored-by: Yonatan Goldschmidt <yon.goldschmidt@gmail.com>
    wbarnha and Jongy authored Mar 10, 2024
    Configuration menu
    Copy the full SHA
    88763da View commit details
    Browse the repository at this point in the history
  5. Strip trailing dot off hostname. (dpkp#133)

    Co-authored-by: Dave Voutila <voutilad@gmail.com>
    wbarnha and voutilad authored Mar 10, 2024
    Configuration menu
    Copy the full SHA
    b1a4c53 View commit details
    Browse the repository at this point in the history
  6. Handle OSError to properly recycle SSL connection, fix infinite loop (d…

    …pkp#155)
    
    * handling OSError
    
    * better error output
    
    * removed traceback logging
    
    ---------
    
    Co-authored-by: Alexander Sibiryakov <sixty-one@yandex.ru>
    wbarnha and sibiryakov authored Mar 10, 2024
    Configuration menu
    Copy the full SHA
    18eaa2d View commit details
    Browse the repository at this point in the history
  7. client_async: Allow throwing an exception upon socket error during (d…

    …pkp#134)
    
    wakeup
    
    When wakeup() is called, we sometime notice that we get
    an endless prints:
    "Unable to send to wakeup socket!".
    
    Those prints are spamming the logs.
    This commit aims to address it by allowing restating the
    application via an intentional exception raise.
    This behavior is configurable and its default is backward compatible.
    
    Signed-off-by: shimon-armis <shimon.turjeman@armis.com>
    Co-authored-by: shimon-armis <shimon.turjeman@armis.com>
    wbarnha and shimonturjeman authored Mar 10, 2024
    Configuration menu
    Copy the full SHA
    54cbd63 View commit details
    Browse the repository at this point in the history

Commits on Mar 12, 2024

  1. Log connection errors at ERROR level (dpkp#139)

    Co-authored-by: drewdogg <drewdogg@users.noreply.github.com>
    wbarnha and drewdogg authored Mar 12, 2024
    Configuration menu
    Copy the full SHA
    eb6fd9b View commit details
    Browse the repository at this point in the history

Commits on Mar 18, 2024

  1. Support custom SASL mechanisms including AWS MSK (dpkp#170)

    * Support custom SASL mechanisms
    
    There is some interest in supporting various SASL mechanisms not
    currently included in the library:
    
    * dpkp#2110 (DMS)
    * dpkp#2204 (SSPI)
    * dpkp#2232 (AWS_MSK_IAM)
    
    Adding these mechanisms in the core library may be undesirable due to:
    
    * Increased maintenance burden.
    * Unavailable testing environments.
    * Vendor specificity.
    
    This commit provides a quick prototype for a pluggable SASL system.
    
    ---
    
    **Example**
    
    To define a custom SASL mechanism a module must implement two methods:
    
    ```py
    
    def validate_config(conn):
        # Check configuration values, available libraries, etc.
        assert conn.config['vendor_specific_setting'] is not None, (
            'vendor_specific_setting required when sasl_mechanism=MY_SASL'
        )
    
    def try_authenticate(conn, future):
        # Do authentication routine and return resolved Future with failed
        # or succeeded state.
    ```
    
    And then the custom mechanism should be registered before initializing
    a KafkaAdminClient, KafkaConsumer, or KafkaProducer:
    
    ```py
    
    import kafka.sasl
    from kafka import KafkaProducer
    
    import my_sasl
    
    kafka.sasl.register_mechanism('MY_SASL', my_sasl)
    
    producer = KafkaProducer(sasl_mechanism='MY_SASL')
    ```
    
    ---
    
    **Notes**
    
    **ABCs**
    
    This prototype does not implement an ABC for custom SASL mechanisms.
    Using an ABC would reduce a few of the explicit assertions involved with
    registering a mechanism and is a viable option. Due to differing feature
    sets between py2/py3 this option was not explored, but shouldn't be
    difficult.
    
    **Private Methods**
    
    This prototype relies on some methods that are currently marked as
    **private** in `BrokerConnection`.
    
    * `._can_send_recv`
    * `._lock`
    * `._recv_bytes_blocking`
    * `._send_bytes_blocking`
    
    A pluggable system would require stable interfaces for these actions.
    
    **Alternative Approach**
    
    If the module-scoped dict modification in `register_mechanism` feels too
    clunky maybe the addtional mechanisms can be specified via an argument
    when initializing one of the `Kafka*` classes?
    
    * Add test_msk.py by @mattoberle
    
    * add msk to __init__ and check for extension in conn.py
    
    * rename try_authenticate in msk.py
    
    * fix imports
    
    * fix imports
    
    * add botocore to requirements-dev.txt
    
    * add boto3 to requirements-dev.txt
    
    * add awscli to requirements-dev.txt
    
    * add awscli to workflow since it takes too long to install normally
    
    * just install botocore i guess
    
    * just install boto3 i guess
    
    * force reinstall awscli
    
    * try something weird
    
    * ok now the dang tests should work and if they don't i'll cry
    
    * skip the msk test for now...
    
    * Revert "skip the msk test for now..."
    
    This reverts commit 1c29667.
    
    * skip the msk test for now...
    
    * nvm just needed to update tox lol
    
    * Update kafka/sasl/gssapi.py
    
    Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
    
    * Update kafka/sasl/oauthbearer.py
    
    Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
    
    * Update kafka/sasl/plain.py
    
    Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
    
    * Update kafka/sasl/scram.py
    
    Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
    
    * Update kafka/sasl/msk.py
    
    Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Matt Oberle <mattoberle@users.noreply.github.com>
    Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
    3 people authored Mar 18, 2024
    Configuration menu
    Copy the full SHA
    6ad79a4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    deeccfa View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    fcca556 View commit details
    Browse the repository at this point in the history

Commits on Mar 19, 2024

  1. Remove all vendoring (dpkp#169)

    Now that the codebase has been modernised by using pyupgrade, we can
    also remove all backported vendor modules, and all uses of them.
    s-t-e-v-e-n-k authored Mar 19, 2024
    Configuration menu
    Copy the full SHA
    a856dc4 View commit details
    Browse the repository at this point in the history
  2. Support Describe log dirs (dpkp#145)

    I implemented API KEY 35 from the official Apache Kafka documentation. This functionality is requested in issue # 2163 and this is an implementation proposal.
    
    Co-authored-by: chopatate <florian.courouge@outlook.fr>
    wbarnha and Courouge authored Mar 19, 2024
    Configuration menu
    Copy the full SHA
    2f2ccb1 View commit details
    Browse the repository at this point in the history

Commits on Mar 20, 2024

  1. Update conftest.py to use request.node.originalname instead for legal…

    … topic naming (dpkp#172)
    
    * Update conftest.py to use request.node.originalname instead for legal topic naming
    
    Otherwise parametrization doesn't work.
    
    * Update test/conftest.py
    
    Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
    wbarnha and code-review-doctor[bot] authored Mar 20, 2024
    Configuration menu
    Copy the full SHA
    0259502 View commit details
    Browse the repository at this point in the history
  2. KIP-345 Static membership implementation (dpkp#137)

    * KIP-345 Add static consumer membership support
    
    * KIP-345 Add examples to docs
    
    * KIP-345 Add leave_group_on_close flag
    
    https://issues.apache.org/jira/browse/KAFKA-6995
    
    * KIP-345 Add tests for static membership
    
    * KIP-345 Update docs for leave_group_on_close option
    
    * Update changelog.rst
    
    * remove six from base.py
    
    * Update base.py
    
    * Update base.py
    
    * Update base.py
    
    * Update changelog.rst
    
    * Update README.rst
    
    ---------
    
    Co-authored-by: Denis Kazakov <d.kazakov@mcplat.ru>
    Co-authored-by: Denis Kazakov <denis@kazakov.ru.net>
    3 people authored Mar 20, 2024
    Configuration menu
    Copy the full SHA
    3c124b2 View commit details
    Browse the repository at this point in the history

Commits on Mar 26, 2024

  1. Use monkeytype to create some semblance of typing (dpkp#173)

    * Add typing
    
    * define types as Struct for simplicity's sake
    wbarnha authored Mar 26, 2024
    Configuration menu
    Copy the full SHA
    56065da View commit details
    Browse the repository at this point in the history
  2. Add zstd support on legacy record and ensure no variable is referred …

    …before definition (dpkp#138)
    
    * fix if statement logic and add zstd check
    
    * fix if statement logic and add zstd uncompress
    
    * fix imports
    
    * avoid variable be used before definition
    
    * Remove unused import from legacy_records.py
    
    ---------
    
    Co-authored-by: Alexandre Souza <alexandre.souza@axonius.com>
    wbarnha and ax-ale authored Mar 26, 2024
    Configuration menu
    Copy the full SHA
    cbf317b View commit details
    Browse the repository at this point in the history

Commits on Mar 27, 2024

  1. Configuration menu
    Copy the full SHA
    af1a5f0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    aba153f View commit details
    Browse the repository at this point in the history

Commits on Mar 29, 2024

  1. Configuration menu
    Copy the full SHA
    81283f5 View commit details
    Browse the repository at this point in the history