1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Browser profile configuration
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
fn default_true() -> Option<bool> {
Some(true)
}
/// Proxy configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProxyConfig {
/// Proxy server URL
pub server: String,
/// Bypass list for proxy
pub bypass: Option<String>,
/// Username for proxy authentication
pub username: Option<String>,
/// Password for proxy authentication
pub password: Option<String>,
}
/// Browser profile configuration (streamlined, single source of truth)
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct BrowserProfile {
/// Whether to run browser in headless mode (defaults to true)
#[serde(default = "default_true")]
pub headless: Option<bool>,
/// Path to user data directory
pub user_data_dir: Option<PathBuf>,
/// List of allowed domains
pub allowed_domains: Option<Vec<String>>,
/// Path to downloads directory
pub downloads_path: Option<PathBuf>,
/// Proxy configuration (for enterprise use)
#[serde(skip_serializing_if = "Option::is_none")]
pub proxy: Option<ProxyConfig>,
/// Enable stealth mode to hide automation fingerprints
#[serde(default)]
pub stealth: bool,
/// Custom user agent string (rotated if multiple provided)
pub user_agent: Option<String>,
}
impl BrowserProfile {
/// Create a new BrowserProfile with default settings
pub fn new() -> Self {
Self::default()
}
/// Set headless mode
pub fn with_headless(mut self, headless: bool) -> Self {
self.headless = Some(headless);
self
}
/// Set user data directory
pub fn with_user_data_dir(mut self, dir: PathBuf) -> Self {
self.user_data_dir = Some(dir);
self
}
/// Set proxy configuration
pub fn with_proxy(mut self, proxy: ProxyConfig) -> Self {
self.proxy = Some(proxy);
self
}
/// Enable stealth mode
pub fn with_stealth(mut self, stealth: bool) -> Self {
self.stealth = stealth;
self
}
/// Set custom user agent
pub fn with_user_agent(mut self, ua: impl Into<String>) -> Self {
self.user_agent = Some(ua.into());
self
}
}