add more debug info for route (#155)
1. use info log for sync_route_info 2. allow dump route info with cli tool. 3. dump route info every 60s
This commit is contained in:
@@ -42,7 +42,7 @@ enum SubCommand {
|
||||
Peer(PeerArgs),
|
||||
Connector(ConnectorArgs),
|
||||
Stun,
|
||||
Route,
|
||||
Route(RouteArgs),
|
||||
PeerCenter,
|
||||
VpnPortal,
|
||||
}
|
||||
@@ -72,6 +72,18 @@ enum PeerSubCommand {
|
||||
List(PeerListArgs),
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct RouteArgs {
|
||||
#[command(subcommand)]
|
||||
sub_command: Option<RouteSubCommand>,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
enum RouteSubCommand {
|
||||
List,
|
||||
Dump,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
struct ConnectorArgs {
|
||||
#[arg(short, long)]
|
||||
@@ -204,6 +216,14 @@ impl CommandHandler {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_route_dump(&self) -> Result<(), Error> {
|
||||
let mut client = self.get_peer_manager_client().await?;
|
||||
let request = tonic::Request::new(DumpRouteRequest::default());
|
||||
let response = client.dump_route(request).await?;
|
||||
println!("response: {}", response.into_inner().result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_route_list(&self) -> Result<(), Error> {
|
||||
#[derive(tabled::Tabled)]
|
||||
struct RouteTableItem {
|
||||
@@ -307,9 +327,10 @@ async fn main() -> Result<(), Error> {
|
||||
handler.handle_connector_list().await?;
|
||||
}
|
||||
},
|
||||
SubCommand::Route => {
|
||||
handler.handle_route_list().await?;
|
||||
}
|
||||
SubCommand::Route(route_args) => match route_args.sub_command {
|
||||
Some(RouteSubCommand::List) | None => handler.handle_route_list().await?,
|
||||
Some(RouteSubCommand::Dump) => handler.handle_route_dump().await?,
|
||||
},
|
||||
SubCommand::Stun => {
|
||||
timeout(Duration::from_secs(5), async move {
|
||||
let collector = StunInfoCollector::new_with_default_servers();
|
||||
|
||||
Reference in New Issue
Block a user