44 Commits

Author SHA1 Message Date
AB
bc473ed532 test 2024-07-14 04:07:11 +03:00
68ffe9b62d Update main.rs 2024-07-09 10:03:33 +03:00
AB
86f30b90e8 Bump version. linting. improved logging. 2024-07-09 02:48:50 +03:00
AB
8991a0579b Improve logging and error handling 2024-07-09 02:28:44 +03:00
cd1ba739ab fix ci 2024-07-08 23:29:45 +03:00
1ab0167336 fix ci 2024-07-08 23:27:58 +03:00
a39e4835e5 fix ci 2024-07-08 23:18:18 +03:00
30bf476037 fix ci 2024-07-08 23:15:10 +03:00
b2c32ec2b9 fix ci 2024-07-08 23:08:52 +03:00
f7226e918e fix ci 2024-07-08 22:46:20 +03:00
770633d0c6 fix ci 2024-07-08 22:36:56 +03:00
1c2c234930 fix 2024-07-08 22:29:24 +03:00
655c32a915 Update Dockerfile 2024-07-08 22:03:23 +03:00
21fe8036d3 Update main.yml 2024-07-08 21:47:43 +03:00
eac6f22756 Test docker build 2024-07-08 21:33:30 +03:00
444251ad00 Update main.yml 2024-07-08 21:24:20 +03:00
418de46955 Update main.yml 2024-07-08 21:22:15 +03:00
e500f9ff10 Update main.yml 2024-07-08 21:20:04 +03:00
c01714d8ce Update main.yml 2024-07-08 21:03:34 +03:00
72419aaabd Update main.yml 2024-07-08 20:27:12 +03:00
faacf4c034 Update main.yml 2024-07-08 20:13:47 +03:00
ca7ca3dc38 Update main.yml 2024-07-08 20:05:14 +03:00
9b8efacabc Update main.yml 2024-07-08 19:56:45 +03:00
5b88e4ab50 Update main.yml 2024-07-08 19:45:51 +03:00
98f3957076 Update main.yml 2024-07-08 19:43:47 +03:00
9485cf435a Update main.yml 2024-07-08 19:25:31 +03:00
a9748bf7f8 Update main.yml 2024-07-08 19:24:11 +03:00
ab8e3454e7 Update main.yml 2024-07-08 19:20:24 +03:00
a6f2eaec19 Update main.yml 2024-07-08 19:14:56 +03:00
2f416821f0 Update main.yml 2024-07-08 19:02:20 +03:00
643ea91f27 Update main.yml 2024-07-08 19:01:16 +03:00
41cc5a7bb1 Update main.yml 2024-07-08 18:52:22 +03:00
40a142e9c5 Update main.yml 2024-07-08 18:45:13 +03:00
fcc008e949 Update main.yml 2024-07-08 18:41:10 +03:00
b5560943ee Update main.yml 2024-07-08 18:24:05 +03:00
f51b17ff24 Update main.yml 2024-07-08 17:57:42 +03:00
d47e191b18 Update main.yml 2024-07-08 17:51:05 +03:00
653ad49319 Update main.yml 2024-07-08 16:03:07 +03:00
ce9141e2a0 Update main.yml 2024-07-08 16:00:05 +03:00
7e9d21e49c Update main.yml 2024-07-08 15:46:54 +03:00
efd8659836 Update main.yml 2024-07-08 15:38:17 +03:00
f32014306b Update main.yml 2024-07-08 14:56:54 +03:00
bd3054d2f1 Update main.yml 2024-07-08 14:27:46 +03:00
8b66d7395e Update main.yml 2024-07-08 14:13:30 +03:00
7 changed files with 232 additions and 88 deletions

View File

