OpenAPITools / OpenAPITools/openapi-generator
[REQ] Socks python asyncio
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
When a kubeconfig cluster entry contains a proxy-url with a SOCKS
scheme (e.g. socks5://localhost:1080), the asyncio Python client fails
with:
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected
This happens because aiohttp.TCPConnector does not support SOCKS
schemes — the connection attempts to go through the SOCKS proxy as a
plain TCP connection, causing the server to disconnect during the
handshake. HTTP/HTTPS proxies work fine but SOCKS is silently broken.
Describe the solution you'd like
In the asyncio rest.mustache template, detect SOCKS schemes at
RESTClientObject initialization and route to
aiohttp_socks.ProxyConnector instead of aiohttp.TCPConnector:
SUPPORTED_SOCKS_PROXIES = frozenset({'socks4', 'socks4a', 'socks5', 'socks5h'})
proxy_scheme = (proxy or "").partition("://")[0].lower()
if proxy_scheme in SUPPORTED_SOCKS_PROXIES:
from aiohttp_socks import ProxyConnector
connector = ProxyConnector.from_url(proxy, ...)
self.proxy = None # connector handles proxy at connection level
else:
connector = aiohttp.TCPConnector(...)
self.proxy = proxy
Requires aiohttp>=3.10.0 and aiohttp-socks>=0.9.0.
Describe alternatives you've considered
- Passing the SOCKS proxy per-request via
args["proxy"]— does not
work, aiohttp does not support SOCKS at the request level - Using
aiohttp-socksat the session level without changing the
connector — not possible, SOCKS requires a dedicated connector
Additional context
- All four SOCKS schemes supported:
socks4,socks4a,socks5,socks5h - Lazy import of
ProxyConnector— non-SOCKS users completely unaffected - HTTP/HTTPS proxy code path contains only minor changes
- Complements the urllib3 SOCKS fix for the sync Python client template
- Relates to kubernetes-client/python#1064
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the asyncio rest.mustache template and inspect RESTClientObject initialization, then review how proxy settings are passed to aiohttp.TCPConnector. Support the four listed SOCKS schemes through aiohttp-socks while preserving the existing HTTP/HTTPS path, and update dependencies for aiohttp>=3.10.0 and aiohttp-socks>=0.9.0. Done means SOCKS proxy URLs use the SOCKS connector and non-SOCKS users remain unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100