From 650e1a2ed5d3c665e511c5fdac300e9a57d242bb Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 4 Feb 2021 18:31:43 +0100 Subject: docs/xmlstream: remove HTTP proxy references It has been removed years ago. --- slixmpp/xmlstream/xmlstream.py | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'slixmpp/xmlstream/xmlstream.py') diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index b80c55d3..48784a4b 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -157,10 +157,6 @@ class XMLStream(asyncio.BaseProtocol): #: non-SSL traffic and another for SSL traffic. self.use_ssl = False - #: If set to ``True``, attempt to connect through an HTTP - #: proxy based on the settings in :attr:`proxy_config`. - self.use_proxy = False - #: If set to ``True``, attempt to use IPv6. self.use_ipv6 = True @@ -173,13 +169,6 @@ class XMLStream(asyncio.BaseProtocol): #: to ``False``. self.use_cdata = False - #: An optional dictionary of proxy settings. It may provide: - #: :host: The host offering proxy services. - #: :port: The port for the proxy service. - #: :username: Optional username for accessing the proxy. - #: :password: Optional password for accessing the proxy. - self.proxy_config = {} - #: The default namespace of the stream content, not of the #: stream wrapper itself. self.default_ns = '' -- cgit v1.2.3 From d3063a0368503daa27d0bb24ea74890952dec707 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 4 Feb 2021 18:32:41 +0100 Subject: xmlstream: make connect_loop_wait private --- slixmpp/xmlstream/xmlstream.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'slixmpp/xmlstream/xmlstream.py') diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 48784a4b..83a197de 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -88,7 +88,9 @@ class XMLStream(asyncio.BaseProtocol): # The socket that is used internally by the transport object self.socket = None - self.connect_loop_wait = 0 + # The backoff of the connect routine (increases exponentially + # after each failure) + self._connect_loop_wait = 0 self.parser = None self.xml_depth = 0 @@ -284,7 +286,7 @@ class XMLStream(asyncio.BaseProtocol): self.disconnect_reason = None self.cancel_connection_attempt() - self.connect_loop_wait = 0 + self._connect_loop_wait = 0 if host and port: self.address = (host, int(port)) try: @@ -309,9 +311,9 @@ class XMLStream(asyncio.BaseProtocol): async def _connect_routine(self): self.event_when_connected = "connected" - if self.connect_loop_wait > 0: - self.event('reconnect_delay', self.connect_loop_wait) - await asyncio.sleep(self.connect_loop_wait, loop=self.loop) + if self._connect_loop_wait > 0: + self.event('reconnect_delay', self._connect_loop_wait) + await asyncio.sleep(self._connect_loop_wait, loop=self.loop) record = await self.pick_dns_answer(self.default_domain) if record is not None: @@ -337,7 +339,7 @@ class XMLStream(asyncio.BaseProtocol): self.address[1], ssl=ssl_context, server_hostname=self.default_domain if self.use_ssl else None) - self.connect_loop_wait = 0 + self._connect_loop_wait = 0 except Socket.gaierror as e: self.event('connection_failed', 'No DNS record available for %s' % self.default_domain) @@ -346,7 +348,7 @@ class XMLStream(asyncio.BaseProtocol): self.event("connection_failed", e) if self._current_connection_attempt is None: return - self.connect_loop_wait = self.connect_loop_wait * 2 + 1 + self._connect_loop_wait = self._connect_loop_wait * 2 + 1 self._current_connection_attempt = asyncio.ensure_future( self._connect_routine(), loop=self.loop, -- cgit v1.2.3 From ccbba89cbd9354a78c12e271d28ea22d8f3058e7 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 4 Feb 2021 18:42:01 +0100 Subject: xmlstream: make dns_answers private --- slixmpp/xmlstream/xmlstream.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'slixmpp/xmlstream/xmlstream.py') diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 83a197de..e6af3faa 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -16,10 +16,12 @@ from typing import ( Any, Callable, Iterable, + Iterator, List, Optional, Set, Union, + Tuple, ) import functools @@ -212,7 +214,7 @@ class XMLStream(asyncio.BaseProtocol): self._current_connection_attempt = None #: A list of DNS results that have not yet been tried. - self.dns_answers = None + self._dns_answers: Optional[Iterator[Tuple[str, str, int]]] = None #: The service name to check with DNS SRV records. For #: example, setting this to ``'xmpp-client'`` would query the @@ -315,7 +317,7 @@ class XMLStream(asyncio.BaseProtocol): self.event('reconnect_delay', self._connect_loop_wait) await asyncio.sleep(self._connect_loop_wait, loop=self.loop) - record = await self.pick_dns_answer(self.default_domain) + record = await self._pick_dns_answer(self.default_domain) if record is not None: host, address, dns_port = record port = dns_port if dns_port else self.address[1] @@ -324,7 +326,7 @@ class XMLStream(asyncio.BaseProtocol): else: # No DNS records left, stop iterating # and try (host, port) as a last resort - self.dns_answers = None + self._dns_answers = None if self.use_ssl: ssl_context = self.get_ssl_context() @@ -392,7 +394,7 @@ class XMLStream(asyncio.BaseProtocol): self._current_connection_attempt = None self.init_parser() self.send_raw(self.stream_header) - self.dns_answers = None + self._dns_answers = None def data_received(self, data): """Called when incoming data is received on the socket. @@ -777,7 +779,7 @@ class XMLStream(asyncio.BaseProtocol): idx += 1 return False - async def get_dns_records(self, domain, port=None): + async def get_dns_records(self, domain: str, port: Optional[int] = None) -> List[Tuple[str, str, int]]: """Get the DNS records for a domain. :param domain: The domain in question. @@ -797,7 +799,7 @@ class XMLStream(asyncio.BaseProtocol): loop=self.loop) return result - async def pick_dns_answer(self, domain, port=None): + async def _pick_dns_answer(self, domain: str, port: Optional[int] = None) -> Optional[Tuple[str, str, int]]: """Pick a server and port from DNS answers. Gets DNS answers if none available. @@ -806,12 +808,12 @@ class XMLStream(asyncio.BaseProtocol): :param domain: The domain in question. :param port: If the results don't include a port, use this one. """ - if self.dns_answers is None: + if self._dns_answers is None: dns_records = await self.get_dns_records(domain, port) - self.dns_answers = iter(dns_records) + self._dns_answers = iter(dns_records) try: - return next(self.dns_answers) + return next(self._dns_answers) except StopIteration: return -- cgit v1.2.3