Skip to content

Commit 666feac

Browse files
committed
socks5 support
1 parent ad3ddee commit 666feac

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Kubernetes Python Client (bjoern)
1+
# Kubernetes Python Client
22

33
[![Build Status](https://travis-ci.org/kubernetes-client/python.svg?branch=master)](https://travis-ci.org/kubernetes-client/python)
44
[![PyPI version](https://badge.fury.io/py/kubernetes.svg)](https://badge.fury.io/py/kubernetes)

kubernetes/base/stream/ws_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def websocket_proxycare(connect_opt, configuration, url, headers):
508508

509509
if configuration.proxy:
510510
proxy_url = urlparse(configuration.proxy)
511-
connect_opt.update({'http_proxy_host': proxy_url.hostname, 'http_proxy_port': proxy_url.port})
511+
connect_opt.update({'http_proxy_host': proxy_url.hostname, 'http_proxy_port': proxy_url.port, 'proxy_type': proxy_url.scheme})
512512
if configuration.proxy_headers:
513513
for key,value in configuration.proxy_headers.items():
514514
if key == 'proxy-authorization' and value.startswith('Basic'):

kubernetes/client/rest.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,31 @@ def __init__(self, configuration, pools_size=4, maxsize=None):
8888

8989
# https pool manager
9090
if configuration.proxy and not should_bypass_proxies(configuration.host, no_proxy=configuration.no_proxy or ''):
91-
self.pool_manager = urllib3.ProxyManager(
92-
num_pools=pools_size,
93-
maxsize=maxsize,
94-
cert_reqs=cert_reqs,
95-
ca_certs=ca_certs,
96-
cert_file=configuration.cert_file,
97-
key_file=configuration.key_file,
98-
proxy_url=configuration.proxy,
99-
proxy_headers=configuration.proxy_headers,
100-
**addition_pool_args
101-
)
91+
if configuration.proxy.startswith('sock'):
92+
from urllib3.contrib.socks import SOCKSProxyManager
93+
self.pool_manager = SOCKSProxyManager(
94+
num_pools=pools_size,
95+
maxsize=maxsize,
96+
cert_reqs=cert_reqs,
97+
ca_certs=ca_certs,
98+
cert_file=configuration.cert_file,
99+
key_file=configuration.key_file,
100+
proxy_url=configuration.proxy,
101+
headers=configuration.proxy_headers,
102+
**addition_pool_args
103+
)
104+
else:
105+
self.pool_manager = urllib3.ProxyManager(
106+
num_pools=pools_size,
107+
maxsize=maxsize,
108+
cert_reqs=cert_reqs,
109+
ca_certs=ca_certs,
110+
cert_file=configuration.cert_file,
111+
key_file=configuration.key_file,
112+
proxy_url=configuration.proxy,
113+
proxy_headers=configuration.proxy_headers,
114+
**addition_pool_args
115+
)
102116
else:
103117
self.pool_manager = urllib3.PoolManager(
104118
num_pools=pools_size,

0 commit comments

Comments
 (0)