mod time;
mod network;
mod dns;
+mod syslog;
pub fn router() -> Router {
.get(ApiMethod::new(
|_,_| Ok(json!([
{"subdir": "network"},
- {"subdir": "time"},
+ {"subdir": "syslog"},
+ {"subdir": "time"},
])),
ObjectSchema::new("Directory index.")))
.subdir("dns", dns::router())
.subdir("network", network::router())
+ .subdir("syslog", syslog::router())
.subdir("time", time::router());
route
--- /dev/null
+use failure::*;
+
+use crate::tools;
+use crate::api::schema::*;
+use crate::api::router::*;
+use serde_json::{json, Value};
+
+use std::sync::Arc;
+use lazy_static::lazy_static;
+use crate::tools::common_regex;
+
+fn get_syslog(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
+
+ let result = json!({});
+
+ Ok(result)
+}
+
+lazy_static! {
+ pub static ref SYSTEMD_DATETIME_FORMAT: Arc<ApiStringFormat> =
+ ApiStringFormat::Pattern(&common_regex::SYSTEMD_DATETIME_REGEX).into();
+}
+
+pub fn router() -> Router {
+
+ let route = Router::new()
+ .get(
+ ApiMethod::new(
+ get_syslog,
+ ObjectSchema::new("Read server time and time zone settings.")
+ .optional(
+ "start",
+ IntegerSchema::new("Start line number.")
+ .minimum(0)
+ )
+ .optional(
+ "limit",
+ IntegerSchema::new("Max. number of lines.")
+ .minimum(0)
+ )
+ .optional(
+ "since",
+ StringSchema::new("Display all log since this date-time string.")
+ .format(SYSTEMD_DATETIME_FORMAT.clone())
+ )
+ .optional(
+ "until",
+ StringSchema::new("Display all log until this date-time string.")
+ .format(SYSTEMD_DATETIME_FORMAT.clone())
+ )
+ .optional(
+ "service",
+ StringSchema::new("Service ID.")
+ .max_length(128)
+ )
+ ).returns(
+ ObjectSchema::new("Returns a list of syslog entries.")
+ .required("n", IntegerSchema::new("Line number."))
+ .required("t", StringSchema::new("Line text."))
+ )
+ );
+
+ route
+}
lazy_static! {
pub static ref IP_REGEX: Regex = Regex::new(IPRE!()).unwrap();
- pub static ref SHA256_HEX_REGEX: Regex = Regex::new("^[a-f0-9]{64}$").unwrap();
+ pub static ref SHA256_HEX_REGEX: Regex =
+ Regex::new(r"^[a-f0-9]{64}$")
+ .unwrap();
+
+ pub static ref SYSTEMD_DATETIME_REGEX: Regex =
+ Regex::new(r"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$")
+ .unwrap();
}