@ -1,84 +1,177 @@
name: Rust CI name: Rust static build and publish
on: on:
push: push:
tags: tags:
- 'v*.*.*' # Запуск при создании новой тэгированной версии - 'v*.*.*'
pull_request:
branches: env:
- main CARGO_TERM_COLOR: always
BINARY_NAME: khm
jobs: jobs:
build: build:
name: Build static binary
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest]
include: include:
- os: ubuntu-latest - os: ubuntu-latest
target: x86_64-unknown-linux-gnu build_target: x86_64-unknown-linux-musl
platform_name: linux-amd64
- os: windows-latest - os: windows-latest
target: x86_64-pc-windows-msvc build_target: x86_64-pc-windows-msvc
- os: macos-latest platform_name: windows-amd64
target: x86_64-apple-darwin permissions:
contents: write
steps: steps:
- name: Checkout repository - uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-index-
- name: Cache Cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Set up Rust - uses: dtolnay/rust-toolchain@stable
uses: actions-rs/toolchain@v1
with: - uses: mbrobbel/rustfmt-check@master
toolchain: stable with:
profile: minimal token: ${{ secrets.GITHUB_TOKEN }}
override: true
- name: Install rust targets
- name: Install target run: rustup target add ${{ matrix.build_target }}
run: rustup target add ${{ matrix.target }}
- name: Build Linux MUSL
- name: Build project if: matrix.os == 'ubuntu-latest'
run: cargo build --release --target ${{ matrix.target }} uses: gmiam/rust-musl-action@master
with:
- name: Run tests args: cargo build --target ${{ matrix.build_target }} --release
run: cargo test --target ${{ matrix.target }}
- name: Build Windows
- name: Upload release assets if: matrix.os != 'ubuntu-latest'
uses: actions/upload-artifact@v4 run: cargo build --target ${{ matrix.build_target }} --release
with:
name: khm-${{ matrix.os }} - name: Upload artifact
path: target/${{ matrix.target }}/release/ uses: actions/upload-artifact@v4
with:
name: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}
path: target/${{ matrix.build_target }}/release/${{ env.BINARY_NAME }}*
release: release:
runs-on: ubuntu-latest name: Create Release Page
needs: build needs: build
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
permissions:
contents: write
steps: steps:
- name: Checkout repository - uses: actions/checkout@v4
uses: actions/checkout@v3 - name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Download Linux build artifact upload:
uses: actions/download-artifact@v4 name: Upload Release Assets
with: needs: release
name: khm-ubuntu-latest runs-on: ${{ matrix.os }}
path: target/x86_64-unknown-linux-gnu/release/ strategy:
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: ubuntu-latest
platform_name: linux-amd64
- os: windows-latest
platform_name: windows-amd64
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
name: Download ${{ matrix.platform_name }} artifact
with:
name: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}
path: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}/${{ env.BINARY_NAME }}${{ matrix.platform_name == 'windows-amd64' && '.exe' || '' }}
asset_name: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}${{ matrix.platform_name == 'windows-amd64' && '.exe' || '' }}
asset_content_type: application/octet-stream
- name: Download Windows build artifact build_docker:
uses: actions/download-artifact@v4 name: Build and Publish Docker Image
with: needs: build
name: khm-windows-latest runs-on: ubuntu-latest
path: target/x86_64-pc-windows-msvc/release/ steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
name: Download Linux artifact
with:
name: ${{ env.BINARY_NAME }}_linux-amd64
path: .
- name: ls
run: |
ls -lah
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download macOS build artifact - name: Set up QEMU
uses: actions/download-artifact@v4 uses: docker/setup-qemu-action@v3
with:
name: khm-macos-latest - name: Login to Docker Hub
path: target/x86_64-apple-darwin/release/ uses: docker/login-action@v3
with:
username: ultradesu
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set exec flag
run: |
chmod +x ${{ env.BINARY_NAME }}
- name: Set outputs
id: get_tag
run: |
echo "tag=$(echo ${GITHUB_REF} | cut -d'/' -f3)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ultradesu/${{ env.BINARY_NAME }}:latest,ultradesu/${{ env.BINARY_NAME }}:${{ steps.get_tag.outputs.tag }}
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
artifacts: "target/x86_64-apple-darwin/release/khm,target/x86_64-pc-windows-msvc/release/khm.exe,target/x86_64-unknown-linux-gnu/release/khm"
#bodyFile: "body.md"

