well structured

4-update-check
plazmoid 4 years ago
parent 1401c0efc4
commit 046ea8d3a3
  1. 5
      Cargo.toml
  2. 1
      bin/u-agent/Cargo.toml
  3. 2
      bin/u-agent/src/main.rs
  4. 0
      bin/u-run/Cargo.toml
  5. 9
      bin/u-run/src/main.rs
  6. 23
      bin/u-server/src/main.rs
  7. 3
      lib/u_lib/Cargo.toml
  8. 10
      lib/u_lib/src/lib.rs
  9. 3
      u-server/src/main.rs

@ -1,6 +1,5 @@
[workspace] [workspace]
members = [ members = [
"u-run", "bin/*",
"u-server", "lib/u_lib"
"u-agent"
] ]

@ -13,6 +13,7 @@ sysinfo = "0.10.5"
#lazy_static = "1.4.0" #lazy_static = "1.4.0"
log = "^0.4" log = "^0.4"
env_logger = "0.7.1" env_logger = "0.7.1"
cron = "0.6.0"
[profile.release] [profile.release]
panic = 'abort' panic = 'abort'

@ -25,6 +25,8 @@ use nix::{
} }
}; };
mod jobs;
fn setsig(sig: Signal, hnd: SigHandler) { fn setsig(sig: Signal, hnd: SigHandler) {
unsafe { unsafe {
signal(sig, hnd).unwrap(); signal(sig, hnd).unwrap();

@ -18,8 +18,8 @@ fn get_uagent_data() -> Option<Vec<u8>> {
// TODO: if not ls - then download // TODO: if not ls - then download
let ls = read_dir("./").unwrap(); let ls = read_dir("./").unwrap();
for dirfile in ls { for dirfile in ls {
let filename: std::path::PathBuf = dirfile.unwrap().path(); let filename = dirfile.unwrap().path();
if filename.ends_with("u-agent") { if filename.to_str().unwrap() == "u-agent" {
let mut file = File::open(filename).unwrap(); let mut file = File::open(filename).unwrap();
let mut data: Vec<u8> = vec![]; let mut data: Vec<u8> = vec![];
file.read_to_end(&mut data).unwrap(); file.read_to_end(&mut data).unwrap();
@ -76,8 +76,9 @@ fn main() {
panic!("write wasn't successful: {}, need {}", panic!("write wasn't successful: {}, need {}",
res_len, ad_len); res_len, ad_len);
} }
let exec_path: String = format!("/proc/{}/fd/{}", let exec_path: String = format!(
unsafe { getpid() }, fd); "/proc/{}/fd/{}", unsafe { getpid() }, fd
);
let proc_name = get_proc_name(); let proc_name = get_proc_name();
let args = [proc_name.as_c_str()]; let args = [proc_name.as_c_str()];
execv( execv(

@ -0,0 +1,23 @@
use warp::{
Filter
};
use env_logger;
use tokio::sync::Mutex;
use std::collections::HashMap;
use u_lib::Client;
type Storage = Mutex<HashMap<String, Client>>;
#[tokio::main]
async fn main() {
env_logger::init();
let db: Storage = Mutex::new(HashMap::<String, Client>::new());
let hello = warp::get().and(warp::path::param())
.map(|p: String| format!("Hello, {} ({})", p, LOL));
//let post = warp::post().and(warp::path("new"))
let routes = hello
.with(warp::log("warp"));
warp::serve(routes).run(([127,0,0,1], 63714)).await;
}

@ -1,5 +1,5 @@
[package] [package]
name = "u-server" name = "u_lib"
version = "0.1.0" version = "0.1.0"
authors = ["plazmoid <kronos44@mail.ru>"] authors = ["plazmoid <kronos44@mail.ru>"]
edition = "2018" edition = "2018"
@ -7,3 +7,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
serde = { version = "1.0.114", features = ["derive"] }

@ -0,0 +1,10 @@
use serde::Deserialize;
#[derive(Deserialize)]
pub struct Client {
pub ip: String,
pub hostname: String,
pub username: String,
pub os: String,
pub platform: String
}

@ -1,3 +0,0 @@
fn main() {
println!("Hello, world!");
}
Loading…
Cancel
Save