def getKey(self): with newkey_lock[self.serverid]: if self.serverid not in keys: for _ in range(2): logger.debug('hxsocks getKey') host, port, usn, psw = (self.hxsServer.hostname, self.hxsServer.port, self.hxsServer.username, self.hxsServer.password) if self._sock is None: logger.debug('hxsocks connect') from connection import create_connection self._sock = create_connection((host, port), self.timeout, parentproxy=self.parentproxy, tunnel=True) self.pskcipher = encrypt.Encryptor(self.PSK, self.method) acipher = ECC(self.pskcipher.key_len) pubk = acipher.get_pub_key() logger.debug('hxsocks send key exchange request') ts = struct.pack('>I', int(time.time())) padding_len = random.randint(64, 255) data = chr(10) + ts + chr(len(pubk)) + pubk + hmac.new(psw.encode(), ts + pubk + usn.encode(), hashlib.sha256).digest()\ + chr(padding_len) + b'\x00' * padding_len self._sock.sendall(self.pskcipher.encrypt(data)) fp = self._sock.makefile('rb', 0) resp_len = 1 if self.pskcipher.decipher else self.pskcipher.iv_len + 1 resp = ord(self.pskcipher.decrypt(fp.read(resp_len))) if resp == 0: logger.debug('hxsocks read key exchange respond') pklen = ord(self.pskcipher.decrypt(fp.read(1))) server_key = self.pskcipher.decrypt(fp.read(pklen)) auth = self.pskcipher.decrypt(fp.read(32)) pklen = ord(self.pskcipher.decrypt(fp.read(1))) server_cert = self.pskcipher.decrypt(fp.read(pklen)) sig_len = ord(self.pskcipher.decrypt(fp.read(1))) signature = self.pskcipher.decrypt(fp.read(sig_len)) pad_len = ord(self.pskcipher.decrypt(fp.read(1))) self.pskcipher.decrypt(fp.read(pad_len)) # TODO: ask user if a certificate should be accepted or not. if host not in known_hosts: logger.info('hxs: server %s new cert %s saved.' % (host, hashlib.sha256(server_cert).hexdigest()[:8])) with open('./.hxs_known_hosts/' + host + '.cert', 'wb') as f: f.write(server_cert) known_hosts[host] = server_cert elif known_hosts[host] != server_cert: logger.error('hxs: server %s certificate mismatch! PLEASE CHECK!' % host) raise OSError(0, 'hxs: bad certificate') if auth == hmac.new(psw.encode(), pubk + server_key + usn.encode(), hashlib.sha256).digest(): if ECC.verify_with_pub_key(server_cert, auth, signature, self.hash_algo): shared_secret = acipher.get_dh_key(server_key) keys[self.serverid] = (hashlib.md5(pubk).digest(), shared_secret) self.cipher = encrypt.AEncryptor(keys[self.serverid][1], self.method, SALT, CTX, 0) logger.debug('hxs key exchange success') return else: logger.error('hxs getKey Error: server auth failed, bad signature') else: logger.error('hxs getKey Error: server auth failed, bad username or password') else: fp.read(ord(self.pskcipher.decrypt(fp.read(1)))) logger.error('hxs getKey Error. bad password or timestamp.') else: raise IOError(0, 'hxs getKey Error') else: self.cipher = encrypt.AEncryptor(keys[self.serverid][1], self.method, SALT, CTX, 0)
def getchannelbyid(channel_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute("SELECT `channel_name`, `oldchannel_name`, `ticker`, `is_bittrex` FROM `channels` WHERE `is_enable` = 1 AND `id` = "+str(channel_id)) ch = cursor.fetchone() connection.close() return ch
def get_by_id(self, id): conn = connection.create_connection() c = conn.cursor() c.execute('''SELECT * FROM TODO WHERE id =?''', (id, )) print(c.fetchall()) c.close() conn.close()
def get_all(self): conn = connection.create_connection() c = conn.cursor() c.execute('''SELECT * FROM TODO''') print(c.fetchall()) c.close() conn.close()
def tcp_dns_record(host, qtype, server, proxy, timeout=2): logger.debug('entering tcp_dns_record(%s, %s, %s)' % (host, server, proxy)) if isinstance(qtype, str): query = dnslib.DNSRecord.question(host, qtype=qtype) else: query = dnslib.DNSRecord(q=dnslib.DNSQuestion(host, qtype)) query_data = query.pack() exp = None for _ in range(2): try: sock = create_connection(server, ctimeout=3, parentproxy=proxy, tunnel=True) data = struct.pack('>h', len(query_data)) + query_data sock.sendall(bytes(data)) sock.settimeout(timeout) rfile = sock.makefile('rb') reply_data_length = rfile.read(2) reply_data = rfile.read(struct.unpack('>h', reply_data_length)[0]) record = dnslib.DNSRecord.parse(reply_data) sock.close() return record except Exception as e: exp = e if exp: raise exp
def main(): options, args = parseCmdLineOpt() config_file = options.configFile config = readConfig(config_file) channel = create_connection(config) #produce_msg(channel, "FRED") consume_msg(channel)
def get_location(self): if time.time() - self.last_ckeck < 60: return ip = ip_address(socket.getaddrinfo(self.parse.hostname, 0)[0][4][0]) if ip.is_loopback or ip.is_private: from connection import create_connection from httputil import read_reaponse_line, read_headers try: soc = create_connection(('bot.whatismyipaddress.com', 80), ctimeout=None, parentproxy=self, via=self.via) soc.sendall(b'GET / HTTP/1.1\r\nConnection: close\r\nHost: bot.whatismyipaddress.com\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0\r\n\r\n') f = soc.makefile() line, version, status, reason = read_reaponse_line(f) _, headers = read_headers(f) assert status == 200 ip = soc.recv(int(headers['Content-Length'])) if not ip: soc.close() raise ValueError('%s: ip address is empty' % self.name) self.country_code = ip_to_country_code(ip) soc.close() except Exception: sys.stderr.write(traceback.format_exc()) sys.stderr.flush() self.country_code = None else: self.country_code = ip_to_country_code(ip) self.last_ckeck = time.time()
def get_location(self): if time.time() - self.last_ckeck < 60: return ip = ip_address(socket.getaddrinfo(self.parse.hostname, 0)[0][4][0]) if ip.is_loopback or ip.is_private: from connection import create_connection from httputil import read_reaponse_line, read_headers try: soc = create_connection(('bot.whatismyipaddress.com', 80), ctimeout=None, parentproxy=self) soc.sendall( b'GET / HTTP/1.1\r\nConnection: close\r\nHost: bot.whatismyipaddress.com\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0\r\n\r\n' ) f = soc.makefile() line, version, status, reason = read_reaponse_line(f) _, headers = read_headers(f) assert status == 200 ip = soc.recv(int(headers['Content-Length'])) if not ip: soc.close() raise ValueError('%s: ip address is empty' % self.name) self.country_code = ip_to_country_code(ip) soc.close() except Exception: sys.stderr.write(traceback.format_exc()) sys.stderr.flush() self.country_code = None else: self.country_code = ip_to_country_code(ip) self.last_ckeck = time.time()
def get_location(self): if self.country_code: return self.country_code if time.time() - self.last_ckeck < 300: return self.country_code try: self.last_ckeck = time.time() ip = ip_address(socket.getaddrinfo(self.parse.hostname, 0)[0][4][0]) if ip.is_loopback or ip.is_private: from connection import create_connection from httputil import read_response_line, read_headers try: soc = create_connection(('bot.whatismyipaddress.com', 80), ctimeout=None, parentproxy=self) soc.sendall(b'GET / HTTP/1.1\r\nConnection: keep_alive\r\nHost: bot.whatismyipaddress.com\r\nAccept-Encoding: identity\r\nUser-Agent: Python-urllib/2.7\r\n\r\n') f = soc.makefile() line, version, status, reason = read_response_line(f) _, headers = read_headers(f) assert status == 200 ip = soc.recv(int(headers['Content-Length'])) if not ip: soc.close() raise ValueError('%s: ip address is empty' % self.name) self.country_code = ip_to_country_code(ip) soc.close() except Exception: sys.stderr.write(traceback.format_exc()) sys.stderr.flush() self.country_code = None else: self.country_code = ip_to_country_code(ip) finally: return self.country_code
def generatingReport(): # connect withe the myTable database connection = create_connection() # Creating a cursor object using the cursor() method cursor = connection.cursor() # execute the command to fetch all the data from the table emp cursor.execute( "Select p.product_name, MIN(year) || '-' || MAX(year) as yearRange, MIN(amount), MAX(amount), AVG(amount) " "FROM product p JOIN sale s " "WHERE s.product_id = p.product_id " "GROUP BY CAST ((year/5) AS INT), p.product_name " "Order by product_name, yearRange desc ") # store all the fetched data in the ans variable query = cursor.fetchall() df = pd.DataFrame(query, columns=['Product', 'Year', 'Min', 'Max', 'Avg']) print(df) # Since we have already selected all the data entries # using the "SELECT *" SQL command and stored them in # the ans variable, all we need to do now is to print # out the ans variable return query cursor.close() connection.close()
def del_from_db(task): values = [task.name, task.desc] conn = connection.create_connection() c = conn.cursor() c.execute('''DELETE FROM TODO WHERE name =?''', (task.name, )) conn.commit() c.close() conn.close()
def insert_into_db(new_task): values = [new_task.name, new_task.desc] conn = connection.create_connection() c = conn.cursor() c.execute('''INSERT INTO TODO(name,description) VALUES(?,?)''', values) conn.commit() c.close() conn.close()
def is_settings(chat_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute("SELECT `user_id` FROM `risk_settings` WHERE `user_id` = " + str(chat_id)) settings = cursor.fetchone() connection.close() return settings
def contacts(self) -> List[Contact]: """Return ALL contacts for user""" with create_connection() as connection: contacts = get_contacts(connection, self.id) return [ Contact(contact[1], contact[2], contact[3], contact[4], contact[0]) for contact in contacts ]
def _connect(self): self.connected = 0 self.getKey() if self._sock is None: from connection import create_connection host, port = self.hxsServer.hostname, self.hxsServer.port self._sock = create_connection((host, port), self.timeout, parentproxy=self.parentproxy, tunnel=True) self.pskcipher = encrypt.Encryptor(self.PSK, self.method)
def setbroadcastmessages_sended(message_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) sql = "UPDATE `broadcasting_msg` SET `is_sended`=1, `changed` = NOW() WHERE `id` = " + str( message_id) cursor = connection.cursor() cursor.execute(sql) connection.commit() connection.close()
def setCustomMsg(msg): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) sql = "UPDATE `messages` SET `custom_message`='"+str(msg)+"'" cursor = connection.cursor() cursor.execute(sql) connection.commit() cursor.close() connection.close()
def connect(self, address): self.__address = address sshost, ssport, ssmethod, sspassword = (self.ssServer.hostname, self.ssServer.port, self.ssServer.username.lower(), self.ssServer.password) from connection import create_connection if ssmethod.endswith('-auth'): self.__ota = True ssmethod = ssmethod[:-5] self._sock = create_connection((sshost, ssport), self.timeout, parentproxy=self.parentproxy, tunnel=True) self.crypto = encrypt.Encryptor(sspassword, ssmethod)
def update_db_element(old_task, new_task): conn = connection.create_connection() c = conn.cursor() id = c.execute( '''UPDATE TODO SET name= ?, description = ? WHERE name = ? and description = ?''', (new_task.name, new_task.desc, old_task.name, old_task.desc)) c.commit() c.close() conn.close()
def del_order(orderId): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) sql = "DELETE FROM `orders` WHERE `orderId` = '" + str(orderId) + "'" cursor.execute(sql) cursor = connection.cursor() connection.commit() cursor.close() connection.close()
def get_order(channel_id, orderId): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute( "SELECT `ticker`,`exchange`, `last_active`, `orderId`, `quantity` FROM `orders` WHERE `channel_id` =" + str(channel_id) + " AND `orderId` = '" + str(orderId) + "'") order = cursor.fetchone() connection.close() return order
def DemoOff(user_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) sql = "UPDATE `users` SET `is_demo`= 0 WHERE `tm_id` = " + str(user_id) cursor.execute(sql) cursor = connection.cursor() connection.commit() cursor.close() connection.close()
def getbroadcastmsgbyid(message_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute("SELECT `message` FROM `broadcasting_msg` WHERE `id` = " + str(message_id)) message = cursor.fetchone() connection.close() return message
def getticker_channel(channel_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute( "SELECT `ticker` FROM `channels` WHERE `is_enable` = 1 AND `id` = " + str(channel_id)) ticker = cursor.fetchone() connection.close() return ticker
def getCustomMsg(): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute("SELECT `custom_message` FROM `messages`") msg = cursor.fetchone() connection.close() if msg: return msg['custom_message'] return False
def getDisableUsers(): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute("SELECT count(*) as count FROM `users` TIME_TO_SEC(TIMEDIFF(NOW(), `last_active`))/3600 > 5 AND `is_enable` = 1") count = cursor.fetchone() connection.close() if count: return count['count'] return False
def get_take_profit(user_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute( "SELECT `take_profit` FROM `risk_settings` WHERE `user_id` = " + str(user_id)) data = cursor.fetchone() connection.close() return float(data['take_profit'])
def get_spread_percent(user_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute( "SELECT `spread_per` FROM `risk_settings` WHERE `user_id` = " + str(user_id)) data = cursor.fetchone() connection.close() return data['spread_per']
def get_position_size(user_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute( "SELECT `pos_size_amount`,`pos_size_per` FROM `risk_settings` WHERE `user_id` = " + str(user_id)) data = cursor.fetchone() connection.close() return data
def cancel_order(orderId): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) sql = "UPDATE `orders` SET `isCanceled`=1,`last_active`=NOW() WHERE `orderId` = '" + str( orderId) + "'" cursor.execute(sql) cursor = connection.cursor() connection.commit() cursor.close() connection.close()
def menu(): """Contact Book User Interface""" with create_connection() as connection: create_tables(connection) while (selection := input(MENU_PROMPT)) != "11": try: MENU_OPTIONS[selection]() except KeyError: print("Invalid selection, please try again.\n")
def getbittrexapi(user_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute("SELECT `bittrex_api` FROM `admins` WHERE `tm_id` = "+str(user_id)) api = cursor.fetchone() connection.close() if api: return api return None
def getTotalUsers(): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute("SELECT count(*) as count FROM `users`") count = cursor.fetchone() connection.close() if count: return count['count'] return False
def change_channelname(channel_id, newchannel_name): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute("SELECT `channel_name` FROM `channels` WHERE `id` = "+str(channel_id)) ch = cursor.fetchone() sql = "UPDATE `channels` SET `channel_name`= '"+newchannel_name+"', `oldchannel_name` = '"+ch['channel_name']+"' WHERE `id` = "+str(channel_id) cursor = connection.cursor() cursor.execute(sql) connection.commit() connection.close()
def enable_channelsql(channel_id, user_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) sql = "UPDATE `using_channels` SET `is_enable`= 1 WHERE `channel_id` = " + str( channel_id) + " AND `user_id` = " + str(user_id) print(sql) cursor = connection.cursor() cursor.execute(sql) connection.commit() connection.close()
def existing_user(user_id): connection = create_connection() cursor = connection.cursor(pymysql.cursors.DictCursor) cursor.execute("SELECT `tm_id` FROM `users` WHERE `tm_id` = " + str(user_id)) user_id = cursor.fetchone() connection.close() if user_id: return True return False
def tcp_dns_record(host, qtype, server, proxy): if isinstance(qtype, str): query = dnslib.DNSRecord.question(host, qtype=qtype) else: query = dnslib.DNSRecord(q=dnslib.DNSQuestion(host, qtype)) query_data = query.pack() sock = create_connection(server, ctimeout=5, parentproxy=proxy, tunnel=True) data = struct.pack(">h", len(query_data)) + query_data sock.sendall(bytes(data)) sock.settimeout(5) rfile = sock.makefile("rb") reply_data_length = rfile.read(2) reply_data = rfile.read(struct.unpack(">h", reply_data_length)[0]) record = dnslib.DNSRecord.parse(reply_data) sock.close() return record
def tcp_dns_record(host, proxy, server=('8.8.8.8', 53), qtype='ANY'): for _ in range(2): try: sock = create_connection(server, ctimeout=5, parentproxy=proxy, tunnel=True) query = dnslib.DNSRecord.question(host, qtype) query_data = query.pack() sock.send(struct.pack('>h', len(query_data)) + query_data) rfile = sock.makefile('rb') reply_data_length = rfile.read(2) reply_data = rfile.read(struct.unpack('>h', reply_data_length)[0]) record = dnslib.DNSRecord.parse(reply_data) sock.close() return record except Exception as e: logger.warning('tcp_dns_record %s failed. %r' % (host, e)) traceback.print_exc(file=sys.stderr) sys.stderr.flush() raise IOError(0, 'tcp_dns_record %s failed.' % host)
def connect(self, address): self._address = address self.getKey() if self._sock is None: from connection import create_connection host, port = self.hxsServer.hostname, self.hxsServer.port self._sock = create_connection((host, port), self.timeout, parentproxy=self.parentproxy, tunnel=True) self.pskcipher = encrypt.Encryptor(self.PSK, self.method) self._rfile = self._sock.makefile('rb') self._header_sent = False self._header_received = False logger.debug('hxsocks send connect request') padding_len = random.randint(64, 255) pt = b''.join([struct.pack('>I', int(time.time())), chr(len(self._address[0])).encode('latin1'), self._address[0].encode(), struct.pack('>H', self._address[1]), b'\x00' * padding_len]) ct, mac = self.cipher.encrypt(pt) self._sock_sendall(self.pskcipher.encrypt(b''.join([chr(11).encode(), keys[self.serverid][0], struct.pack('>H', len(ct))])) + ct + mac) resp_len = 2 if self.pskcipher.decipher else self.pskcipher.iv_len + 2 data = self._rfile_read(resp_len) if not data: raise IOError(0, 'hxsocks Error: connection closed.') resp_len = self.pskcipher.decrypt(data) resp_len = struct.unpack('>H', resp_len)[0] resp = self.pskcipher.decrypt(self._rfile_read(resp_len)) d = byte2int(resp) if resp else None if d == 0: logger.debug('hxsocks connected') self.readable = 1 self.writeable = 1 return elif d == 2: raise IOError(0, 'hxsocks Error: remote connect timed out. code 2') else: if self.serverid in keys: del keys[self.serverid] raise IOError(0, 'hxsocks Error: invalid shared key. code %d' % d)
def get_location(self): if time.time() - self.last_ckeck < 60: return from connection import create_connection from httputil import read_reaponse_line, read_headers try: soc = create_connection(('bot.whatismyipaddress.com', 80), ctimeout=None, parentproxy=self, via=self.via) soc.sendall(b'GET / HTTP/1.0\r\nHost: bot.whatismyipaddress.com\r\n\r\n') f = soc.makefile() line, version, status, reason = read_reaponse_line(f) _, headers = read_headers(f) assert status == 200 ip = soc.recv(int(headers['Content-Length'])) if not ip: soc.close() raise ValueError('%s: ip address is empty' % self.name) self.country_code = ip_to_country_code(ip) soc.close() except Exception as e: sys.stderr.write(traceback.format_exc()) sys.stderr.flush() self.country_code = None self.last_ckeck = time.time()
def handle(self): logger.info('tcp forward from %s(local) to %s(remote) via %s' % (self.server.addr, self.server.target, self.server.proxy)) self.remotesoc = create_connection(self.server.target, ctimeout=5, parentproxy=self.server.proxy, tunnel=True) try: fd = [self.connection, self.remotesoc] while fd: ins, _, _ = select.select(fd, [], [], 60) if not ins: break if self.connection in ins: data = self.connection.recv(self.bufsize) if data: self.remotesoc.sendall(data) else: fd.remove(self.connection) self.remotesoc.shutdown(socket.SHUT_WR) if self.remotesoc in ins: data = self.remotesoc.recv(self.bufsize) if data: self.wfile.write(data) else: fd.remove(self.remotesoc) self.connection.shutdown(socket.SHUT_WR) except socket.timeout: pass except (IOError, OSError) as e: if e.args[0] not in (errno.ECONNABORTED, errno.ECONNRESET, errno.ENOTCONN, errno.EPIPE): raise if e.args[0] in (errno.EBADF,): return finally: for sock in [self.connection, self.remotesoc]: try: sock.close() except (IOError, OSError): pass
def main(): document = None page_num = 0 options, args = parseCmdLineOpt() config_file = options.configFile config = readConfig(config_file) channel = create_connection(config) documents = [] scanner = init_scanner(config) for output, image_bar in start_scanning(scanner): for symbol in image_bar: logger.debug("symbol %s" % symbol.data) for clef, valeur in config.items("type"): if re.match(valeur, symbol.data): page_num = 0 logger.debug("new document detected") document = Document() logger.debug(document) document.name = symbol.data document.genre = clef documents.append(document) break if re.match(("^%s.*" % config.get("workflow", "key")), symbol.data): document.workflows.append(symbol.data) page_num += 1 if document is not None: filename = "%s_%s.tiff" % (document.name, str(page_num)) else: document = Document() filename = "undefined_%s_%s.tiff" % (datetime.today().strftime("%Y%m%d-%H%M%S"), str(page_num)) document.name = "undefined_%s" % datetime.today().strftime("%Y%m%d-%H%M%S") documents.append(document) filepath = os.path.join(config.get("output", "tmp_dir"), filename) output.save(filepath, 'TIFF') document.files.append(filepath) for symbol in image_bar: document.barcodes.append(symbol.data) print str(document) ocr = Ocr() ocr.bin_path = config.get("ocr","ocr_bin") ocr.input_image = filepath ocr.parse() document.ocr.append(ocr.content) if config.get("scanner", "interactive") == "True": input_cmd = raw_input("press enter to scan the next document or 'quit' to leave ") if input_cmd == "quit": break for document in documents: logger.debug("documents : %s" % documents) logger.debug("document : %s" % document) old_files = document.files logger.debug(" old_files :") logger.debug(old_files) document.files = [] file_format = config.get("output", "file_format") for image in old_files: logger.debug(" image : %s" % image) document.files.append(convert_file(image,file_format)) if file_format == "PDF": new_file = merge_files(document.files,file_format) document.files = [new_file] logger.debug("we gonna produce a new message in the queue for %s" % document) produce_msg_document(channel, document, config.get("queues", "documents"))
def connect(self, address): self.__address = address sshost, ssport, ssmethod, sspassword = (self.ssServer.hostname, self.ssServer.port, self.ssServer.username, self.ssServer.password) from connection import create_connection self._sock = create_connection((sshost, ssport), self.timeout, parentproxy=self.parentproxy, tunnel=True) self.crypto = encrypt.Encryptor(sspassword, ssmethod)
def _connect_via_proxy(self, netloc, iplist=None, tunnel=False): self.on_conn_log() return create_connection(netloc, ctimeout=self.ctimeout, iplist=iplist, parentproxy=self.pproxy, tunnel=tunnel)