Compare commits
No commits in common. "3224c02d6f239b787acb090db57ee5e6697e467b" and "be38c16c8d0d149927051451a29f2340b42cd0d1" have entirely different histories.
3224c02d6f
...
be38c16c8d
6 changed files with 1014 additions and 1240 deletions
2222
Cargo.lock
generated
2222
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,18 +8,17 @@ edition = "2018"
|
||||||
reqwest = "0.9"
|
reqwest = "0.9"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
ron = "0.5"
|
ron = "0.5"
|
||||||
actix-web = { version = "1.0", default-features = false, features = ["brotli", "flate2-zlib"] }
|
actix-web = { version = "1.0.0-beta.3", default-features = false, features = ["brotli", "flate2-zlib"] }
|
||||||
actix = "0.8"
|
actix = "0.8"
|
||||||
tokio = "0.1"
|
tokio = "0.1"
|
||||||
tera = "0.11"
|
tera = "0.11"
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
ring = "^0"
|
ring = "^0"
|
||||||
log="0.4"
|
|
||||||
rss = { version = "1.7.0", optional = true }
|
rss = { version = "1.7.0", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["json", "webhooks"]
|
default = ["json"]
|
||||||
|
|
||||||
json = []
|
json = []
|
||||||
rss_feed = ["rss"]
|
rss_feed = ["rss"]
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -1,9 +1,16 @@
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
#[macro_use]
|
extern crate actix;
|
||||||
extern crate log;
|
extern crate actix_web;
|
||||||
|
extern crate chrono;
|
||||||
|
extern crate env_logger;
|
||||||
|
extern crate reqwest;
|
||||||
|
extern crate ron;
|
||||||
|
extern crate serde;
|
||||||
|
extern crate tokio;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate tera;
|
extern crate tera;
|
||||||
|
extern crate ring;
|
||||||
|
|
||||||
#[cfg(feature = "rss_feed")]
|
#[cfg(feature = "rss_feed")]
|
||||||
extern crate rss;
|
extern crate rss;
|
||||||
|
@ -35,7 +42,7 @@ fn main() {
|
||||||
let conf_file_loc =
|
let conf_file_loc =
|
||||||
var("ENDSTAT_CONF").unwrap_or_else(|_| String::from("./config/endstat_conf.ron"));
|
var("ENDSTAT_CONF").unwrap_or_else(|_| String::from("./config/endstat_conf.ron"));
|
||||||
let config = from_str::<Config>(
|
let config = from_str::<Config>(
|
||||||
&read_to_string(&conf_file_loc).unwrap_or_else(|_| panic!("finding {}", conf_file_loc)),
|
&read_to_string(&conf_file_loc).expect(&format!("finding {}", conf_file_loc)),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let bind_addr = &config.bind_address;
|
let bind_addr = &config.bind_address;
|
||||||
|
|
|
@ -50,9 +50,7 @@ impl QueryResults {
|
||||||
($(($hook:ident, $cond:expr)),*) => {
|
($(($hook:ident, $cond:expr)),*) => {
|
||||||
$(if let Some(url) = &webhooks.$hook {
|
$(if let Some(url) = &webhooks.$hook {
|
||||||
if new_endpoint.status == $cond {
|
if new_endpoint.status == $cond {
|
||||||
if let Err(e) = client.post(url).json(new_endpoint).send() {
|
client.post(url).json(new_endpoint).send();
|
||||||
warn!("{}", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})*
|
})*
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,8 +74,8 @@ fn get_result(
|
||||||
|
|
||||||
if let Some(expected_hash) = &endpoint.body_hash {
|
if let Some(expected_hash) = &endpoint.body_hash {
|
||||||
let expected = from_hex(expected_hash).unwrap();
|
let expected = from_hex(expected_hash).unwrap();
|
||||||
let actual = digest(&SHA256, res_body.as_bytes());
|
let actual = digest(&SHA256, String::from(res_body).as_bytes());
|
||||||
if expected != actual.as_ref() {
|
if &expected != &actual.as_ref() {
|
||||||
errors.push(String::from("Body hash mismatch."));
|
errors.push(String::from("Body hash mismatch."));
|
||||||
}
|
}
|
||||||
} else if !body.is_empty() && res_body != body {
|
} else if !body.is_empty() && res_body != body {
|
||||||
|
@ -112,7 +112,7 @@ fn get_result(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_url(base: &Option<String>, path: &str, port: Option<u16>) -> Result<String, UrlError> {
|
fn get_url(base: &Option<String>, path: &String, port: Option<u16>) -> Result<String, UrlError> {
|
||||||
let mut url = if let Some(base) = base {
|
let mut url = if let Some(base) = base {
|
||||||
Url::parse(base)?.join(path)?
|
Url::parse(base)?.join(path)?
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
background-color: #424242;
|
background-color: #424242;
|
||||||
margin: 1rem 0;
|
margin: 1rem 0;
|
||||||
border-radius: .5rem;
|
border-radius: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
p { margin: 0; }
|
p { margin: 0; }
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
.indicator {
|
.indicator {
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
border-radius: .5rem 0 0 .5rem;
|
border-radius: 1rem 0 0 1rem;
|
||||||
}
|
}
|
||||||
.ok { background-color: #4ed34e; }
|
.ok { background-color: #4ed34e; }
|
||||||
.warn { background-color: #fcfc64; }
|
.warn { background-color: #fcfc64; }
|
||||||
|
|
Loading…
Reference in a new issue