def functionSelectiion(sci: ScanInfo): if sci.scantype == 'sS': pass elif sci.scantype == 'sT': ConnectedScan(sci) elif sci.scantype == 'proxy': proxy.start()
def test_single_threaded_connection_drop(self): if not is_python6_or_more(): self.skipTest("Cannot use proxy on python < 3.6") # Allocate the proxy dev = None print("Connecting through proxy...") with proxy.start([ '--num-workers', '1', '--hostname', '127.0.0.1', '--port', str(PROXY_PORT) ]): # Configure the manager client to use the proxy self.manager._cloud_client._mqtt_client.proxy_set( proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=PROXY_PORT) # Connect self.manager.start() self.assertTrue( self.manager._cloud_client.connection_status.check_status( ClientStatus.SUBSCRIBED)) # Wait a bit before closing the proxy. In the meanwhile, select a device to be used for testing. devices = self.manager.get_supported_devices() if len(devices) < 1: self.skipTest("Could not find any device to test...") dev = devices[0] status = dev.get_status(force_status_refresh=True) print("Device status: %s" % str(status)) time.sleep(5) print("Closing the proxy to trigger disconnection") print("Proxy closed") try: new_status = dev.get_status(force_status_refresh=True) raise Exception("Device was still able to reconnect.") except CommandTimeoutException: print("Device is unreachable. That's ok!") print("Reconnecting the proxy...") with proxy.start([ '--num-workers', '1', '--hostname', '127.0.0.1', '--port', str(PROXY_PORT) ]): self.manager._cloud_client.connection_status.wait_for_status( ClientStatus.SUBSCRIBED, timeout=30) new_status = dev.get_status(force_status_refresh=True) print("New device status: %s" % new_status) self.manager.stop(logout=True)
def test_multithreaded_connection_drop(self): if not is_python6_or_more(): self.skipTest("Cannot use proxy on python < 3.6") # Allocate the proxy workers = [] print("Connecting through proxy...") with proxy.start([ '--num-workers', '1', '--hostname', '127.0.0.1', '--port', str(PROXY_PORT) ]): # Configure the manager client to use the proxy self.manager._cloud_client._mqtt_client.proxy_set( proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=PROXY_PORT) # Connect self.manager.start() # Start 2 workers for every plug for p in self.manager.get_devices_by_kind(GenericPlug): w1 = TestAutoreconnect.WorkerThread(p) w2 = TestAutoreconnect.WorkerThread(p) workers.append(w1) workers.append(w2) w1.start() w2.start() print("Started workers. Waiting a bit....") time.sleep(10) print("Dropping connection...") self.manager._cloud_client.connection_status.wait_for_status( ClientStatus.CONNECTION_DROPPED, timeout=30) print("Proxy has been closed. Waiting 120 seconds to trigger timeouts") time.sleep(120) print("Establishing connection back again...") with proxy.start([ '--num-workers', '1', '--hostname', '127.0.0.1', '--port', str(PROXY_PORT) ]): print("Proxy online again. Waiting a bit...") time.sleep(10) print("Stopping workers") for w in workers: w.stop() print("Closing manager.") self.manager.stop(logout=True)
def start_proxy(port): global stop_proxy HOST = "127.0.0.1" # Standard loopback interface address (localhost) with proxy.start(["--hostname", HOST, "--port", str(port), "--num-workers", "1"]): while not stop_proxy: time.sleep(2)
def test_api_get_proxy(supply_url): with proxy.start(['--host', '127.0.0.1', '--port', '8888']): time.sleep(2) url = supply_url + "/users/1" probe = APIGetTester(url, proxy_url='http://localhost:8888') probe.run() response = probe.measured() assert response is not None assert response['data']['id'] == 1 assert response['data']['first_name'] == 'George'
import proxy if __name__ == '__main__': proxy.start('127.0.0.1', 8899, 'INFO')
if effective_work_dir is None and "TREZOR_USER_ENV_WORK_DIR" in os.environ: effective_work_dir = os.environ["TREZOR_USER_ENV_WORK_DIR"] if effective_work_dir is None: effective_work_dir = "." effective_work_dir = os.path.abspath(os.path.expanduser(effective_work_dir)) os.chdir(effective_work_dir) print("Working from {}".format(colored(os.getcwd(), "yellow"))) binaries.explore(args) if not args.disable_proxy: print("Starting proxy") proxy.start() print( "Controller with proxy running at: http://{}:{}".format( proxy.PROXY_IP, proxy.PROXY_PORT ) ) print("Starting websocket server on port: {}".format(colored(str(PORT), "cyan"))) server = WebsocketServer(PORT) server.set_fn_new_client(new_client) server.set_fn_client_left(client_left) server.set_fn_message_received(message_received) print("Websocket server running... CTRL+C to exit") server.run_forever()
browserVersion = driverManager.getBrowserVersion('chrome') client = boto3.client('sqs') userManager = UserManager(console) userAgentManager = UserAgentManager() proxyManagerListener = ProxyManager(proxyFile=PROXY_FILE_LISTENER) proxyManagerRegister = ProxyManager(proxyFile=PROXY_FILE_REGISTER) lock = Lock() stats = Stats() users = [] #Start proxy server proxy.start([], plugins=[ ProxyRedirect( 'rapempireinc2020', 'gktgfks36flx', proxyManager=ProxyManager(PROXY_FILE_LISTENER)) ]) for index in range(config.REGISTER_BATCH_COUNT): users.append( userManager.createRandomUser( proxy=proxyManagerListener.getRandomProxy(), userAgent=userAgentManager.getRandomUserAgent(), application='SP')) shutdownEvent = Event() client = boto3.client('sqs') lastQueuePolling = 0.0 while len(users) or len(processes): try:
def proxy_server(): with proxy.start([ '--hostname', '127.0.0.1', '--num-workers', '1', '--port', str(unused_port()) ]) as p: yield p