2
Cargo.lock generated
View File

@ -1053,7 +1053,7 @@ dependencies = [
[[package]] [[package]]
name = "khm" name = "khm"
version = "0.1.0" version = "0.2.0"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"chrono", "chrono",

View File

@ -1,8 +1,8 @@
[package] [package]
name = "khm" name = "khm"
version = "0.1.0" version = "0.2.0"
edition = "2021" edition = "2021"
authors = ["AB <ab@hexor.cy>"] authors = ["AB <ab@hexor.cy>", "ChatGPT-4o"]
[dependencies] [dependencies]
actix-web = "4" actix-web = "4"

5
Dockerfile Normal file
View File

@ -0,0 +1,5 @@
# syntax=docker/dockerfile:1
FROM alpine:latest
COPY khm /usr/local/bin/khm
ENTRYPOINT ["/usr/local/bin/khm"]

View File

@ -1,3 +1,4 @@
use log::{error, info};
use reqwest::Client; use reqwest::Client;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fs::File; use std::fs::File;
@ -17,15 +18,21 @@ fn read_known_hosts(file_path: &str) -> io::Result<Vec<SshKey>> {
let mut keys = Vec::new(); let mut keys = Vec::new();
for line in reader.lines() { for line in reader.lines() {
if let Ok(line) = line { match line {
let parts: Vec<&str> = line.split_whitespace().collect(); Ok(line) => {
if parts.len() >= 2 { let parts: Vec<&str> = line.split_whitespace().collect();
let server = parts[0].to_string(); if parts.len() >= 2 {
let public_key = parts[1..].join(" "); let server = parts[0].to_string();
keys.push(SshKey { server, public_key }); let public_key = parts[1..].join(" ");
keys.push(SshKey { server, public_key });
}
}
Err(e) => {
error!("Error reading line from known_hosts file: {}", e);
} }
} }
} }
info!("Read {} keys from known_hosts file", keys.len());
Ok(keys) Ok(keys)
} }
@ -36,6 +43,7 @@ fn write_known_hosts(file_path: &str, keys: &[SshKey]) -> io::Result<()> {
for key in keys { for key in keys {
writeln!(file, "{} {}", key.server, key.public_key)?; writeln!(file, "{} {}", key.server, key.public_key)?;
} }
info!("Wrote {} keys to known_hosts file", keys.len());
Ok(()) Ok(())
} }
@ -46,9 +54,9 @@ async fn send_keys_to_server(host: &str, keys: Vec<SshKey>) -> Result<(), reqwes
let response = client.post(&url).json(&keys).send().await?; let response = client.post(&url).json(&keys).send().await?;
if response.status().is_success() { if response.status().is_success() {
println!("Keys successfully sent to server."); info!("Keys successfully sent to server.");
} else { } else {
eprintln!( error!(
"Failed to send keys to server. Status: {}", "Failed to send keys to server. Status: {}",
response.status() response.status()
); );
@ -64,9 +72,10 @@ async fn get_keys_from_server(host: &str) -> Result<Vec<SshKey>, reqwest::Error>
if response.status().is_success() { if response.status().is_success() {
let keys: Vec<SshKey> = response.json().await?; let keys: Vec<SshKey> = response.json().await?;
info!("Received {} keys from server", keys.len());
Ok(keys) Ok(keys)
} else { } else {
eprintln!( error!(
"Failed to get keys from server. Status: {}", "Failed to get keys from server. Status: {}",
response.status() response.status()
); );
@ -75,21 +84,26 @@ async fn get_keys_from_server(host: &str) -> Result<Vec<SshKey>, reqwest::Error>
} }
pub async fn run_client(args: crate::Args) -> std::io::Result<()> { pub async fn run_client(args: crate::Args) -> std::io::Result<()> {
info!("Client mode: Reading known_hosts file");
let keys = read_known_hosts(&args.known_hosts).expect("Failed to read known hosts file"); let keys = read_known_hosts(&args.known_hosts).expect("Failed to read known hosts file");
let host = args.host.expect("host is required in client mode"); let host = args.host.expect("host is required in client mode");
info!("Client mode: Sending keys to server at {}", host);
send_keys_to_server(&host, keys) send_keys_to_server(&host, keys)
.await .await
.expect("Failed to send keys to server"); .expect("Failed to send keys to server");
if args.in_place { if args.in_place {
info!("Client mode: In-place update is enabled. Fetching keys from server.");
let server_keys = get_keys_from_server(&host) let server_keys = get_keys_from_server(&host)
.await .await
.expect("Failed to get keys from server"); .expect("Failed to get keys from server");
info!("Client mode: Writing updated known_hosts file");
write_known_hosts(&args.known_hosts, &server_keys) write_known_hosts(&args.known_hosts, &server_keys)
.expect("Failed to write known hosts file"); .expect("Failed to write known hosts file");
} }
info!("Client mode: Finished operations");
Ok(()) Ok(())
} }

View File

@ -3,6 +3,7 @@ mod server;
use clap::Parser; use clap::Parser;
use env_logger; use env_logger;
use log::{error, info};
/// This application manages SSH keys and flows, either as a server or client. /// This application manages SSH keys and flows, either as a server or client.
/// In server mode, it stores keys and flows in a PostgreSQL database. /// In server mode, it stores keys and flows in a PostgreSQL database.
@ -11,7 +12,7 @@ use env_logger;
#[command( #[command(
author = env!("CARGO_PKG_AUTHORS"), author = env!("CARGO_PKG_AUTHORS"),
version = env!("CARGO_PKG_VERSION"), version = env!("CARGO_PKG_VERSION"),
about = "SSH Key Manager", about = "SSH Host Key Manager",
long_about = None, long_about = None,
after_help = "Examples:\n\ after_help = "Examples:\n\
\n\ \n\
@ -19,7 +20,7 @@ use env_logger;
khm --server --ip 0.0.0.0 --port 1337 --db-host psql.psql.svc --db-name khm --db-user admin --db-password <SECRET> --flows work,home\n\ khm --server --ip 0.0.0.0 --port 1337 --db-host psql.psql.svc --db-name khm --db-user admin --db-password <SECRET> --flows work,home\n\
\n\ \n\
Running in client mode to send diff and sync ~/.ssh/known_hosts with remote flow in place:\n\ Running in client mode to send diff and sync ~/.ssh/known_hosts with remote flow in place:\n\
khm --host http://kh.example.com:8080 --known_hosts ~/.ssh/known_hosts --in-place\n\ khm --host http://kh.example.com:8080 --known-hosts ~/.ssh/known_hosts --in-place\n\
\n\ \n\
" "
)] )]
@ -109,12 +110,22 @@ struct Args {
#[actix_web::main] #[actix_web::main]
async fn main() -> std::io::Result<()> { async fn main() -> std::io::Result<()> {
env_logger::init(); env_logger::init();
info!("Starting SSH Key Manager");
let args = Args::parse(); let args = Args::parse();
if args.server { if args.server {
server::run_server(args).await info!("Running in server mode");
if let Err(e) = server::run_server(args).await {
error!("Failed to run server: {}", e);
}
} else { } else {
client::run_client(args).await info!("Running in client mode");
if let Err(e) = client::run_client(args).await {
error!("Failed to run client: {}", e);
}
} }
info!("Application has exited");
Ok(())
} }

View File

@ -1,5 +1,5 @@
use actix_web::{web, App, HttpResponse, HttpServer, Responder}; use actix_web::{web, App, HttpResponse, HttpServer, Responder};
use log; use log::{error, info};
use regex::Regex; use regex::Regex;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
@ -51,12 +51,14 @@ pub async fn insert_key_if_not_exists(
&[&row.get::<_, i32>(0)], &[&row.get::<_, i32>(0)],
) )
.await?; .await?;
info!("Updated existing key for server: {}", key.server);
Ok(row.get(0)) Ok(row.get(0))
} else { } else {
let row = client.query_one( let row = client.query_one(
"INSERT INTO public.keys (host, key, updated) VALUES ($1, $2, NOW()) RETURNING key_id", "INSERT INTO public.keys (host, key, updated) VALUES ($1, $2, NOW()) RETURNING key_id",
&[&key.server, &key.public_key] &[&key.server, &key.public_key]
).await?; ).await?;
info!("Inserted new key for server: {}", key.server);
Ok(row.get(0)) Ok(row.get(0))
} }
} }
@ -72,6 +74,7 @@ pub async fn insert_flow_key(
&[&flow_name, &key_id], &[&flow_name, &key_id],
) )
.await?; .await?;
info!("Inserted key_id {} into flow: {}", key_id, flow_name);
Ok(()) Ok(())
} }
@ -106,6 +109,7 @@ pub async fn get_keys_from_db(client: &Client) -> Result<Vec<Flow>, tokio_postgr
} }
} }
info!("Retrieved {} flows from database", flows_map.len());
Ok(flows_map.into_values().collect()) Ok(flows_map.into_values().collect())
} }
@ -116,14 +120,17 @@ pub async fn get_keys(
) -> impl Responder { ) -> impl Responder {
let flow_id_str = flow_id.into_inner(); let flow_id_str = flow_id.into_inner();
if !allowed_flows.contains(&flow_id_str) { if !allowed_flows.contains(&flow_id_str) {
error!("Flow ID not allowed: {}", flow_id_str);
return HttpResponse::Forbidden().body("Flow ID not allowed"); return HttpResponse::Forbidden().body("Flow ID not allowed");
} }
let flows = flows.lock().unwrap(); let flows = flows.lock().unwrap();
if let Some(flow) = flows.iter().find(|flow| flow.name == flow_id_str) { if let Some(flow) = flows.iter().find(|flow| flow.name == flow_id_str) {
let servers: Vec<&SshKey> = flow.servers.iter().collect(); let servers: Vec<&SshKey> = flow.servers.iter().collect();
info!("Returning {} keys for flow: {}", servers.len(), flow_id_str);
HttpResponse::Ok().json(servers) HttpResponse::Ok().json(servers)
} else { } else {
error!("Flow ID not found: {}", flow_id_str);
HttpResponse::NotFound().body("Flow ID not found") HttpResponse::NotFound().body("Flow ID not found")
} }
} }
@ -137,11 +144,13 @@ pub async fn add_keys(
) -> impl Responder { ) -> impl Responder {
let flow_id_str = flow_id.into_inner(); let flow_id_str = flow_id.into_inner();
if !allowed_flows.contains(&flow_id_str) { if !allowed_flows.contains(&flow_id_str) {
error!("Flow ID not allowed: {}", flow_id_str);
return HttpResponse::Forbidden().body("Flow ID not allowed"); return HttpResponse::Forbidden().body("Flow ID not allowed");
} }
for new_key in new_keys.iter() { for new_key in new_keys.iter() {
if !is_valid_ssh_key(&new_key.public_key) { if !is_valid_ssh_key(&new_key.public_key) {
error!("Invalid SSH key format for server: {}", new_key.server);
return HttpResponse::BadRequest().body(format!( return HttpResponse::BadRequest().body(format!(
"Invalid SSH key format for server: {}", "Invalid SSH key format for server: {}",
new_key.server new_key.server
@ -151,31 +160,38 @@ pub async fn add_keys(
match insert_key_if_not_exists(&db_client, new_key).await { match insert_key_if_not_exists(&db_client, new_key).await {
Ok(key_id) => { Ok(key_id) => {
if let Err(e) = insert_flow_key(&db_client, &flow_id_str, key_id).await { if let Err(e) = insert_flow_key(&db_client, &flow_id_str, key_id).await {
log::error!("Failed to insert flow key into database: {}", e); error!("Failed to insert flow key into database: {}", e);
return HttpResponse::InternalServerError() return HttpResponse::InternalServerError()
.body("Failed to insert flow key into database"); .body("Failed to insert flow key into database");
} }
} }
Err(e) => { Err(e) => {
log::error!("Failed to insert key into database: {}", e); error!("Failed to insert key into database: {}", e);
return HttpResponse::InternalServerError() return HttpResponse::InternalServerError()
.body("Failed to insert key into database"); .body("Failed to insert key into database");
} }
} }
} }
// Refresh the flows data from the database let updated_flows = match get_keys_from_db(&db_client).await {
let updated_flows = get_keys_from_db(&db_client) Ok(flows) => flows,
.await Err(e) => {
.unwrap_or_else(|_| Vec::new()); error!("Failed to get updated flows from database: {}", e);
return HttpResponse::InternalServerError()
.body("Failed to refresh flows from database");
}
};
let mut flows_guard = flows.lock().unwrap(); let mut flows_guard = flows.lock().unwrap();
*flows_guard = updated_flows; *flows_guard = updated_flows;
let updated_flow = flows_guard.iter().find(|flow| flow.name == flow_id_str); let updated_flow = flows_guard.iter().find(|flow| flow.name == flow_id_str);
if let Some(flow) = updated_flow { if let Some(flow) = updated_flow {
let servers: Vec<&SshKey> = flow.servers.iter().collect(); let servers: Vec<&SshKey> = flow.servers.iter().collect();
info!("Updated flow: {} with {} keys", flow_id_str, servers.len());
HttpResponse::Ok().json(servers) HttpResponse::Ok().json(servers)
} else { } else {
error!("Flow ID not found after update: {}", flow_id_str);
HttpResponse::NotFound().body("Flow ID not found") HttpResponse::NotFound().body("Flow ID not found")
} }
} }
@ -197,13 +213,17 @@ pub async fn run_server(args: crate::Args) -> std::io::Result<()> {
// Spawn a new thread to run the database connection // Spawn a new thread to run the database connection
tokio::spawn(async move { tokio::spawn(async move {
if let Err(e) = connection.await { if let Err(e) = connection.await {
eprintln!("Connection error: {}", e); error!("Connection error: {}", e);
} }
}); });
let mut initial_flows = get_keys_from_db(&db_client) let mut initial_flows = match get_keys_from_db(&db_client).await {
.await Ok(flows) => flows,
.unwrap_or_else(|_| Vec::new()); Err(e) => {
error!("Failed to get initial flows from database: {}", e);
Vec::new()
}
};
// Ensure all allowed flows are initialized // Ensure all allowed flows are initialized
for allowed_flow in &args.flows { for allowed_flow in &args.flows {
@ -218,6 +238,7 @@ pub async fn run_server(args: crate::Args) -> std::io::Result<()> {
let flows: Flows = Arc::new(Mutex::new(initial_flows)); let flows: Flows = Arc::new(Mutex::new(initial_flows));
let allowed_flows = web::Data::new(args.flows); let allowed_flows = web::Data::new(args.flows);
info!("Starting HTTP server on {}:{}", args.ip, args.port);
HttpServer::new(move || { HttpServer::new(move || {
App::new() App::new()
.app_data(web::Data::new(flows.clone())) .app_data(web::Data::new(flows.clone()))