Commit eb9f9b66 authored by nanamicat's avatar nanamicat

online

parent 3306fbf6
Pipeline #41999 passed with stages
in 2 minutes and 4 seconds
# Rust build artifacts
target/
# Git
.git/
.gitignore
# IDE
.idea/
# CI/CD
.gitlab-ci.yml
# Docker
Dockerfile
.dockerignore
# Documentation
README.md
rustfmt.toml
\ No newline at end of file
...@@ -33,14 +33,14 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" ...@@ -33,14 +33,14 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]] [[package]]
name = "axum" name = "axum"
version = "0.7.9" version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" checksum = "5b098575ebe77cb6d14fc7f32749631a6e44edbef6b796f89b020e99ba20d425"
dependencies = [ dependencies = [
"async-trait",
"axum-core", "axum-core",
"axum-macros", "axum-macros",
"bytes", "bytes",
"form_urlencoded",
"futures-util", "futures-util",
"http", "http",
"http-body", "http-body",
...@@ -53,8 +53,7 @@ dependencies = [ ...@@ -53,8 +53,7 @@ dependencies = [
"mime", "mime",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"rustversion", "serde_core",
"serde",
"serde_json", "serde_json",
"serde_path_to_error", "serde_path_to_error",
"serde_urlencoded", "serde_urlencoded",
...@@ -68,19 +67,17 @@ dependencies = [ ...@@ -68,19 +67,17 @@ dependencies = [
[[package]] [[package]]
name = "axum-core" name = "axum-core"
version = "0.4.5" version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" checksum = "59446ce19cd142f8833f856eb31f3eb097812d1479ab224f54d72428ca21ea22"
dependencies = [ dependencies = [
"async-trait",
"bytes", "bytes",
"futures-util", "futures-core",
"http", "http",
"http-body", "http-body",
"http-body-util", "http-body-util",
"mime", "mime",
"pin-project-lite", "pin-project-lite",
"rustversion",
"sync_wrapper", "sync_wrapper",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
...@@ -89,9 +86,9 @@ dependencies = [ ...@@ -89,9 +86,9 @@ dependencies = [
[[package]] [[package]]
name = "axum-macros" name = "axum-macros"
version = "0.4.2" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" checksum = "604fde5e028fea851ce1d8570bbdc034bec850d157f7569d10f347d06808c05c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
...@@ -276,21 +273,6 @@ dependencies = [ ...@@ -276,21 +273,6 @@ dependencies = [
"percent-encoding", "percent-encoding",
] ]
[[package]]
name = "futures"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]] [[package]]
name = "futures-channel" name = "futures-channel"
version = "0.3.31" version = "0.3.31"
...@@ -298,7 +280,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -298,7 +280,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-sink",
] ]
[[package]] [[package]]
...@@ -307,40 +288,6 @@ version = "0.3.31" ...@@ -307,40 +288,6 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
[[package]]
name = "futures-executor"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-io"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
[[package]]
name = "futures-macro"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "futures-sink"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.31" version = "0.3.31"
...@@ -353,16 +300,10 @@ version = "0.3.31" ...@@ -353,16 +300,10 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
dependencies = [ dependencies = [
"futures-channel",
"futures-core", "futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task", "futures-task",
"memchr",
"pin-project-lite", "pin-project-lite",
"pin-utils", "pin-utils",
"slab",
] ]
[[package]] [[package]]
...@@ -532,9 +473,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" ...@@ -532,9 +473,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]] [[package]]
name = "matchit" name = "matchit"
version = "0.7.3" version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
[[package]] [[package]]
name = "memchr" name = "memchr"
...@@ -691,7 +632,6 @@ dependencies = [ ...@@ -691,7 +632,6 @@ dependencies = [
"axum", "axum",
"bincode", "bincode",
"config", "config",
"futures",
"serde", "serde",
"serde_json", "serde_json",
"tokio", "tokio",
...@@ -730,12 +670,6 @@ dependencies = [ ...@@ -730,12 +670,6 @@ dependencies = [
"ordered-multimap", "ordered-multimap",
] ]
[[package]]
name = "rustversion"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.20" version = "1.0.20"
...@@ -855,12 +789,6 @@ dependencies = [ ...@@ -855,12 +789,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "slab"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.15.1" version = "1.15.1"
......
...@@ -11,6 +11,5 @@ serde_json = "1.0.145" ...@@ -11,6 +11,5 @@ serde_json = "1.0.145"
serde = { version = "1.0.228", features = ["derive", "rc"] } serde = { version = "1.0.228", features = ["derive", "rc"] }
tokio = { version = "1.48", features = ["full"] } tokio = { version = "1.48", features = ["full"] }
anyhow = "1.0.100" anyhow = "1.0.100"
axum = { version = "0.7", features = ["macros"] } axum = { version = "0.8.7", features = ["macros"] }
bincode = "2.0.1" bincode = "2.0.1"
futures = "0.3.31"
{
"udp_bind": "[::]:500",
"http_bind": "[::]:80"
}
\ No newline at end of file
...@@ -5,10 +5,10 @@ pub struct RouterData { ...@@ -5,10 +5,10 @@ pub struct RouterData {
pub id: u8, pub id: u8,
pub name: String, pub name: String,
pub location: String, pub location: String,
pub host: String, // pub host: String,
#[serde(default)] // #[serde(default)]
pub ssh_port: u16, // pub ssh_port: u16,
pub user: String, // pub user: String,
} }
#[derive(Serialize, Deserialize, Clone)] #[derive(Serialize, Deserialize, Clone)]
......
...@@ -5,7 +5,7 @@ use crate::router::Router; ...@@ -5,7 +5,7 @@ use crate::router::Router;
use crate::settings::{Settings, INTERVAL, TIMEOUT}; use crate::settings::{Settings, INTERVAL, TIMEOUT};
use anyhow::Result; use anyhow::Result;
use ::config::Config; use ::config::Config;
use config::{Environment, File}; use config::Environment;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::sync::Arc; use std::sync::Arc;
use tokio::net::UdpSocket; use tokio::net::UdpSocket;
...@@ -29,14 +29,10 @@ pub struct UpdatingState { ...@@ -29,14 +29,10 @@ pub struct UpdatingState {
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
let config: Settings = Config::builder() let config: Settings = Config::builder().add_source(Environment::default()).build()?.try_deserialize()?;
.add_source(File::with_name("config/config.json"))
.add_source(Environment::with_prefix("RAILGUN"))
.build()?
.try_deserialize()?;
let routers_data: Arc<Vec<RouterData>> = Arc::new(serde_json::from_str(&std::fs::read_to_string("../import/data/Router.json")?)?); let routers_data: Arc<Vec<RouterData>> = Arc::new(serde_json::from_str(&std::fs::read_to_string("import/data/Router.json")?)?);
let connections = Arc::new(serde_json::from_str(&std::fs::read_to_string("../import/connections.json")?)?); let connections = Arc::new(serde_json::from_str(&std::fs::read_to_string("import/connections.json")?)?);
// let routers_map: BTreeMap<u8, RouterData> = routers_data.iter().map(|r| (r.id, r.clone())).collect(); // let routers_map: BTreeMap<u8, RouterData> = routers_data.iter().map(|r| (r.id, r.clone())).collect();
// let routers_map = Arc::new(routers_map); // let routers_map = Arc::new(routers_map);
...@@ -61,6 +57,7 @@ async fn main() -> Result<()> { ...@@ -61,6 +57,7 @@ async fn main() -> Result<()> {
let app = create_app(routers_data, connections.clone(), routers.clone()); let app = create_app(routers_data, connections.clone(), routers.clone());
tokio::spawn(async move { tokio::spawn(async move {
println!("HTTP listening on {}", &listener.local_addr().unwrap());
axum::serve(listener, app).await.unwrap(); axum::serve(listener, app).await.unwrap();
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment