use super::http2::Http2Settings;
use super::http3::Http3Fingerprint;
use super::tls::TlsFingerprint;
use crate::transport::h2::PseudoHeaderOrder;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum FingerprintProfile {
#[default]
Chrome142,
Chrome143,
Chrome144,
Chrome145,
Chrome146,
Chrome147,
Chrome148,
Firefox133,
None,
Firefox134,
Firefox135,
Firefox136,
Firefox137,
Firefox138,
Firefox139,
Firefox140,
Firefox141,
Firefox142,
Firefox143,
Firefox144,
Firefox145,
Firefox146,
Firefox147,
Firefox148,
Firefox149,
Firefox150,
Firefox151,
FirefoxEsr115,
FirefoxEsr128,
FirefoxEsr140,
}
impl FingerprintProfile {
pub fn is_firefox(&self) -> bool {
matches!(
self,
Self::Firefox133
| Self::Firefox134
| Self::Firefox135
| Self::Firefox136
| Self::Firefox137
| Self::Firefox138
| Self::Firefox139
| Self::Firefox140
| Self::Firefox141
| Self::Firefox142
| Self::Firefox143
| Self::Firefox144
| Self::Firefox145
| Self::Firefox146
| Self::Firefox147
| Self::Firefox148
| Self::Firefox149
| Self::Firefox150
| Self::Firefox151
| Self::FirefoxEsr115
| Self::FirefoxEsr128
| Self::FirefoxEsr140
)
}
pub fn user_agent(&self) -> &'static str {
match self {
Self::Chrome142 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36"
}
Self::Chrome143 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"
}
Self::Chrome144 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36"
}
Self::Chrome145 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36"
}
Self::Chrome146 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
}
Self::Chrome147 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36"
}
Self::Chrome148 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36"
}
Self::Firefox133 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0"
}
Self::None => "specter/0.1",
Self::Firefox134 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0"
}
Self::Firefox135 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0"
}
Self::Firefox136 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:136.0) Gecko/20100101 Firefox/136.0"
}
Self::Firefox137 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0"
}
Self::Firefox138 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0"
}
Self::Firefox139 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0"
}
Self::Firefox140 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:140.0) Gecko/20100101 Firefox/140.0"
}
Self::Firefox141 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:141.0) Gecko/20100101 Firefox/141.0"
}
Self::Firefox142 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:142.0) Gecko/20100101 Firefox/142.0"
}
Self::Firefox143 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:143.0) Gecko/20100101 Firefox/143.0"
}
Self::Firefox144 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:144.0) Gecko/20100101 Firefox/144.0"
}
Self::Firefox145 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0"
}
Self::Firefox146 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:146.0) Gecko/20100101 Firefox/146.0"
}
Self::Firefox147 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0"
}
Self::Firefox148 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:148.0) Gecko/20100101 Firefox/148.0"
}
Self::Firefox149 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:149.0) Gecko/20100101 Firefox/149.0"
}
Self::Firefox150 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:150.0) Gecko/20100101 Firefox/150.0"
}
Self::Firefox151 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:151.0) Gecko/20100101 Firefox/151.0"
}
Self::FirefoxEsr115 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:115.0) Gecko/20100101 Firefox/115.0"
}
Self::FirefoxEsr128 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0"
}
Self::FirefoxEsr140 => {
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:140.0) Gecko/20100101 Firefox/140.0"
}
}
}
pub fn tls_fingerprint(&self) -> TlsFingerprint {
if self.is_firefox() {
TlsFingerprint::firefox()
} else {
match self {
FingerprintProfile::Chrome142
| FingerprintProfile::Chrome143
| FingerprintProfile::Chrome144
| FingerprintProfile::Chrome145
| FingerprintProfile::Chrome146
| FingerprintProfile::Chrome147
| FingerprintProfile::Chrome148 => TlsFingerprint::chrome(),
FingerprintProfile::None => TlsFingerprint::default(),
_ => unreachable!("all Firefox profiles are handled above"),
}
}
}
pub fn http2_settings(&self) -> Http2Settings {
if self.is_firefox() {
Http2Settings::firefox()
} else {
Http2Settings::default()
}
}
pub fn http2_pseudo_order(&self) -> PseudoHeaderOrder {
if self.is_firefox() {
PseudoHeaderOrder::Firefox
} else {
PseudoHeaderOrder::Chrome
}
}
pub fn http3_fingerprint(&self) -> Http3Fingerprint {
if self.is_firefox() {
Http3Fingerprint::firefox()
} else {
match self {
FingerprintProfile::Chrome142
| FingerprintProfile::Chrome143
| FingerprintProfile::Chrome144
| FingerprintProfile::Chrome145
| FingerprintProfile::Chrome146
| FingerprintProfile::Chrome147
| FingerprintProfile::Chrome148 => Http3Fingerprint::chrome(),
FingerprintProfile::None => Http3Fingerprint::default(),
_ => unreachable!("all Firefox profiles are handled above"),
}
}
}
}