Browse Source

fix(driver): expose native-host option and set default to 127.0.0.1 (#3816)

pwespi 3 năm trước cách đây
mục cha
commit
cd9dfc7b9a

+ 5 - 0
.changes/webdriver-native-host.md

@@ -0,0 +1,5 @@
+---
+"tauri-driver": patch
+---
+
+Expose `native-host` option in tauri-driver and set default to `127.0.0.1`.

+ 3 - 0
tooling/webdriver/src/cli.rs

@@ -13,6 +13,7 @@ FLAGS:
 OPTIONS:
   --port NUMBER           Sets the tauri-driver intermediary port
   --native-port NUMBER    Sets the port of the underlying WebDriver
+  --native-host HOST      Sets the host of the underlying WebDriver (Linux only)
   --native-driver PATH    Sets the path to the native WebDriver binary
 ";
 
@@ -20,6 +21,7 @@ OPTIONS:
 pub struct Args {
   pub port: u16,
   pub native_port: u16,
+  pub native_host: String,
   pub native_driver: Option<PathBuf>,
 }
 
@@ -42,6 +44,7 @@ impl From<pico_args::Arguments> for Args {
     let parsed = Args {
       port: args.value_from_str("--port").unwrap_or(4444),
       native_port: args.value_from_str("--native-port").unwrap_or(4445),
+      native_host: args.value_from_str("--native-host").unwrap_or(String::from("127.0.0.1")),
       native_driver,
     };
 

+ 1 - 0
tooling/webdriver/src/webdriver.rs

@@ -47,5 +47,6 @@ pub fn native(args: &Args) -> Command {
   let mut cmd = Command::new(native_binary);
   cmd.env("TAURI_AUTOMATION", "true");
   cmd.arg(format!("--port={}", args.native_port));
+  cmd.arg(format!("--host={}", args.native_host));
   cmd
 }