Compare commits
3 commits
0237540773
...
168621cd99
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
168621cd99 | ||
|
|
bcbe002beb | ||
|
|
b924e4dc2f |
5 changed files with 54 additions and 23 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -14,3 +14,5 @@ Cargo.lock
|
|||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# Vim swapfiles
|
||||
*.swp
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
unicorn_hat_hd_2 = { version = "*" }
|
||||
#unicorn_hat_hd_2 = { version = "*", default-features = false, features = [ "fake-hardware" ] }
|
||||
url = "*"
|
||||
reqwest = "*"
|
||||
trust-dns-client = "*"
|
||||
|
|
|
|||
13
src/dns.rs
Normal file
13
src/dns.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
use crate::{Probe, ProbeResult};
|
||||
use trust_dns_client::client::Client;
|
||||
|
||||
// DNS probe
|
||||
|
||||
pub struct DnsProbe {
|
||||
}
|
||||
|
||||
impl Probe for DnsProbe {
|
||||
fn execute() -> ProbeResult {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
31
src/http.rs
Normal file
31
src/http.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use crate::{Probe, ProbeResult};
|
||||
use url::Url;
|
||||
|
||||
use std::net::SocketAddr;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum HttpError {
|
||||
UrlError(url::ParseError)
|
||||
}
|
||||
|
||||
// HTTP probe
|
||||
//
|
||||
pub struct HttpProbe {
|
||||
remote_addr: SocketAddr
|
||||
}
|
||||
|
||||
impl HttpProbe {
|
||||
pub fn get(url: &str) -> Result<HttpProbe, HttpError> {
|
||||
let request = url::Url::parse(url)
|
||||
.map_err(HttpError::UrlError);
|
||||
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
impl Probe for HttpProbe {
|
||||
fn execute() -> ProbeResult {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
30
src/main.rs
30
src/main.rs
|
|
@ -1,7 +1,9 @@
|
|||
use unicorn_hat_hd_2::UnicornHatHd;
|
||||
use url::Url;
|
||||
|
||||
use std::net::SocketAddr;
|
||||
use self::http::HttpProbe;
|
||||
|
||||
mod dns;
|
||||
mod http;
|
||||
|
||||
pub trait Probe {
|
||||
fn execute() -> ProbeResult;
|
||||
|
|
@ -21,26 +23,6 @@ pub struct ProbeMetrics {
|
|||
pub latency_ms: u32
|
||||
}
|
||||
|
||||
// HTTP probe
|
||||
//
|
||||
pub struct HttpProbe {
|
||||
remote_addr: SocketAddr
|
||||
}
|
||||
|
||||
impl Probe for HttpProbe {
|
||||
fn execute() -> ProbeResult {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
// DNS probe
|
||||
|
||||
pub struct DnsProbe {
|
||||
fn execute() -> ProbeResult {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut hat_hd = UnicornHatHd::default();
|
||||
|
||||
|
|
@ -50,5 +32,9 @@ fn main() {
|
|||
//hat_hd.set_pixel(x, y, [255, 255, 255].into());
|
||||
//hat_hd.display().unwrap();
|
||||
|
||||
let probes = vec![
|
||||
HttpProbe::get("https://google.co.uk").expect("Failed to parse URL")
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue