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 to work behind a proxy #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
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
13 changes: 12 additions & 1 deletion cloudprint/xmpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import socket
import select
import time
import os, socks
from urlparse import urlparse

from collections import deque
from xml.etree.ElementTree import XMLParser, TreeBuilder
Expand Down Expand Up @@ -113,7 +115,16 @@ def connect(self, host, port, use_ssl, sasl_token):

LOGGER.info("Establishing connection to xmpp server %s:%i" %
(host, port))
self._xmppsock = socket.socket()

http_proxy = os.environ.get('http_proxy')
if http_proxy is not None:
proxy= urlparse(http_proxy)
s = socks.socksocket()
s.setproxy(socks.PROXY_TYPE_HTTP, proxy.hostname, proxy.port)
self._xmppsock = s
else:
self._xmppsock = socket.socket()

self._wrappedsock = self._xmppsock

try:
Expand Down