feat&fix: add proxy support in setup and remove hardcoded proxy from example
This commit is contained in:
@@ -47,11 +47,12 @@ class SetupController:
|
||||
self.http_server: str = f"http://{vm_ip}:{server_port}"
|
||||
self.http_server_setup_root: str = f"http://{vm_ip}:{server_port}/setup"
|
||||
self.cache_dir: str = cache_dir
|
||||
self.use_proxy: bool = False
|
||||
|
||||
def reset_cache_dir(self, cache_dir: str):
|
||||
self.cache_dir = cache_dir
|
||||
|
||||
def setup(self, config: List[Dict[str, Any]])-> bool:
|
||||
def setup(self, config: List[Dict[str, Any]], use_proxy: bool = False)-> bool:
|
||||
"""
|
||||
Args:
|
||||
config (List[Dict[str, Any]]): list of dict like {str: Any}. each
|
||||
@@ -63,6 +64,7 @@ class SetupController:
|
||||
parameters
|
||||
}
|
||||
"""
|
||||
self.use_proxy = use_proxy
|
||||
# make sure connection can be established
|
||||
logger.info(f"try to connect {self.http_server}")
|
||||
retry = 0
|
||||
@@ -237,6 +239,9 @@ class SetupController:
|
||||
if not shell and isinstance(command, str) and len(command.split()) > 1:
|
||||
logger.warning("Command should be a list of strings. Now it is a string. Will split it by space.")
|
||||
command = command.split()
|
||||
|
||||
if command[0] == "google-chrome" and self.use_proxy:
|
||||
command.append("--proxy-server=http://127.0.0.1:18888") # Use the proxy server set up by _proxy_setup
|
||||
|
||||
payload = json.dumps({"command": command, "shell": shell})
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
Reference in New Issue
Block a user