mirror of
https://github.com/EasyTier/EasyTier.git
synced 2024-11-16 11:42:27 +08:00
Optimize building speed (#442)
Some checks failed
EasyTier Core / pre_job (push) Has been cancelled
EasyTier GUI / pre_job (push) Has been cancelled
EasyTier Mobile / pre_job (push) Has been cancelled
EasyTier Test / pre_job (push) Has been cancelled
EasyTier Core / build (freebsd-13.2-x86_64, 13.2, ubuntu-22.04, x86_64-unknown-freebsd) (push) Has been cancelled
EasyTier Core / build (linux-aarch64, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-arm, ubuntu-22.04, arm-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armhf, ubuntu-22.04, arm-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-armv7, ubuntu-22.04, armv7-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armv7hf, ubuntu-22.04, armv7-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-mips, ubuntu-22.04, mips-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-mipsel, ubuntu-22.04, mipsel-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-x86_64, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (macos-aarch64, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (macos-x86_64, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / core-result (push) Has been cancelled
EasyTier GUI / build-gui (linux-aarch64, aarch64-unknown-linux-gnu, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (linux-x86_64, x86_64-unknown-linux-gnu, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (macos-aarch64, aarch64-apple-darwin, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (macos-x86_64, x86_64-apple-darwin, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (windows-x86_64, x86_64-pc-windows-msvc, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / gui-result (push) Has been cancelled
EasyTier Mobile / build-mobile (android, ubuntu-22.04, android) (push) Has been cancelled
EasyTier Mobile / mobile-result (push) Has been cancelled
EasyTier Test / test (push) Has been cancelled
Some checks failed
EasyTier Core / pre_job (push) Has been cancelled
EasyTier GUI / pre_job (push) Has been cancelled
EasyTier Mobile / pre_job (push) Has been cancelled
EasyTier Test / pre_job (push) Has been cancelled
EasyTier Core / build (freebsd-13.2-x86_64, 13.2, ubuntu-22.04, x86_64-unknown-freebsd) (push) Has been cancelled
EasyTier Core / build (linux-aarch64, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-arm, ubuntu-22.04, arm-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armhf, ubuntu-22.04, arm-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-armv7, ubuntu-22.04, armv7-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armv7hf, ubuntu-22.04, armv7-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-mips, ubuntu-22.04, mips-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-mipsel, ubuntu-22.04, mipsel-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-x86_64, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (macos-aarch64, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (macos-x86_64, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / core-result (push) Has been cancelled
EasyTier GUI / build-gui (linux-aarch64, aarch64-unknown-linux-gnu, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (linux-x86_64, x86_64-unknown-linux-gnu, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (macos-aarch64, aarch64-apple-darwin, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (macos-x86_64, x86_64-apple-darwin, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (windows-x86_64, x86_64-pc-windows-msvc, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / gui-result (push) Has been cancelled
EasyTier Mobile / build-mobile (android, ubuntu-22.04, android) (push) Has been cancelled
EasyTier Mobile / mobile-result (push) Has been cancelled
EasyTier Test / test (push) Has been cancelled
Make easytier-cli and easytier-core link to the easytier library to avoid duplicate linking of mods.
This commit is contained in:
parent
efee3707da
commit
b5c3726e67
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,6 +11,7 @@ target-*/
|
|||
*.pdb
|
||||
|
||||
.vscode
|
||||
/.idea
|
||||
|
||||
# perf & flamegraph
|
||||
perf.data
|
||||
|
|
|
@ -21,12 +21,10 @@ path = "src/easytier-core.rs"
|
|||
[[bin]]
|
||||
name = "easytier-cli"
|
||||
path = "src/easytier-cli.rs"
|
||||
test = false
|
||||
|
||||
[lib]
|
||||
name = "easytier"
|
||||
path = "src/lib.rs"
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
git-version = "0.3.9"
|
||||
|
|
|
@ -147,7 +147,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.type_attribute("peer_rpc.ForeignNetworkRouteInfoKey", "#[derive(Hash, Eq)]")
|
||||
.type_attribute("common.RpcDescriptor", "#[derive(Hash, Eq)]")
|
||||
.service_generator(Box::new(rpc_build::ServiceGenerator::new()))
|
||||
.btree_map(&["."])
|
||||
.btree_map(["."])
|
||||
.compile_protos(&proto_files, &["src/proto/"])
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -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::{
|
||||
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},
|
||||
};
|
||||
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;
|
||||
|
||||
#[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);
|
||||
|
|
|
@ -1,51 +1,31 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[macro_use]
|
||||
extern crate rust_i18n;
|
||||
|
||||
use std::{
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
#[macro_use]
|
||||
extern crate rust_i18n;
|
||||
|
||||
use anyhow::Context;
|
||||
use clap::Parser;
|
||||
|
||||
mod arch;
|
||||
mod common;
|
||||
mod connector;
|
||||
mod gateway;
|
||||
mod instance;
|
||||
mod launcher;
|
||||
mod peer_center;
|
||||
mod peers;
|
||||
mod proto;
|
||||
mod tunnel;
|
||||
mod utils;
|
||||
mod vpn_portal;
|
||||
|
||||
use common::{
|
||||
config::{ConsoleLoggerConfig, FileLoggerConfig, NetworkIdentity, PeerConfig, VpnPortalConfig},
|
||||
constants::EASYTIER_VERSION,
|
||||
global_ctx::EventBusSubscriber,
|
||||
scoped_task::ScopedTask,
|
||||
};
|
||||
use tokio::net::TcpSocket;
|
||||
use utils::setup_panic_handler;
|
||||
|
||||
use crate::{
|
||||
use easytier::{
|
||||
common::{
|
||||
config::{ConfigLoader, TomlConfigLoader},
|
||||
global_ctx::GlobalCtxEvent,
|
||||
config::{
|
||||
ConfigLoader, ConsoleLoggerConfig, FileLoggerConfig, NetworkIdentity, PeerConfig,
|
||||
TomlConfigLoader, VpnPortalConfig,
|
||||
},
|
||||
utils::init_logger,
|
||||
constants::EASYTIER_VERSION,
|
||||
global_ctx::{EventBusSubscriber, GlobalCtxEvent},
|
||||
scoped_task::ScopedTask,
|
||||
},
|
||||
launcher, proto,
|
||||
utils::{init_logger, setup_panic_handler},
|
||||
};
|
||||
|
||||
#[cfg(feature = "mimalloc")]
|
||||
use mimalloc_rust::*;
|
||||
use mimalloc_rust::GlobalMiMalloc;
|
||||
|
||||
#[cfg(feature = "mimalloc")]
|
||||
#[global_allocator]
|
||||
|
@ -509,7 +489,7 @@ impl From<Cli> for TomlConfigLoader {
|
|||
f.enable_encryption = !cli.disable_encryption;
|
||||
f.enable_ipv6 = !cli.disable_ipv6;
|
||||
f.latency_first = cli.latency_first;
|
||||
f.dev_name = cli.dev_name.unwrap_or(Default::default());
|
||||
f.dev_name = cli.dev_name.unwrap_or_default();
|
||||
if let Some(mtu) = cli.mtu {
|
||||
f.mtu = mtu;
|
||||
}
|
||||
|
@ -544,7 +524,7 @@ fn print_event(msg: String) {
|
|||
);
|
||||
}
|
||||
|
||||
fn peer_conn_info_to_string(p: crate::proto::cli::PeerConnInfo) -> String {
|
||||
fn peer_conn_info_to_string(p: proto::cli::PeerConnInfo) -> String {
|
||||
format!(
|
||||
"my_peer_id: {}, dst_peer_id: {}, tunnel_info: {:?}",
|
||||
p.my_peer_id, p.peer_id, p.tunnel
|
||||
|
|
|
@ -5,13 +5,16 @@ mod connector;
|
|||
mod gateway;
|
||||
mod instance;
|
||||
mod peer_center;
|
||||
mod peers;
|
||||
mod vpn_portal;
|
||||
|
||||
pub mod common;
|
||||
pub mod launcher;
|
||||
pub mod peers;
|
||||
pub mod proto;
|
||||
pub mod tunnel;
|
||||
pub mod utils;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub const VERSION: &str = common::constants::EASYTIER_VERSION;
|
||||
|
|
|
@ -6,4 +6,5 @@ pub mod common;
|
|||
pub mod error;
|
||||
pub mod peer_rpc;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use crate::common::PeerId;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod three_node;
|
||||
|
||||
use crate::common::PeerId;
|
||||
use crate::peers::peer_manager::PeerManager;
|
||||
|
||||
pub fn get_guest_veth_name(net_ns: &str) -> &str {
|
||||
Box::leak(format!("veth_{}_g", net_ns).into_boxed_str())
|
||||
}
|
||||
|
@ -14,29 +15,29 @@ pub fn get_host_veth_name(net_ns: &str) -> &str {
|
|||
pub fn del_netns(name: &str) {
|
||||
// del veth host
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&["link", "del", get_host_veth_name(name)])
|
||||
.args(["link", "del", get_host_veth_name(name)])
|
||||
.output();
|
||||
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&["netns", "del", name])
|
||||
.args(["netns", "del", name])
|
||||
.output();
|
||||
}
|
||||
|
||||
pub fn create_netns(name: &str, ipv4: &str) {
|
||||
// create netns
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&["netns", "add", name])
|
||||
.args(["netns", "add", name])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
// set lo up
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&["netns", "exec", name, "ip", "link", "set", "lo", "up"])
|
||||
.args(["netns", "exec", name, "ip", "link", "set", "lo", "up"])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&[
|
||||
.args([
|
||||
"link",
|
||||
"add",
|
||||
get_host_veth_name(name),
|
||||
|
@ -50,12 +51,12 @@ pub fn create_netns(name: &str, ipv4: &str) {
|
|||
.unwrap();
|
||||
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&["link", "set", get_guest_veth_name(name), "netns", name])
|
||||
.args(["link", "set", get_guest_veth_name(name), "netns", name])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&[
|
||||
.args([
|
||||
"netns",
|
||||
"exec",
|
||||
name,
|
||||
|
@ -69,12 +70,12 @@ pub fn create_netns(name: &str, ipv4: &str) {
|
|||
.unwrap();
|
||||
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&["link", "set", get_host_veth_name(name), "up"])
|
||||
.args(["link", "set", get_host_veth_name(name), "up"])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&[
|
||||
.args([
|
||||
"netns",
|
||||
"exec",
|
||||
name,
|
||||
|
@ -92,25 +93,25 @@ pub fn create_netns(name: &str, ipv4: &str) {
|
|||
pub fn prepare_bridge(name: &str) {
|
||||
// del bridge with brctl
|
||||
let _ = std::process::Command::new("brctl")
|
||||
.args(&["delbr", name])
|
||||
.args(["delbr", name])
|
||||
.output();
|
||||
|
||||
// create new br
|
||||
let _ = std::process::Command::new("brctl")
|
||||
.args(&["addbr", name])
|
||||
.args(["addbr", name])
|
||||
.output();
|
||||
}
|
||||
|
||||
pub fn add_ns_to_bridge(br_name: &str, ns_name: &str) {
|
||||
// use brctl to add ns to bridge
|
||||
let _ = std::process::Command::new("brctl")
|
||||
.args(&["addif", br_name, get_host_veth_name(ns_name)])
|
||||
.args(["addif", br_name, get_host_veth_name(ns_name)])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
// set bridge up
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&["link", "set", br_name, "up"])
|
||||
.args(["link", "set", br_name, "up"])
|
||||
.output()
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -143,7 +144,7 @@ fn check_route(ipv4: &str, dst_peer_id: PeerId, routes: Vec<crate::proto::cli::R
|
|||
}
|
||||
|
||||
async fn wait_proxy_route_appear(
|
||||
mgr: &std::sync::Arc<crate::peers::peer_manager::PeerManager>,
|
||||
mgr: &std::sync::Arc<PeerManager>,
|
||||
ipv4: &str,
|
||||
dst_peer_id: PeerId,
|
||||
proxy_cidr: &str,
|
||||
|
@ -167,7 +168,7 @@ async fn wait_proxy_route_appear(
|
|||
|
||||
fn set_link_status(net_ns: &str, up: bool) {
|
||||
let _ = std::process::Command::new("ip")
|
||||
.args(&[
|
||||
.args([
|
||||
"netns",
|
||||
"exec",
|
||||
net_ns,
|
||||
|
|
Loading…
Reference in New Issue
Block a user