use boring::ssl::SslVersion;
use crate::profile::{
ChromeProfile, HeaderProfile, HeadersPriority, Http2Profile, Platform, PseudoOrder,
SettingsFrame, TlsProfile,
};
pub const JA3_HASH: &str = "845db3b4e398789bdeb5b15594360a29";
pub const JA3N_HASH: &str = "8e19337e7524d2573be54efb2b0784c9";
pub const JA4: &str = "t13d1516h2_8daaf6152771_d8a2da3f94cd";
pub const AKAMAI_FINGERPRINT: &str = "1:65536;2:0;4:6291456;6:262144|15663105|0|m,a,s,p";
const ALPS_EXTRA_SETTINGS_WIN_LINUX: &[(u16, u32)] = &[(0x7A9A, 0xE3590A45)];
const ALPS_EXTRA_SETTINGS_MACOS: &[(u16, u32)] = &[];
const CIPHER_LIST: &str = concat!(
"TLS_AES_128_GCM_SHA256:",
"TLS_AES_256_GCM_SHA384:",
"TLS_CHACHA20_POLY1305_SHA256:",
"ECDHE-ECDSA-AES128-GCM-SHA256:",
"ECDHE-RSA-AES128-GCM-SHA256:",
"ECDHE-ECDSA-AES256-GCM-SHA384:",
"ECDHE-RSA-AES256-GCM-SHA384:",
"ECDHE-ECDSA-CHACHA20-POLY1305:",
"ECDHE-RSA-CHACHA20-POLY1305:",
"ECDHE-RSA-AES128-SHA:",
"ECDHE-RSA-AES256-SHA:",
"AES128-GCM-SHA256:",
"AES256-GCM-SHA384:",
"AES128-SHA:",
"AES256-SHA"
);
const CURVES: &[u16] = &[4588, 29, 23, 24];
const ALPN_H2: &[u8] = b"h2";
const ALPN_HTTP_11: &[u8] = b"http/1.1";
const ALPN_PROTOCOLS: &[&[u8]] = &[ALPN_H2, ALPN_HTTP_11];
const SIGALGS: &[u16] = &[
0x0403, 0x0804, 0x0401, 0x0503, 0x0805, 0x0501, 0x0806, 0x0601, ];
const PSEUDO_ORDER: [PseudoOrder; 4] = [
PseudoOrder::Method,
PseudoOrder::Authority,
PseudoOrder::Scheme,
PseudoOrder::Path,
];
fn base_tls(alps_extra: &'static [(u16, u32)]) -> TlsProfile {
TlsProfile {
min_version: SslVersion::TLS1_2,
max_version: SslVersion::TLS1_3,
cipher_list: CIPHER_LIST,
curves: CURVES,
grease_enabled: true,
permute_extensions: true,
enable_ech_grease: true,
alps_enabled: true,
alps_use_new_codepoint: true,
alps_extra_settings: alps_extra,
compress_certificate: true,
session_ticket_enabled: true,
alpn_protocols: ALPN_PROTOCOLS,
sigalgs: SIGALGS,
verify_peer: true,
}
}
fn base_h2() -> Http2Profile {
Http2Profile {
settings: SettingsFrame {
header_table_size: 65_536,
enable_push: false,
initial_window_size: 6_291_456,
max_header_list_size: 262_144,
},
initial_connection_window_size: 15_728_640,
pseudo_order: PSEUDO_ORDER,
headers_priority: HeadersPriority {
dep: 0,
weight: 255,
exclusive: true,
},
}
}
const SEC_CH_UA: &str =
"\"Chromium\";v=\"134\", \"Not:A-Brand\";v=\"24\", \"Google Chrome\";v=\"134\"";
pub fn chrome_134_macos_arm() -> ChromeProfile {
ChromeProfile {
version: 134,
platform: Platform::MacOsArm,
tls: base_tls(ALPS_EXTRA_SETTINGS_MACOS),
h2: base_h2(),
headers: HeaderProfile {
user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) \
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.35 Safari/537.36"
.to_owned(),
sec_ch_ua: SEC_CH_UA.to_owned(),
sec_ch_ua_platform: "\"macOS\"".to_owned(),
sec_ch_ua_platform_version: "\"15.0.0\"".to_owned(),
include_priority_header: true,
zstd_encoding: true,
},
}
}
pub fn chrome_134_windows_x64() -> ChromeProfile {
ChromeProfile {
version: 134,
platform: Platform::WindowsX64,
tls: base_tls(ALPS_EXTRA_SETTINGS_WIN_LINUX),
h2: base_h2(),
headers: HeaderProfile {
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) \
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.35 Safari/537.36"
.to_owned(),
sec_ch_ua: SEC_CH_UA.to_owned(),
sec_ch_ua_platform: "\"Windows\"".to_owned(),
sec_ch_ua_platform_version: "\"13.0.0\"".to_owned(),
include_priority_header: true,
zstd_encoding: true,
},
}
}
pub fn chrome_134_linux_x64() -> ChromeProfile {
ChromeProfile {
version: 134,
platform: Platform::LinuxX64,
tls: base_tls(ALPS_EXTRA_SETTINGS_WIN_LINUX),
h2: base_h2(),
headers: HeaderProfile {
user_agent: "Mozilla/5.0 (X11; Linux x86_64) \
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.35 Safari/537.36"
.to_owned(),
sec_ch_ua: SEC_CH_UA.to_owned(),
sec_ch_ua_platform: "\"Linux\"".to_owned(),
sec_ch_ua_platform_version: "\"0.0.0\"".to_owned(),
include_priority_header: true,
zstd_encoding: true,
},
}
}
pub fn profile(platform: Platform) -> ChromeProfile {
match platform {
Platform::MacOsArm | Platform::MacOsX86 => chrome_134_macos_arm(),
Platform::WindowsX64 => chrome_134_windows_x64(),
Platform::LinuxX64 => chrome_134_linux_x64(),
}
}
pub fn profile_auto() -> ChromeProfile {
if cfg!(target_os = "macos") {
chrome_134_macos_arm()
} else if cfg!(target_os = "windows") {
chrome_134_windows_x64()
} else {
chrome_134_linux_x64()
}
}