def handle(self, conn): """ handle is called by the framework to establish a new connection to the proxy server and start processing when an incoming SOCKS client connection is established. """ logging.info('handle_socks') yield readHandshake(conn) logging.error('read handshake') yield sendHandshake(conn) logging.error('send handshake') dest = (yield readRequest(conn)) # logging.error('read request: %s' % str(dest)) yield sendResponse(dest, conn) logging.error('sent response') (addr, port) = uncompact(dest) logging.error('connecting %s:%d' % (addr, port)) logging.info(addr) logging.info(port) client = Client() yield client.connect(addr, port) logging.info('connected %s:%d' % (addr, port)) self.pump = Pump(conn, client, self.transport) yield self.pump.run()
def handle_socksDust(conn): print('connection') client = Client() yield client.connect('blanu.net', 7051) coder = yield handshake(client) monocle.launch(pump, conn, client, coder.encrypt) yield pump(client, conn, coder.decrypt)
def handle_dust(conn): print('handle_dust') coder = yield handshake(conn) client = Client() yield client.connect('localhost', 9050) monocle.launch(pump, conn, client, coder.decrypt) yield pump(client, conn, coder.encrypt)
def handle_dust(conn): print('handle_dust') coder=yield handshake(conn) client = Client() yield client.connect('localhost', 9050) monocle.launch(pump, conn, client, coder.decrypt) yield pump(client, conn, coder.encrypt)
def handle_socksDust(conn): print('connection') client = Client() yield client.connect('blanu.net', 7051) coder=yield handshake(client) monocle.launch(pump, conn, client, coder.encrypt) yield pump(client, conn, coder.decrypt)
def _subproc_wrapper(port, target, *args, **kwargs): try: client = Client() while True: try: yield client.connect('127.0.0.1', port) break except Exception, e: print type(e), str(e) yield sleep(1) chan = SocketChannel(client) yield target(chan, *args, **kwargs)
def _subproc_wrapper(port, target, *args, **kwargs): try: client = Client() while True: try: yield client.connect('127.0.0.1', port) break except Exception, e: print "failed to connect to monocle multiprocess parent on port", port, type(e), str(e) yield sleep(1) chan = SocketChannel(client) yield target(chan, *args, **kwargs)
def do_echos(): try: client = Client() yield client.connect('localhost', 8000) t = time.time() for x in xrange(10000): msg = "hello, world #%s!" % x yield client.write(msg + '\r\n') echo_result = yield client.read_until("\r\n") assert echo_result.strip() == "you said: %s" % msg print '10000 loops in %.2fs' % (time.time() - t) finally: eventloop.halt()
def _subproc_wrapper(port, target, *args, **kwargs): try: client = Client() while True: try: yield client.connect('127.0.0.1', port) break except Exception, e: print "failed to connect to monocle multiprocess parent on port", port, type( e), str(e) yield sleep(1) chan = SocketChannel(client) yield target(chan, *args, **kwargs)
def handle_socks(conn): yield readHandshake(conn) yield sendHandshake(conn) dest = yield readRequest(conn) yield sendResponse(dest, conn) addr, port = uncompact(dest) print(addr) print(port) client = Client() yield client.connect(addr, port) yield handle_socksDust(conn, client)
def handle_socks(conn): yield readHandshake(conn) yield sendHandshake(conn) dest=yield readRequest(conn) yield sendResponse(dest, conn) addr, port=uncompact(dest) print(addr) print(port) client = Client() yield client.connect(addr, port) yield handle_socksDust(conn, client)
def handle_socks(conn): print('connection') yield readHandshake(conn) yield sendHandshake(conn) dest=yield readRequest(conn) yield sendResponse(dest, conn) addr, port=uncompact(dest) print(addr) print(port) client = Client() yield client.connect(addr, port) monocle.launch(pump, conn, client) yield pump(client, conn)
def main(): c = Client() """ yield c.connect('google.com', 80) yield c.write("GET / HTTP/1.0\r\n\r\n") x = None c.timeout = 0 try: x = yield c.read(40000) except Exception, e: print str(e) print x """ c.timeout = 1 yield c.connect("google.com", 80) c.timeout = 0 x = yield c.read(40000) print x
def handle(self, conn): """ handle is called by the framework to establish a new proxy connection to the Tor server and start processing when an incoming client connection is established. """ logging.error('connection') logging.error('connecting %s:%d' % (self.addr, self.port)) client = Client() try: yield client.connect(self.addr, self.port) except Exception as e: logging.error('Error connecting to destination') return try: self.pump = Pump(conn, client, self.transport) yield self.pump.run() except Exception as e: logging.error('Exception pumping') logging.error(e)
def send(dir, coin, to): try: receipt=Send(None, pub, epoch(), coin, loadPublic(to)) receipt.setPrivate(priv) receipt.sign() receipts=Receipts() receipts.load(dir+'/receipts.dat') receipts.add(receipt) smsg=json.dumps(receipt.save(True)) print('sending') client=Client() yield client.connect('localhost', 7050) yield client.write(smsg+"\n") s=yield client.read_until("\n") msg=json.loads(s) receipt=Receive() receipt.load(msg) if receipt.cmd!='receive': print('Unknown command: '+str(receipt.cmd)) return if receipt.args.save_pkcs1('DER')!=pub.save_pkcs1('DER'): print('Not me') return if not rsa.verify(str(receipt.sig), receipt.pub): print('Not verified') return cs.save(dir+'/coins.dat') receipts.add(receipt) print('saving '+str(len(receipts.receipts))) receipts.save(dir+'/receipts.dat') eventloop.halt() except Exception, e: print('Exception:') print(e) traceback.print_exc()
def handle_socks(conn): print('handle_socks') yield readHandshake(conn) print('read handshake') yield sendHandshake(conn) print('send handshake') dest=yield readRequest(conn) print('read request: '+str(dest)) yield sendResponse(dest, conn) print('sent response') addr, port=uncompact(dest) print(addr) print(port) client = Client() yield client.connect(addr, port) print('connected '+str(addr)+', '+str(port)) monocle.launch(pump, conn, client, None) yield pump(client, conn, None)
def handle_socks(conn): print('handle_socks') yield readHandshake(conn) print('read handshake') yield sendHandshake(conn) print('send handshake') dest = yield readRequest(conn) print('read request: ' + str(dest)) yield sendResponse(dest, conn) print('sent response') addr, port = uncompact(dest) print(addr) print(port) client = Client() yield client.connect(addr, port) print('connected ' + str(addr) + ', ' + str(port)) monocle.launch(pump, conn, client, None) yield pump(client, conn, None)
def do_echos(): try: client = Client() yield client.connect('localhost', 8000) t = time.time() for x in xrange(10000): msg = "hello, world #%s!" % x yield client.write(msg + '\r\n') echo_result = yield client.read_until("\r\n") assert echo_result.strip() == "you said: %s" % msg print('10000 loops in %.2fs' % (time.time() - t)) finally: client.close()
def test_lots_of_messages(): add_service(Service(handle_echo, port=8000)) try: client = Client() yield client.connect('localhost', 8000) t = time.time() for x in xrange(10000): msg = "hello, world #%s!" % x yield client.write(msg + '\r\n') echo_result = yield client.read_until("\r\n") assert echo_result.strip() == "you said: %s" % msg print '10000 loops in %.2fs' % (time.time() - t) finally: client.close()
def connect(self, host, port, scheme='http', timeout=None): if timeout is not None: # this parameter is deprecated self.timeout = None if self.client and not self.client.is_closed(): self.client.close() if scheme == 'http': self.client = Client() elif scheme == 'https': self.client = SSLClient() else: raise HttpException('unsupported url scheme %s' % scheme) self.scheme = scheme self.host = host self.port = port self.client.timeout = self._timeout yield self.client.connect(self.host, self.port)
def main(): c = Client() """ yield c.connect('google.com', 80) yield c.write("GET / HTTP/1.0\r\n\r\n") x = None c.timeout = 0 try: x = yield c.read(40000) except Exception, e: print str(e) print x """ c.timeout = 1 yield c.connect('google.com', 80) yield c.write("GET / HTTP/1.0\r\n\r\n") c.timeout = 0 x = yield c.read(40000) print(x) eventloop.halt()
def handle_socks(conn): client = Client() yield client.connect('localhost', 8050) monocle.launch(pump, conn, client) yield pump(client, conn)
def proxy(conn): client = Client() yield client.connect(backend_host, backend_port) monocle.launch(make_pumper("client"), conn, client) pumper = make_pumper("server") yield pumper(client, conn)
def main(): c = Client() yield c.connect('google.com', 80) c.close() yield c.connect('google.com', 80, timeout=0)