added CommandLineInput
This commit is contained in:
parent
a680c1ece8
commit
b59570b297
@ -1,15 +1,18 @@
|
||||
use sdlan_rs::get_edge;
|
||||
use sdlan_rs::run_sdlan;
|
||||
use sdlan_rs::CommandLine;
|
||||
use sdlan_rs::CommandLineInput;
|
||||
use sdlan_sn_rs::log;
|
||||
|
||||
use structopt::StructOpt;
|
||||
use std::time::Duration;
|
||||
use tokio::sync::mpsc::Sender;
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let _guard = log::init_log();
|
||||
|
||||
let cmd = CommandLineInput::from_args();
|
||||
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
let _ = run_sdlan(
|
||||
CommandLine {
|
||||
@ -22,12 +25,12 @@ async fn main() {
|
||||
mtu: 1290,
|
||||
name: "tau".to_owned(),
|
||||
tos: 0,
|
||||
token: "".to_owned(),
|
||||
token: cmd.token,
|
||||
allow_p2p: true,
|
||||
}, tx,
|
||||
).await;
|
||||
|
||||
rx.recv();
|
||||
let _ = rx.recv();
|
||||
|
||||
let edge = get_edge();
|
||||
edge.start("0".to_owned()).await;
|
||||
|
||||
@ -13,7 +13,7 @@ use network::{async_main, init_edge, NodeConfig};
|
||||
use tokio::sync::mpsc::channel;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::{debug, error};
|
||||
pub use utils::CommandLine;
|
||||
pub use utils::{CommandLine, CommandLineInput};
|
||||
|
||||
use sdlan_sn_rs::{
|
||||
peer::SdlanSock,
|
||||
|
||||
@ -612,6 +612,7 @@ async fn send_register(eee: &Node, sock: &SdlanSock, _v6_info: &Option<V6Info>)
|
||||
|
||||
let msg = encode_to_udp_message(Some(register), PacketType::Register as u8).unwrap();
|
||||
|
||||
println!("send register to {}", sock.to_string());
|
||||
let _ = send_to_sock(eee, &msg, sock).await;
|
||||
/*
|
||||
let key = eee.get_header_key();
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub struct CommandLineInput {
|
||||
#[structopt(long = "token", default_value = "")]
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub struct CommandLine {
|
||||
#[structopt(short = "s", long = "sn", default_value = "127.0.0.1:7655")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user