1pub mod fingerprint;
14pub mod headers;
15mod map;
16pub mod network;
17pub mod rng;
18mod zip;
19
20pub use fingerprint::{
21 Fingerprint, FingerprintGenerator, FingerprintOptions, FingerprintOverrides,
22 NavigatorFingerprint, Screen, ScreenFingerprint, VideoCard, generate_fingerprint,
23 generate_headers,
24};
25pub use headers::{
26 Browser, HeaderGenerator, HeaderOptions, HeaderOverrides, Headers, HttpVersion, browser_of,
27 get_user_agent, pascalize,
28};
29pub use map::{OrderedMap, Restrictions, Values};
30pub use network::{BayesianNetwork, Node, fingerprint_network, header_network, input_network};
31pub use rng::Rng;
32
33const TOO_RESTRICTIVE: &str = "The current constraints are too restrictive. No possible values can be found for the given constraints.";
35
36const NO_HEADERS: &str = "No headers based on this input can be generated. Please relax or change some of the requirements you specified.";
38
39const NO_FINGERPRINT: &str = "Cannot generate headers. User-Agent may be invalid, or screen constraints are too restrictive.";
41
42#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
44#[non_exhaustive]
45pub enum Error {
46 #[error("{TOO_RESTRICTIVE}")]
48 TooRestrictive,
49 #[error("unknown network node {0:?}")]
51 UnknownNode(String),
52 #[error("malformed zip archive: {0}")]
54 Zip(String),
55 #[error("malformed network definition: {0}")]
57 Network(String),
58 #[error("invalid header options: {0}")]
61 InvalidOptions(String),
62 #[error("{NO_HEADERS}")]
65 NoHeaders,
66 #[error("Failed to find User-Agent in generated response")]
68 MissingUserAgent,
69 #[error("{NO_FINGERPRINT}")]
72 NoFingerprint,
73 #[error("Failed to find browser in User-Agent {0:?}")]
75 UnknownBrowser(String),
76 #[error("malformed embedded data: {0}")]
78 Data(String),
79 #[error("operating system entropy unavailable: {0}")]
81 Entropy(#[source] getrandom::Error),
82}
83
84pub type Result<T> = std::result::Result<T, Error>;