A simple interval-based site monitor that bypasses TLS fingerprinting on sites.
```rs use asynctrait::asynctrait; use maera::{ AsyncBody, AsyncJob, AsyncReadResponseExt, AsyncScheduler, Interval, Job, JobHandler, Maera, Method, }; use serde_json::Value;
// Define the struct that represents the site you're monitoring
struct Peet;
impl JobHandler for Peet {
// The target website that's going to be requested
fn target(&self) -> maera::MaeraRequest {
maera::Request::builder()
.method(Method::GET)
.uri("https://tls.peet.ws/api/all")
.body(AsyncBody::empty())
.unwrap()
}
fn schedule<'a>(&self, scheduler: &'a mut AsyncScheduler) -> &'a mut AsyncJob {
scheduler.every(Interval::Seconds(2))
}
async fn onsuccess(&self, response: &mut maera::MaeraResponse) {
// get JSON from response text
let text = serdejson::fromstr::
fn main () { let maera = Maera::new(vec![Job { handler: Peet, name: "tls.peet.ws" }]);
maera.start().await.unwrap(); } ```
It's recommended to not change the headers for the request too much as the order and values of headers are used for fingerprinting purposes, so a lot of them like user-agent
are hardcoded.
Warning, I have no idea how to build rust libraries (as you can tell from the type signature of traits). If you run into this and want to improve the API, feel free to open a PR.