Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Added proxy support for websocket connections #4635

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
Loading
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion 18 lib/request/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,25 @@ def getPage(**kwargs):
url = getBytes(url) # Note: Python3 requires text while Python2 has problems when mixing text with binary POST

if webSocket:
ws_proxy_port = None
ws_proxy_host = None
ws_proxy_auth = None
ws_proxy_scheme = None

if conf.proxy:
ws_proxy_uri = _urllib.parse.urlsplit(conf.proxy)
ws_proxy_port = ws_proxy_uri.port
ws_proxy_host = ws_proxy_uri.hostname
ws_proxy_scheme = ws_proxy_uri.scheme

if conf.proxyCred:
ws_proxy_auth = conf.proxyCred.split(":")

ws = websocket.WebSocket()
ws.settimeout(WEBSOCKET_INITIAL_TIMEOUT if kb.webSocketRecvCount is None else timeout)
ws.connect(url, header=("%s: %s" % _ for _ in headers.items() if _[0] not in ("Host",)), cookie=cookie) # WebSocket will add Host field of headers automatically
ws.connect(url, header=("%s: %s" % _ for _ in headers.items() if _[0] not in ("Host",)), cookie=cookie,
http_proxy_host=ws_proxy_host, http_proxy_port=ws_proxy_port,
http_proxy_auth=ws_proxy_auth, proxy_type=ws_proxy_scheme) # WebSocket will add Host field of headers automatically
ws.send(urldecode(post or ""))

_page = []
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.