完善1.2.2
This commit is contained in:
+14
-14
@@ -110,40 +110,40 @@ jobs:
|
||||
# some additional configuration for cross-compilation on linux
|
||||
cat >>~/.cargo/config <<EOF
|
||||
[target.x86_64-unknown-linux-musl]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.aarch64-unknown-linux-gnu]
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.aarch64-unknown-linux-musl]
|
||||
linker = "aarch64-linux-gnu-gcc"
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.armv7-unknown-linux-gnueabihf]
|
||||
linker = "arm-linux-gnueabihf-gcc"
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.armv7-unknown-linux-musleabihf]
|
||||
linker = "arm-linux-gnueabihf-gcc"
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.arm-unknown-linux-gnueabihf]
|
||||
linker = "arm-linux-gnueabihf-gcc"
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.arm-unknown-linux-musleabihf]
|
||||
linker = "arm-linux-gnueabihf-gcc"
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.mipsel-unknown-linux-musl]
|
||||
linker = "mipsel-linux-gnu-gcc"
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.x86_64-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.i686-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.x86_64-apple-darwin]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.aarch64-apple-darwin]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.i686-unknown-linux-musl]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
[target.x86_64-unknown-linux-gnu]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "target-feature=+aes","--cfg","aes_armv8"]
|
||||
rustflags = ["-C", "target-feature=+crt-static","-C", "strip=symbols","--cfg","aes_armv8"]
|
||||
EOF
|
||||
- name: Install rust target
|
||||
run: rustup target add $TARGET
|
||||
|
||||
@@ -29,6 +29,7 @@ pub struct DeviceItem {
|
||||
pub nat_type: String,
|
||||
pub public_ips: String,
|
||||
pub local_ip: String,
|
||||
pub ipv6: String,
|
||||
pub nat_traversal_type: String,
|
||||
pub rt: String,
|
||||
pub status: String,
|
||||
|
||||
@@ -81,16 +81,17 @@ pub fn command_list(vnt: &Vnt) -> Vec<DeviceItem> {
|
||||
for peer in device_list {
|
||||
let name = peer.name;
|
||||
let virtual_ip = peer.virtual_ip.to_string();
|
||||
let (nat_type, public_ips, local_ip) =
|
||||
let (nat_type, public_ips, local_ip,ipv6) =
|
||||
if let Some(nat_info) = vnt.peer_nat_info(&peer.virtual_ip) {
|
||||
let nat_type = format!("{:?}", nat_info.nat_type);
|
||||
let public_ips: Vec<String> =
|
||||
nat_info.public_ips.iter().map(|v| v.to_string()).collect();
|
||||
let public_ips = public_ips.join(",");
|
||||
let local_ip = nat_info.local_ipv4_addr.ip().to_string();
|
||||
(nat_type, public_ips, local_ip)
|
||||
let ipv6 = nat_info.ipv6_addr.ip().to_string();
|
||||
(nat_type, public_ips, local_ip,ipv6)
|
||||
} else {
|
||||
("".to_string(), "".to_string(), "".to_string())
|
||||
("".to_string(), "".to_string(), "".to_string(), "".to_string())
|
||||
};
|
||||
let (nat_traversal_type, rt) = if let Some(route) = vnt.route(&peer.virtual_ip) {
|
||||
let nat_traversal_type = if route.metric == 1 {
|
||||
@@ -118,6 +119,7 @@ pub fn command_list(vnt: &Vnt) -> Vec<DeviceItem> {
|
||||
nat_type,
|
||||
public_ips,
|
||||
local_ip,
|
||||
ipv6,
|
||||
nat_traversal_type,
|
||||
rt,
|
||||
status,
|
||||
|
||||
@@ -125,6 +125,7 @@ pub fn console_device_list_all(mut list: Vec<DeviceItem>) {
|
||||
("NAT Type".to_string(), Style::new()),
|
||||
("Public Ips".to_string(), Style::new()),
|
||||
("Local Ip".to_string(), Style::new()),
|
||||
("IPv6".to_string(), Style::new()),
|
||||
]);
|
||||
for item in list {
|
||||
if &item.status == "Online" {
|
||||
@@ -138,6 +139,7 @@ pub fn console_device_list_all(mut list: Vec<DeviceItem>) {
|
||||
(item.nat_type, Style::new().green()),
|
||||
(item.public_ips, Style::new().green()),
|
||||
(item.local_ip, Style::new().green()),
|
||||
(item.ipv6, Style::new().green()),
|
||||
]);
|
||||
} else {
|
||||
out_list.push(vec![
|
||||
@@ -149,6 +151,7 @@ pub fn console_device_list_all(mut list: Vec<DeviceItem>) {
|
||||
(item.nat_type, Style::new().yellow()),
|
||||
(item.public_ips, Style::new().yellow()),
|
||||
(item.local_ip, Style::new().yellow()),
|
||||
(item.ipv6, Style::new().yellow()),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
@@ -161,6 +164,7 @@ pub fn console_device_list_all(mut list: Vec<DeviceItem>) {
|
||||
("".to_string(), Style::new().color256(102)),
|
||||
("".to_string(), Style::new().color256(102)),
|
||||
("".to_string(), Style::new().color256(102)),
|
||||
("".to_string(), Style::new().color256(102)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -424,8 +424,9 @@ async fn main0(config: Config, show_cmd: bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(unix)]
|
||||
tokio::select! {
|
||||
}
|
||||
#[cfg(unix)]
|
||||
tokio::select! {
|
||||
_ = vnt.wait_stop()=>{
|
||||
return;
|
||||
}
|
||||
@@ -439,8 +440,8 @@ async fn main0(config: Config, show_cmd: bool) {
|
||||
vnt.wait_stop_ms(std::time::Duration::from_secs(3)).await;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
vnt.wait_stop().await;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ pub enum VntStatus {
|
||||
}
|
||||
|
||||
pub struct VntWorker {
|
||||
_name: String,
|
||||
name: String,
|
||||
wg: WaitGroup,
|
||||
status_s: Arc<Sender<VntStatus>>,
|
||||
status_r: Receiver<VntStatus>,
|
||||
@@ -20,7 +20,7 @@ impl VntWorker {
|
||||
pub fn worker(&self, name: &str) -> Self {
|
||||
self.wg.add();
|
||||
VntWorker {
|
||||
_name: name.to_string(),
|
||||
name: name.to_string(),
|
||||
wg: self.wg.clone(),
|
||||
status_s: self.status_s.clone(),
|
||||
status_r: self.status_r.clone(),
|
||||
@@ -30,6 +30,7 @@ impl VntWorker {
|
||||
|
||||
impl Drop for VntWorker {
|
||||
fn drop(&mut self) {
|
||||
log::info!("任务停止:{}", self.name);
|
||||
self.wg.done();
|
||||
}
|
||||
}
|
||||
@@ -82,7 +83,7 @@ impl VntStatusManger {
|
||||
pub fn worker(&self, name: &str) -> VntWorker {
|
||||
self.wg.add();
|
||||
VntWorker {
|
||||
_name: name.to_string(),
|
||||
name: name.to_string(),
|
||||
wg: self.wg.clone(),
|
||||
status_s: self.status_s.clone(),
|
||||
status_r: self.status_r.clone(),
|
||||
|
||||
@@ -178,17 +178,28 @@ async fn start_heartbeat_(
|
||||
peer.virtual_ip,
|
||||
);
|
||||
if let Some(route) = sender.route_one(&peer.virtual_ip) {
|
||||
let _ = sender
|
||||
if let Err(e) = sender
|
||||
.send_by_key(client_packet.buffer(), &route.route_key())
|
||||
.await;
|
||||
.await
|
||||
{
|
||||
log::warn!("virtual_ip:{},route:{:?},e:{:?}", peer.virtual_ip, route, e);
|
||||
}
|
||||
if route.is_p2p() {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
//没有直连路由则发送到网关
|
||||
let _ = sender
|
||||
if let Err(e) = sender
|
||||
.send_main(client_packet.buffer(), current_dev.connect_server)
|
||||
.await;
|
||||
.await
|
||||
{
|
||||
log::warn!(
|
||||
"virtual_ip:{},connect_server:{:?},e:{:?}",
|
||||
peer.virtual_ip,
|
||||
current_dev.connect_server,
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//再随机发送到其他地址,看有没有客户端符合转发条件
|
||||
@@ -201,8 +212,16 @@ async fn start_heartbeat_(
|
||||
'a: for (peer_ip, route_list) in route_list.iter() {
|
||||
for route in route_list {
|
||||
if peer_ip != &peer.virtual_ip && route.is_p2p() {
|
||||
let _ =
|
||||
sender.try_send_by_key(client_packet.buffer(), &route.route_key());
|
||||
if let Err(e) =
|
||||
sender.try_send_by_key(client_packet.buffer(), &route.route_key())
|
||||
{
|
||||
log::warn!(
|
||||
"virtual_ip:{},route:{:?},e:{:?}",
|
||||
peer.virtual_ip,
|
||||
route,
|
||||
e
|
||||
);
|
||||
}
|
||||
num += 1;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user