0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-23 06:28:23 -05:00
websurfx/src/search_results_handler/user_agent.rs

27 lines
677 B
Rust
Raw Normal View History

2023-04-27 10:53:28 -04:00
//! This module provides the functionality to generate random user agent string.
use fake_useragent::{Browsers, UserAgentsBuilder};
2023-04-27 10:53:28 -04:00
/// A function to generate random user agent to improve privacy of the user.
///
/// # Returns
///
/// A randomly generated user agent string.
pub fn random_user_agent() -> String {
UserAgentsBuilder::new()
.cache(false)
.dir("/tmp")
.thread(1)
.set_browsers(
Browsers::new()
.set_chrome()
.set_safari()
.set_edge()
.set_firefox()
.set_mozilla(),
)
.build()
.random()
.to_string()
}