Fix existing issues

This commit is contained in:
undef-i 2023-04-30 19:24:45 +08:00
parent 8b8547755b
commit 4ef7802fc0
5 changed files with 74 additions and 9 deletions

2
Cargo.lock generated
View File

@ -368,7 +368,7 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "bird-looking-glass-proxy"
version = "0.0.2"
version = "0.0.3"
dependencies = [
"actix-web",
"birdc",

View File

@ -1,6 +1,6 @@
[package]
name = "bird-looking-glass-proxy"
version = "0.0.2"
version = "0.0.3"
edition = "2021"
[dependencies]

View File

@ -1,14 +1,10 @@
bind_ip = "0.0.0.0"
bind_port = 5000
bind_port = 8000
# Used to restrict access to bird-looking-glass-proxy based on source IP address.
# Empty list = any IP is allowed to run queries.
access_list = ["127.0.0.1"]
# Used to restrict access to bird-looking-glass-proxy based on a shared secret (must also be configured in lg.cfg)
# Empty string or unset = no shared secret is required to run queries.
shared_secret="ThisTokenIsNotSecret"
# Used as source address when running traceroute
ipv4_source="198.51.100.42"
ipv6_source="2001:db8:42::1"

View File

@ -13,7 +13,7 @@ lazy_static! {
.arg_from_usage("-e, --example 'Export sample config file'")
.get_matches();
if matches.is_present("example") {
println!("bind_ip = \"0.0.0.0\"\nbind_port = 5000\n\n# Used to restrict access to bird-looking-glass-proxy based on source IP address.\n# Empty list = any IP is allowed to run queries.\naccess_list = [\"127.0.0.1\"]\n\n# Used to restrict access to bird-looking-glass-proxy based on a shared secret (must also be configured in lg.cfg)\n# Empty string or unset = no shared secret is required to run queries.\nshared_secret=\"ThisTokenIsNotSecret\"\n\n# Used as source address when running traceroute\nipv4_source=\"198.51.100.42\"\nipv6_source=\"2001:db8:42::1\"\n\nbird_socket=\"/var/run/bird/bird.ctl\"\nbird6_socket=\"/var/run/bird/bird6.ctl\"");
println!("bind_ip = \"0.0.0.0\"\nbind_port = 5000\n\n# Used to restrict access to bird-looking-glass-proxy based on source IP address.\n# Empty list = any IP is allowed to run queries.\naccess_list = [\"127.0.0.1\"]\n\n# Used as source address when running traceroute\nipv4_source=\"198.51.100.42\"\nipv6_source=\"2001:db8:42::1\"\n\nbird_socket=\"/var/run/bird/bird.ctl\"\nbird6_socket=\"/var/run/bird/bird6.ctl\"");
std::process::exit(0);
}
config::Config::new(matches.value_of("config").unwrap_or("config.toml"))

View File

@ -16,7 +16,76 @@ pub async fn bird(_param: web::Query<Param>, _req: HttpRequest, mode: i8) -> Res
});
let mut connection = block_on(client.connect())?;
let messages = block_on(connection.send_request(&_param.q))?;
return Ok(messages.iter().map(|message |format!("{:?}",message)).collect::<String>());
return Ok(messages.iter().map(|message | match message {
Message::Welcome(s) |
Message::ReadingConfiguration(s) |
Message::Reconfigured(s) |
Message::ReconfigurationInProgress(s) |
Message::ReconfigurationQueued(s) |
Message::ReconfigurationIgnoredShutdown(s) |
Message::ShutdownOrdered(s) |
Message::AlreadyDisable(s) |
Message::Disabled(s) |
Message::AlreadyEnabled(s) |
Message::Enabled(s) |
Message::Restarted(s) |
Message::StatusReport(s) |
Message::RouteCount(s) |
Message::Reloading(s) |
Message::AccessRestricted(s) |
Message::ReconfigurationUnQueued(s) |
Message::ReconfigurationConfirmed(s) |
Message::NothingToDo(s) |
Message::ConfigurationOk(s) |
Message::UndoRequested(s) |
Message::UndoScheduled(s) |
Message::EvaluatingExpression(s) |
Message::GracefulRestartStatus(s) |
Message::BirdVersion(s) |
Message::InterfaceList(s) |
Message::ProtocolList(s) |
Message::InterfaceAddress(s) |
Message::InterfaceFlags(s) |
Message::InterfaceSummary(s) |
Message::ProtocolDetails(s) |
Message::RouteList(s) |
Message::RouteDetails(s) |
Message::StaticRouteList(s) |
Message::SymbolList(s) |
Message::Uptime(s) |
Message::RouteExtendedAttributeList(s) |
Message::OspfNeighbors(s) |
Message::Ospf(s) |
Message::OspfInterface(s) |
Message::OspfState(s) |
Message::OspfLsadb(s) |
Message::Memory(s) |
Message::RoaList(s) |
Message::BfdSessions(s) |
Message::RipInterfaces(s) |
Message::RipNeighbors(s) |
Message::BabelInterfaces(s) |
Message::BabelNeighbors(s) |
Message::BabelEntries(s) |
Message::ProtocolListHeader(s) |
Message::InterfaceSummaryHeader(s) |
Message::TableHeader(_, s) |
Message::ReplyTooLong(s) |
Message::RouteNotFound(s) |
Message::ConfigurationFileError(s) |
Message::NoProtocolsMatch(s) |
Message::StoppedDueToReconfiguration(s) |
Message::ProtocolDown(s) |
Message::ReloadFailed(s) |
Message::AccessDenied(s) |
Message::RuntimeError(_, s) |
Message::CommandTooLong(s) |
Message::ParseError(s) |
Message::InvalidSymbol(s) |
Message::ClientError(_, s) |
Message::Unknown(_, s) => s.to_string(),
_ => "".to_string(),
}).collect::<Vec<String>>().join("\n"));
}
pub async fn bird4(_param: web::Query<Param>, _req: HttpRequest) -> impl Responder {