|
|
@@ -20,10 +20,11 @@ from cryptography.hazmat.primitives import serialization, hashes
|
|
|
from cryptography.hazmat.primitives.asymmetric import padding
|
|
|
from cryptography.hazmat.backends import default_backend
|
|
|
|
|
|
+import configure
|
|
|
from vs_plg import IVSPlg
|
|
|
from vs_types import VSPlgConfig, AppointmentType, VSQueryResult, VSBookResult, DateAvailability, AvailabilityStatus, NotFoundError, PermissionDeniedError, RateLimiteddError, SessionExpiredOrInvalidError, BizLogicError
|
|
|
from toolkit.vs_cloud_api import VSCloudApi
|
|
|
-from toolkit.proxy_tunnel import ProxyTunnel
|
|
|
+from toolkit.mihomo_tunnel import MihomoTunnel
|
|
|
from utils.cloudflare_bypass_for_scraping import CloudflareBypasser
|
|
|
|
|
|
|
|
|
@@ -217,20 +218,37 @@ class VfsPlugin(IVSPlg):
|
|
|
co.set_local_port(debug_port)
|
|
|
co.set_user_data_path(self.user_data_path)
|
|
|
|
|
|
- chrome_path = os.getenv("CHROME_BIN")
|
|
|
+ chrome_path = configure.CHROME_PATH
|
|
|
+ if not chrome_path:
|
|
|
+ chrome_path = os.getenv("CHROME_BIN")
|
|
|
if chrome_path and os.path.exists(chrome_path):
|
|
|
co.set_paths(browser_path=chrome_path)
|
|
|
|
|
|
if self.config.proxy and self.config.proxy.ip:
|
|
|
p = self.config.proxy
|
|
|
-
|
|
|
+ self._log(f'Current proxy id={p.id}')
|
|
|
if p.username and p.password:
|
|
|
self._log(f"Starting Proxy Tunnel for {p.ip}...")
|
|
|
- self.tunnel = ProxyTunnel(p.ip, p.port, p.username, p.password)
|
|
|
+ exit_node = {
|
|
|
+ "name": "ExitNode",
|
|
|
+ "type": p.proto,
|
|
|
+ "server": p.ip,
|
|
|
+ "port": p.port,
|
|
|
+ "username": p.username,
|
|
|
+ "password": p.password
|
|
|
+ }
|
|
|
+ relay_node = None
|
|
|
+ if configure.MIHOMO_RELAY_NODES:
|
|
|
+ relay_node = random.choice(configure.MIHOMO_RELAY_NODES)
|
|
|
+ mihomo_path = configure.MIHOMO_BIN_PATH
|
|
|
+ if not mihomo_path:
|
|
|
+ mihomo_path = os.getenv("MIHOMO_BIN")
|
|
|
+ if not mihomo_path:
|
|
|
+ raise BizLogicError(message='Mihomo path is null, You need set mihomo bin path in configure or os env')
|
|
|
+ self.tunnel = MihomoTunnel(mihomo_path, exit_node=exit_node, relay_node=relay_node)
|
|
|
local_proxy = self.tunnel.start()
|
|
|
self._log(f"Tunnel started at {local_proxy}")
|
|
|
co.set_argument(f'--proxy-server={local_proxy}')
|
|
|
-
|
|
|
else:
|
|
|
proxy_str = f"{p.proto}://{p.ip}:{p.port}"
|
|
|
co.set_argument(f'--proxy-server={proxy_str}')
|
|
|
@@ -239,7 +257,7 @@ class VfsPlugin(IVSPlg):
|
|
|
|
|
|
co.headless(False)
|
|
|
co.set_argument('--no-sandbox')
|
|
|
- # co.set_argument('--disable-gpu')
|
|
|
+ co.set_argument('--disable-gpu')
|
|
|
co.set_argument('--disable-dev-shm-usage')
|
|
|
co.set_argument('--window-size=1920,1080')
|
|
|
co.set_argument('--disable-blink-features=AutomationControlled')
|