mirror of
https://github.com/EasyTier/EasyTier.git
synced 2024-11-16 03:32:43 +08:00
fix bugs
add timeout for wss try_accept public server should show stats use default values for flags bump version to 2.0.0
This commit is contained in:
parent
ff5ee8a05e
commit
d0a3a40a0f
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
@ -21,7 +21,7 @@ on:
|
||||||
version:
|
version:
|
||||||
description: 'Version for this release'
|
description: 'Version for this release'
|
||||||
type: string
|
type: string
|
||||||
default: 'v1.2.3'
|
default: 'v2.0.0'
|
||||||
required: true
|
required: true
|
||||||
make_latest:
|
make_latest:
|
||||||
description: 'Mark this release as latest'
|
description: 'Mark this release as latest'
|
||||||
|
|
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -1539,7 +1539,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "easytier"
|
name = "easytier"
|
||||||
version = "1.2.3"
|
version = "2.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm",
|
"aes-gcm",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
@ -1597,6 +1597,7 @@ dependencies = [
|
||||||
"rust-i18n",
|
"rust-i18n",
|
||||||
"rustls",
|
"rustls",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"serial_test",
|
"serial_test",
|
||||||
"smoltcp",
|
"smoltcp",
|
||||||
"socket2",
|
"socket2",
|
||||||
|
@ -1630,7 +1631,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "easytier-gui"
|
name = "easytier-gui"
|
||||||
version = "1.2.3"
|
version = "2.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "easytier-gui",
|
"name": "easytier-gui",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.2.3",
|
"version": "2.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "easytier-gui"
|
name = "easytier-gui"
|
||||||
version = "1.2.3"
|
version = "2.0.0"
|
||||||
description = "EasyTier GUI"
|
description = "EasyTier GUI"
|
||||||
authors = ["you"]
|
authors = ["you"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"createUpdaterArtifacts": false
|
"createUpdaterArtifacts": false
|
||||||
},
|
},
|
||||||
"productName": "easytier-gui",
|
"productName": "easytier-gui",
|
||||||
"version": "1.2.3",
|
"version": "2.0.0",
|
||||||
"identifier": "com.kkrainbow.easytier",
|
"identifier": "com.kkrainbow.easytier",
|
||||||
"plugins": {},
|
"plugins": {},
|
||||||
"app": {
|
"app": {
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "easytier"
|
||||||
description = "A full meshed p2p VPN, connecting all your devices in one network with one command."
|
description = "A full meshed p2p VPN, connecting all your devices in one network with one command."
|
||||||
homepage = "https://github.com/EasyTier/EasyTier"
|
homepage = "https://github.com/EasyTier/EasyTier"
|
||||||
repository = "https://github.com/EasyTier/EasyTier"
|
repository = "https://github.com/EasyTier/EasyTier"
|
||||||
version = "1.2.3"
|
version = "2.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["kkrainbow"]
|
authors = ["kkrainbow"]
|
||||||
keywords = ["vpn", "p2p", "network", "easytier"]
|
keywords = ["vpn", "p2p", "network", "easytier"]
|
||||||
|
@ -125,6 +125,7 @@ rand = "0.8.5"
|
||||||
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
pnet = { version = "0.35.0", features = ["serde"] }
|
pnet = { version = "0.35.0", features = ["serde"] }
|
||||||
|
serde_json = "1"
|
||||||
|
|
||||||
clap = { version = "4.4.8", features = [
|
clap = { version = "4.4.8", features = [
|
||||||
"string",
|
"string",
|
||||||
|
|
|
@ -208,7 +208,10 @@ struct Config {
|
||||||
|
|
||||||
socks5_proxy: Option<url::Url>,
|
socks5_proxy: Option<url::Url>,
|
||||||
|
|
||||||
flags: Option<Flags>,
|
flags: Option<serde_json::Map<String, serde_json::Value>>,
|
||||||
|
|
||||||
|
#[serde(skip)]
|
||||||
|
flags_struct: Option<Flags>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -224,13 +227,15 @@ impl Default for TomlConfigLoader {
|
||||||
|
|
||||||
impl TomlConfigLoader {
|
impl TomlConfigLoader {
|
||||||
pub fn new_from_str(config_str: &str) -> Result<Self, anyhow::Error> {
|
pub fn new_from_str(config_str: &str) -> Result<Self, anyhow::Error> {
|
||||||
let config = toml::de::from_str::<Config>(config_str).with_context(|| {
|
let mut config = toml::de::from_str::<Config>(config_str).with_context(|| {
|
||||||
format!(
|
format!(
|
||||||
"failed to parse config file: {}\n{}",
|
"failed to parse config file: {}\n{}",
|
||||||
config_str, config_str
|
config_str, config_str
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
config.flags_struct = Some(Self::gen_flags(config.flags.clone().unwrap_or_default()));
|
||||||
|
|
||||||
Ok(TomlConfigLoader {
|
Ok(TomlConfigLoader {
|
||||||
config: Arc::new(Mutex::new(config)),
|
config: Arc::new(Mutex::new(config)),
|
||||||
})
|
})
|
||||||
|
@ -248,6 +253,28 @@ impl TomlConfigLoader {
|
||||||
|
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn gen_flags(mut flags_hashmap: serde_json::Map<String, serde_json::Value>) -> Flags {
|
||||||
|
let default_flags_json = serde_json::to_string(&Flags::default()).unwrap();
|
||||||
|
let default_flags_hashmap =
|
||||||
|
serde_json::from_str::<serde_json::Map<String, serde_json::Value>>(&default_flags_json)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
tracing::debug!("default_flags_hashmap: {:?}", default_flags_hashmap);
|
||||||
|
|
||||||
|
let mut merged_hashmap = serde_json::Map::new();
|
||||||
|
for (key, value) in default_flags_hashmap {
|
||||||
|
if let Some(v) = flags_hashmap.remove(&key) {
|
||||||
|
merged_hashmap.insert(key, v);
|
||||||
|
} else {
|
||||||
|
merged_hashmap.insert(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tracing::debug!("merged_hashmap: {:?}", merged_hashmap);
|
||||||
|
|
||||||
|
serde_json::from_value(serde_json::Value::Object(merged_hashmap)).unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigLoader for TomlConfigLoader {
|
impl ConfigLoader for TomlConfigLoader {
|
||||||
|
@ -474,13 +501,13 @@ impl ConfigLoader for TomlConfigLoader {
|
||||||
self.config
|
self.config
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.flags
|
.flags_struct
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_flags(&self, flags: Flags) {
|
fn set_flags(&self, flags: Flags) {
|
||||||
self.config.lock().unwrap().flags = Some(flags);
|
self.config.lock().unwrap().flags_struct = Some(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_exit_nodes(&self) -> Vec<Ipv4Addr> {
|
fn get_exit_nodes(&self) -> Vec<Ipv4Addr> {
|
||||||
|
|
|
@ -23,7 +23,15 @@ impl PeerManagerRpcService {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_peers(&self) -> Vec<PeerInfo> {
|
pub async fn list_peers(&self) -> Vec<PeerInfo> {
|
||||||
let peers = self.peer_manager.get_peer_map().list_peers().await;
|
let mut peers = self.peer_manager.get_peer_map().list_peers().await;
|
||||||
|
peers.extend(
|
||||||
|
self.peer_manager
|
||||||
|
.get_foreign_network_client()
|
||||||
|
.get_peer_map()
|
||||||
|
.list_peers()
|
||||||
|
.await
|
||||||
|
.iter(),
|
||||||
|
);
|
||||||
let mut peer_infos = Vec::new();
|
let mut peer_infos = Vec::new();
|
||||||
for peer in peers {
|
for peer in peers {
|
||||||
let mut peer_info = PeerInfo::default();
|
let mut peer_info = PeerInfo::default();
|
||||||
|
@ -31,6 +39,14 @@ impl PeerManagerRpcService {
|
||||||
|
|
||||||
if let Some(conns) = self.peer_manager.get_peer_map().list_peer_conns(peer).await {
|
if let Some(conns) = self.peer_manager.get_peer_map().list_peer_conns(peer).await {
|
||||||
peer_info.conns = conns;
|
peer_info.conns = conns;
|
||||||
|
} else if let Some(conns) = self
|
||||||
|
.peer_manager
|
||||||
|
.get_foreign_network_client()
|
||||||
|
.get_peer_map()
|
||||||
|
.list_peer_conns(peer)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
peer_info.conns = conns;
|
||||||
}
|
}
|
||||||
|
|
||||||
peer_infos.push(peer_info);
|
peer_infos.push(peer_info);
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
use std::{net::SocketAddr, sync::Arc};
|
use std::{net::SocketAddr, sync::Arc, time::Duration};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use futures::{stream::FuturesUnordered, SinkExt, StreamExt};
|
use futures::{stream::FuturesUnordered, SinkExt, StreamExt};
|
||||||
use tokio::net::{TcpListener, TcpSocket, TcpStream};
|
use tokio::{
|
||||||
|
net::{TcpListener, TcpSocket, TcpStream},
|
||||||
|
time::timeout,
|
||||||
|
};
|
||||||
use tokio_rustls::TlsAcceptor;
|
use tokio_rustls::TlsAcceptor;
|
||||||
use tokio_websockets::{ClientBuilder, Limits, MaybeTlsStream, Message};
|
use tokio_websockets::{ClientBuilder, Limits, MaybeTlsStream, Message};
|
||||||
use zerocopy::AsBytes;
|
use zerocopy::AsBytes;
|
||||||
|
@ -141,9 +144,9 @@ impl TunnelListener for WSTunnelListener {
|
||||||
// only fail on tcp accept error
|
// only fail on tcp accept error
|
||||||
let (stream, _) = listener.accept().await?;
|
let (stream, _) = listener.accept().await?;
|
||||||
stream.set_nodelay(true).unwrap();
|
stream.set_nodelay(true).unwrap();
|
||||||
match self.try_accept(stream).await {
|
match timeout(Duration::from_secs(3), self.try_accept(stream)).await {
|
||||||
Ok(tunnel) => return Ok(tunnel),
|
Ok(Ok(tunnel)) => return Ok(tunnel),
|
||||||
Err(e) => {
|
e => {
|
||||||
tracing::error!(?e, ?self, "Failed to accept ws/wss tunnel");
|
tracing::error!(?e, ?self, "Failed to accept ws/wss tunnel");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user