Skip to content
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