feat(stealth): 默认开启并收敛 chrome 指纹特征

This commit is contained in:
leeguooooo
2026-02-24 14:54:30 +09:00
parent c5b2292caa
commit 0443e4ed7a
12 changed files with 29 additions and 76 deletions
-2
View File
@@ -1923,10 +1923,8 @@ mod tests {
cli_proxy_bypass: false,
cli_allow_file_access: false,
cli_annotate: false,
cli_stealth: false,
annotate: false,
color_scheme: None,
stealth: false,
}
}
+2 -3
View File
@@ -220,7 +220,6 @@ pub fn ensure_daemon(
provider: Option<&str>,
device: Option<&str>,
session_name: Option<&str>,
stealth: bool,
debug: bool,
) -> Result<DaemonResult, String> {
// Check if daemon is running AND responsive
@@ -366,7 +365,7 @@ pub fn ensure_daemon(
cmd.env("AGENT_BROWSER_SESSION_NAME", sn);
}
cmd.env("AGENT_BROWSER_STEALTH", if stealth { "1" } else { "0" });
cmd.env("AGENT_BROWSER_STEALTH", "1");
if debug {
cmd.env("AGENT_BROWSER_DEBUG", "1");
}
@@ -454,7 +453,7 @@ pub fn ensure_daemon(
cmd.env("AGENT_BROWSER_SESSION_NAME", sn);
}
cmd.env("AGENT_BROWSER_STEALTH", if stealth { "1" } else { "0" });
cmd.env("AGENT_BROWSER_STEALTH", "1");
if debug {
cmd.env("AGENT_BROWSER_DEBUG", "1");
}
-18
View File
@@ -34,7 +34,6 @@ pub struct Config {
pub headers: Option<String>,
pub annotate: Option<bool>,
pub color_scheme: Option<String>,
pub stealth: Option<bool>,
}
impl Config {
@@ -69,7 +68,6 @@ impl Config {
headers: other.headers.or(self.headers),
annotate: other.annotate.or(self.annotate),
color_scheme: other.color_scheme.or(self.color_scheme),
stealth: other.stealth.or(self.stealth),
}
}
}
@@ -204,7 +202,6 @@ pub struct Flags {
pub session_name: Option<String>,
pub annotate: bool,
pub color_scheme: Option<String>,
pub stealth: bool,
// Track which launch-time options were explicitly passed via CLI
// (as opposed to being set only via environment variables)
@@ -218,7 +215,6 @@ pub struct Flags {
pub cli_proxy_bypass: bool,
pub cli_allow_file_access: bool,
pub cli_annotate: bool,
pub cli_stealth: bool,
}
pub fn parse_flags(args: &[String]) -> Flags {
@@ -283,10 +279,6 @@ pub fn parse_flags(args: &[String]) -> Flags {
color_scheme: env::var("AGENT_BROWSER_COLOR_SCHEME")
.ok()
.or(config.color_scheme),
stealth: match env::var("AGENT_BROWSER_STEALTH") {
Ok(val) => !matches!(val.to_lowercase().as_str(), "0" | "false" | "no" | ""),
Err(_) => config.stealth.unwrap_or(true),
},
cli_executable_path: false,
cli_extensions: false,
cli_profile: false,
@@ -297,7 +289,6 @@ pub fn parse_flags(args: &[String]) -> Flags {
cli_proxy_bypass: false,
cli_allow_file_access: false,
cli_annotate: false,
cli_stealth: false,
};
let mut i = 0;
@@ -453,14 +444,6 @@ pub fn parse_flags(args: &[String]) -> Flags {
i += 1;
}
}
"--stealth" => {
let (val, consumed) = parse_bool_arg(args, i);
flags.stealth = val;
flags.cli_stealth = true;
if consumed {
i += 1;
}
}
"--color-scheme" => {
if let Some(s) = args.get(i + 1) {
flags.color_scheme = Some(s.clone());
@@ -492,7 +475,6 @@ pub fn clean_args(args: &[String]) -> Vec<String> {
"--allow-file-access",
"--auto-connect",
"--annotate",
"--stealth",
];
// Global flags that always take a value (need to skip the next arg too)
const GLOBAL_FLAGS_WITH_VALUE: &[&str] = &[
+3 -22
View File
@@ -52,14 +52,6 @@ fn parse_proxy(proxy_str: &str) -> serde_json::Value {
})
}
fn print_stealth_debug(resp: &connection::Response) {
if let Some(data) = &resp.data {
if let Some(stealth) = data.get("stealth") {
eprintln!("[DEBUG] stealth: {}", stealth);
}
}
}
fn run_session(args: &[String], session: &str, json_mode: bool) {
let subcommand = args.get(1).map(|s| s.as_str());
@@ -234,7 +226,6 @@ fn main() {
flags.provider.as_deref(),
flags.device.as_deref(),
flags.session_name.as_deref(),
flags.stealth,
flags.debug,
) {
Ok(result) => result,
@@ -291,7 +282,6 @@ fn main() {
},
flags.ignore_https_errors.then_some("--ignore-https-errors"),
flags.cli_allow_file_access.then_some("--allow-file-access"),
flags.cli_stealth.then_some("--stealth"),
]
.into_iter()
.flatten()
@@ -472,9 +462,7 @@ fn main() {
}
exit(1);
}
if flags.debug {
print_stealth_debug(&resp);
}
}
Err(e) => {
if flags.json {
@@ -512,9 +500,7 @@ fn main() {
}
exit(1);
}
if flags.debug {
print_stealth_debug(&resp);
}
}
Err(e) => {
if flags.json {
@@ -537,7 +523,6 @@ fn main() {
|| flags.user_agent.is_some()
|| flags.ignore_https_errors
|| flags.allow_file_access
|| flags.cli_stealth
|| flags.debug
|| flags.color_scheme.is_some())
&& flags.cdp.is_none()
@@ -601,8 +586,6 @@ fn main() {
launch_cmd["allowFileAccess"] = json!(true);
}
launch_cmd["stealth"] = json!(flags.stealth);
if let Some(ref cs) = flags.color_scheme {
launch_cmd["colorScheme"] = json!(cs);
}
@@ -621,9 +604,7 @@ fn main() {
}
exit(1);
}
if flags.debug {
print_stealth_debug(&resp);
}
}
Err(e) => {
if flags.json {
+1 -2
View File
@@ -2114,7 +2114,6 @@ Options:
e.g., --proxy-bypass "localhost,*.internal.com"
--ignore-https-errors Ignore HTTPS certificate errors
--allow-file-access Allow file:// URLs to access local files (Chromium only)
--stealth Stealth mode (default: on): local=launch args+init scripts, CDP/provider=init scripts
-p, --provider <name> Browser provider: ios, browserbase, kernel, browseruse
--device <name> iOS device name (e.g., "iPhone 15 Pro")
--json JSON output
@@ -2126,7 +2125,7 @@ Options:
--color-scheme <scheme> Color scheme: dark, light, no-preference (or AGENT_BROWSER_COLOR_SCHEME)
--session-name <name> Auto-save/restore session state (cookies, localStorage)
--config <path> Use a custom config file (or AGENT_BROWSER_CONFIG env)
--debug Debug output (includes stealth connection type + capabilities)
--debug Debug output
--version, -V Show version
Configuration: