Optimize building speed (#442)

Make easytier-cli and easytier-core link to the easytier library to
avoid duplicate linking of mods.
This commit is contained in:
fanyang
2024-10-24 16:21:35 +08:00
committed by GitHub
parent efee3707da
commit b5c3726e67
8 changed files with 64 additions and 89 deletions
+24 -33
View File
@@ -1,33 +1,29 @@
#![allow(dead_code)]
use std::{net::SocketAddr, sync::Mutex, time::Duration, vec};
use anyhow::{Context, Ok};
use clap::{command, Args, Parser, Subcommand};
use common::{constants::EASYTIER_VERSION, stun::StunInfoCollectorTrait};
use proto::{
common::NatType,
peer_rpc::{GetGlobalPeerMapRequest, PeerCenterRpc, PeerCenterRpcClientFactory},
rpc_impl::standalone::StandAloneClient,
rpc_types::controller::BaseController,
};
use tokio::time::timeout;
use tunnel::tcp::TcpTunnelConnector;
use utils::{list_peer_route_pair, PeerRoutePair};
mod arch;
mod common;
mod proto;
mod tunnel;
mod utils;
use crate::{
common::stun::StunInfoCollector,
proto::cli::*,
utils::{cost_to_str, float_to_str},
};
use humansize::format_size;
use tabled::settings::Style;
use tokio::time::timeout;
use easytier::{
common::{constants::EASYTIER_VERSION, stun::StunInfoCollector, stun::StunInfoCollectorTrait},
proto::{
cli::{
ConnectorManageRpc, ConnectorManageRpcClientFactory, DumpRouteRequest,
GetVpnPortalInfoRequest, ListConnectorRequest, ListForeignNetworkRequest,
ListGlobalForeignNetworkRequest, ListPeerRequest, ListPeerResponse, ListRouteRequest,
ListRouteResponse, NodeInfo, PeerManageRpc, PeerManageRpcClientFactory,
ShowNodeInfoRequest, VpnPortalRpc, VpnPortalRpcClientFactory,
},
common::NatType,
peer_rpc::{GetGlobalPeerMapRequest, PeerCenterRpc, PeerCenterRpcClientFactory},
rpc_impl::standalone::StandAloneClient,
rpc_types::controller::BaseController,
},
tunnel::tcp::TcpTunnelConnector,
utils::{cost_to_str, float_to_str, list_peer_route_pair, PeerRoutePair},
};
#[derive(Parser, Debug)]
#[command(name = "easytier-cli", author, version = EASYTIER_VERSION, about, long_about = None)]
@@ -230,7 +226,6 @@ impl CommandHandler {
ipv4: p
.route
.ipv4_addr
.clone()
.map(|ip| ip.to_string())
.unwrap_or_default(),
hostname: p.route.hostname.clone(),
@@ -239,7 +234,7 @@ impl CommandHandler {
loss_rate: float_to_str(p.get_loss_rate().unwrap_or(0.0), 3),
rx_bytes: format_size(p.get_rx_bytes().unwrap_or(0), humansize::DECIMAL),
tx_bytes: format_size(p.get_tx_bytes().unwrap_or(0), humansize::DECIMAL),
tunnel_proto: p.get_conn_protos().unwrap_or(vec![]).join(",").to_string(),
tunnel_proto: p.get_conn_protos().unwrap_or_default().join(",").to_string(),
nat_type: p.get_udp_nat_type(),
id: p.route.peer_id.to_string(),
version: if p.route.version.is_empty() {
@@ -294,7 +289,7 @@ impl CommandHandler {
println!(
"{}",
tabled::Table::new(items).with(Style::modern()).to_string()
tabled::Table::new(items).with(Style::modern())
);
Ok(())
@@ -421,7 +416,6 @@ impl CommandHandler {
ipv4: p
.route
.ipv4_addr
.clone()
.map(|ip| ip.to_string())
.unwrap_or_default(),
hostname: p.route.hostname.clone(),
@@ -441,7 +435,6 @@ impl CommandHandler {
ipv4: p
.route
.ipv4_addr
.clone()
.map(|ip| ip.to_string())
.unwrap_or_default(),
hostname: p.route.hostname.clone(),
@@ -449,7 +442,6 @@ impl CommandHandler {
next_hop_ipv4: next_hop_pair
.route
.ipv4_addr
.clone()
.map(|ip| ip.to_string())
.unwrap_or_default(),
next_hop_hostname: next_hop_pair.route.hostname.clone(),
@@ -466,7 +458,7 @@ impl CommandHandler {
println!(
"{}",
tabled::Table::new(items).with(Style::modern()).to_string()
tabled::Table::new(items).with(Style::modern())
);
Ok(())
@@ -588,7 +580,6 @@ async fn main() -> Result<(), Error> {
"{}",
tabled::Table::new(table_rows)
.with(Style::modern())
.to_string()
);
}
SubCommand::VpnPortal => {
@@ -643,7 +634,7 @@ async fn main() -> Result<(), Error> {
builder.push_record(vec![format!("Listener {}", idx).as_str(), l]);
}
println!("{}", builder.build().with(Style::modern()).to_string());
println!("{}", builder.build().with(Style::modern()));
}
Some(NodeSubCommand::Config) => {
println!("{}", node_info.config);