Added dns and http client stubs
This commit is contained in:
parent
b924e4dc2f
commit
bcbe002beb
4 changed files with 54 additions and 22 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -14,3 +14,5 @@ Cargo.lock
|
||||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
*.pdb
|
*.pdb
|
||||||
|
|
||||||
|
# Vim swapfiles
|
||||||
|
*.swp
|
||||||
|
|
|
||||||
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 unicorn_hat_hd_2::UnicornHatHd;
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
use std::net::SocketAddr;
|
use self::http::HttpProbe;
|
||||||
|
|
||||||
|
mod dns;
|
||||||
|
mod http;
|
||||||
|
|
||||||
pub trait Probe {
|
pub trait Probe {
|
||||||
fn execute() -> ProbeResult;
|
fn execute() -> ProbeResult;
|
||||||
|
|
@ -21,26 +23,6 @@ pub struct ProbeMetrics {
|
||||||
pub latency_ms: u32
|
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() {
|
fn main() {
|
||||||
let mut hat_hd = UnicornHatHd::default();
|
let mut hat_hd = UnicornHatHd::default();
|
||||||
|
|
||||||
|
|
@ -50,5 +32,9 @@ fn main() {
|
||||||
//hat_hd.set_pixel(x, y, [255, 255, 255].into());
|
//hat_hd.set_pixel(x, y, [255, 255, 255].into());
|
||||||
//hat_hd.display().unwrap();
|
//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