async def connect(self, server_info, proto_code=None, *,<EOL>use_tor=False, disable_cert_verify=False,<EOL>proxy=None, short_term=False):
self.server_info = server_info<EOL>if not proto_code:<EOL><INDENT>proto_code,*_ = server_info.protocols<EOL><DEDENT>self.proto_code = proto_code<EOL>logger.debug("<STR_LIT>" % server_info)<EOL>if proto_code == '<STR_LIT:g>':       <EOL><INDENT>raise NotImplementedError('<STR_LIT>')<EOL><DEDENT>hostname, port, use_ssl = server_info.get_port(proto_code)<EOL>if use_tor:<EOL><INDENT>if have_aiosocks:<EOL><INDENT>try:<EOL><INDENT>socks_host, socks_port = use_tor<EOL><DEDENT>except TypeError:<EOL><INDENT>socks_host, socks_port = '<STR_LIT:localhost>', <NUM_LIT><EOL><DEDENT>disable_cert_verify = True<EOL>assert not proxy, "<STR_LIT>"<EOL>logger.debug("<STR_LIT>")<EOL>proxy = aiosocks.Socks5Addr(socks_host, int(socks_port))<EOL><DEDENT>else:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL><DEDENT><DEDENT>if use_ssl == True and disable_cert_verify:<EOL><INDENT>use_ssl = ssl.create_default_context()<EOL>use_ssl.check_hostname = False<EOL>use_ssl.verify_mode = ssl.CERT_NONE<EOL>logger.debug("<STR_LIT>")<EOL><DEDENT>async def _reconnect():<EOL><INDENT>if self.protocol: return        <EOL>if proxy:<EOL><INDENT>if have_aiosocks:<EOL><INDENT>transport, protocol = await aiosocks.create_connection(<EOL>StratumProtocol, proxy=proxy,<EOL>proxy_auth=None,<EOL>remote_resolve=True, ssl=use_ssl,<EOL>dst=(hostname, port))<EOL><DEDENT>else:<EOL><INDENT>logger.debug("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>transport, protocol = await self.loop.create_connection(<EOL>StratumProtocol, host=hostname,<EOL>port=port, ssl=use_ssl)<EOL><DEDENT>self.protocol = protocol<EOL>protocol.client = self<EOL>self.actual_connection = dict(hostname=hostname, port=int(port),<EOL>ssl=bool(use_ssl), tor=bool(proxy))<EOL>self.actual_connection['<STR_LIT>'] = transport.get_extra_info('<STR_LIT>',<EOL>default=['<STR_LIT>'])[<NUM_LIT:0>]<EOL>if not short_term:<EOL><INDENT>self.ka_task = self.loop.create_task(self._keepalive())<EOL><DEDENT>logger.debug("<STR_LIT>" % server_info)<EOL><DEDENT>if self.protocol:<EOL><INDENT>self.protocol.close()<EOL>self.protocol = None<EOL><DEDENT>self.reconnect = _reconnect<EOL>await self.reconnect()<EOL>
Start connection process.
Destination must be specified in a ServerInfo() record (first arg).