saving current changes
This commit is contained in:
@@ -98,6 +98,15 @@ async fn main() {
|
|||||||
|
|
||||||
println!("{:#?}", p2prc_read_config());
|
println!("{:#?}", p2prc_read_config());
|
||||||
|
|
||||||
|
// p2prc_default_config();
|
||||||
|
|
||||||
|
// println!("{:#?}", p2prc_read_config());
|
||||||
|
|
||||||
|
println!("{:#?}", p2prc_get_specs("217.76.63.222:32921".to_string()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
|
use std::net::IpAddr;
|
||||||
use std::process::{Command, Output};
|
use std::process::{Command, Output};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
@@ -90,6 +91,20 @@ pub struct MapPort {
|
|||||||
pub entire_address: String,
|
pub entire_address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct Specs {
|
||||||
|
#[serde(rename = "Hostname")]
|
||||||
|
pub hostname: String,
|
||||||
|
#[serde(rename = "Platform")]
|
||||||
|
pub platform: String,
|
||||||
|
#[serde(rename = "CPU")]
|
||||||
|
pub cpu: String,
|
||||||
|
#[serde(rename = "RAM")]
|
||||||
|
pub ram: i64,
|
||||||
|
#[serde(rename = "Disk")]
|
||||||
|
pub disk: i64,
|
||||||
|
}
|
||||||
|
|
||||||
// Runs p2prc with custom arguments called.
|
// Runs p2prc with custom arguments called.
|
||||||
// Function implemented as an identity function
|
// Function implemented as an identity function
|
||||||
pub fn run_p2prc_command<T>(arguments: &str) -> T
|
pub fn run_p2prc_command<T>(arguments: &str) -> T
|
||||||
@@ -160,3 +175,17 @@ pub fn p2prc_write_config(config: Config) {
|
|||||||
fs::write(config.config_path, json).expect("Panic message: ");
|
fs::write(config.config_path, json).expect("Panic message: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set default config (--dc command)
|
||||||
|
pub fn p2prc_default_config() {
|
||||||
|
let _: Option<bool> = run_p2prc_command(&*"--dc".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get hardware information of a remote server
|
||||||
|
pub fn p2prc_get_specs(ip_addr: String) -> Specs {
|
||||||
|
let command: String = format!("--specs {}", ip_addr);
|
||||||
|
let specs: Specs = run_p2prc_command(&*command);
|
||||||
|
specs
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user