added support for map port, list server and run server command
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
mod p2prc;
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::process::Command;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, Write};
|
||||
use uuid::Uuid;
|
||||
use crate::p2prc::*;
|
||||
|
||||
use tokio::time::{sleep, Duration};
|
||||
// Struct representing NodeInfo
|
||||
#[derive(Debug)]
|
||||
struct NodeInfo {
|
||||
@@ -72,15 +73,30 @@ fn spin_process(mut process: Process) -> Process {
|
||||
}
|
||||
|
||||
// Main function
|
||||
fn main() {
|
||||
println!("{}", p2prc_map_port_command("3000", "0.0.0.0"));
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Start p2prc in the background
|
||||
tokio::spawn(async {
|
||||
p2prc_start_server().await;
|
||||
});
|
||||
|
||||
// list servers on the network
|
||||
println!("{:#?}", p2prc_list_server_command());
|
||||
|
||||
// Before next instruction sleep for 2 seconds
|
||||
sleep(Duration::from_secs(4)).await;
|
||||
|
||||
// Test map port output
|
||||
println!("{:#?}", p2prc_map_port_command("3000","test.akilan.io",""));
|
||||
|
||||
// println!("{}", p2prc_map_port_command("3000", "0.0.0.0",""));
|
||||
// println!("Starting SpinProcess...");
|
||||
//
|
||||
//
|
||||
// let node_info = NodeInfo {
|
||||
// ipv4: "192.168.1.20".to_string(),
|
||||
// server_port: "9000".to_string(),
|
||||
// };
|
||||
//
|
||||
//
|
||||
// let process = Process {
|
||||
// id: String::new(),
|
||||
// internal_port_no: "".to_string(),
|
||||
@@ -92,8 +108,11 @@ fn main() {
|
||||
// status: false,
|
||||
// domain_name: "example.com".to_string(),
|
||||
// };
|
||||
//
|
||||
//
|
||||
// let updated = spin_process(process);
|
||||
//
|
||||
//
|
||||
// println!("Final Process: {:?}", updated);
|
||||
|
||||
// Start P2PRC as a server to test if the background process works
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user