Compare commits

...
6 Commits
Author SHA1 Message Date
lubeilin 959f2aa783 修改版本 2023-08-29 21:15:48 +08:00
lubeilin 99b2aa9522 修改linux上kill不退出的问题 2023-08-29 21:15:39 +08:00
lubeilin 561fa9f8fe Merge remote-tracking branch 'origin/dev' into dev 2023-08-29 21:03:36 +08:00
lubeilin ad9dd6a7f7 增加tun创建失败的说明 2023-08-29 21:03:27 +08:00
lbl8603 65758eb94c Update README.md 2023-08-29 10:39:03 +08:00
lubeilin fb7ccf4d11 增加参数说明 2023-08-29 00:21:25 +08:00
11 changed files with 67 additions and 14 deletions
+28
View File
@@ -86,6 +86,34 @@ A virtual network tool (VPN)
- p2p组播/广播
- 客户端数据加密
- 服务端数据加密
### 结构
<details> <summary>展开</summary>
<pre>
0 15 31
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|e |s |unused| 版本(4) | 协议(8) | 上层协议(8) |初始ttl(4)|生存时间(4) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 源ip地址(32) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 目的ip地址(32) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 数据体(n) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| 指纹(96) |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
注:
1. e为是否加密标志,s为服务端通信包标志,unused占两位未使用;
2. 开启加密时,数据体为加密后的密文(加密方式取决于密码长度和加密模式),
且会存在指纹,指纹使用sha256生成,用于对数据包完整性和真实性的校验
</pre>
</details>
### Todo
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "common"
version = "1.2.0"
version = "1.2.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "vnt-cli"
version = "1.2.0"
version = "1.2.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+11 -1
View File
@@ -50,9 +50,19 @@
### --ip `<IP>`
指定虚拟ip,指定的ip不能和其他设备重复,必须有效并且在服务端所属网段下,默认情况由服务端分配
### --par `<parallel>`
任务并行度(必须为正整数),默认值为2,该值表示处理网卡读写的任务数,组网设备数较多、处理延迟较大时可适当调大此值
任务并行度(必须为正整数),默认值为1,该值表示处理网卡读写的任务数,组网设备数较多、处理延迟较大时可适当调大此值
### --thread `<thread>`
线程数(必须为正整数),默认为核心数乘2,该值表示处理网络读写、ip代理、打洞等用到的线程数,组网设备数较多、处理延迟较大时可适当调大此值
### --model `<model>`
加密模式,可选值 aes_gcm/aes_cbc,默认使用aes_gcm,通常情况使用aes_cbc性能更好
| 密码位数 | model | 加密算法 |
|-------|--------|------------|
| 1~8位 | aes_gcm | AES128-GCM |
| `>=`8 | aes_gcm | AES256-GCM |
| 1~8位 | aes_cbc | AES128-CBC |
| `>=`8 | aes_cbc | AES256-CBC |
### --relay
禁用p2p,在网络环境很差时,只使用服务器中转效果可能更好(可以配合--tcp参数一起使用)
### --list
+20 -4
View File
@@ -208,7 +208,7 @@ fn main() {
println!("--thread invalid");
return;
}
println!("version 1.2.0");
println!("version {}",vnt::VNT_VERSION);
let config = Config::new(tap,
token, device_id, name,
server_address, server_address_str,
@@ -348,7 +348,7 @@ async fn main0(config: Config, show_cmd: bool) {
#[cfg(unix)]
tokio::select! {
_ = vnt.wait_stop()=>{
break;
return;
}
_ = signal::ctrl_c()=>{
let _ = vnt.stop();
@@ -377,7 +377,7 @@ async fn main0(config: Config, show_cmd: bool) {
#[cfg(windows)]
tokio::select! {
_ = vnt.wait_stop()=>{
break;
return;
}
_ = signal::ctrl_c()=>{
let _ = vnt.stop();
@@ -399,6 +399,22 @@ async fn main0(config: Config, show_cmd: bool) {
}
}
}
#[cfg(unix)]
tokio::select! {
_ = vnt.wait_stop()=>{
return;
}
_ = signal::ctrl_c()=>{
let _ = vnt.stop();
vnt.wait_stop_ms(std::time::Duration::from_secs(3)).await;
return;
}
_ = sigterm.recv()=>{
let _ = vnt.stop();
vnt.wait_stop_ms(std::time::Duration::from_secs(3)).await;
return;
}
}
}
vnt.wait_stop().await;
}
@@ -436,7 +452,7 @@ fn command(cmd: &str, vnt: &Vnt) -> bool {
fn print_usage(program: &str, _opts: Options) {
println!("Usage: {} [options]", program);
println!("version:1.2.0");
println!("version:{}",vnt::VNT_VERSION);
println!("Options:");
println!(" -k <token> {}", green("必选,使用相同的token,就能组建一个局域网络".to_string()));
println!(" -n <name> 给设备一个名字,便于区分不同设备,默认使用系统版本");
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "vnt-jni"
version = "1.2.0"
version = "1.2.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "vnt"
version = "1.2.0"
version = "1.2.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+1 -2
View File
@@ -11,7 +11,6 @@ use crate::proto::message::{HandshakeRequest, HandshakeResponse, SecretHandshake
use crate::protocol::{MAX_TTL, NetPacket, Protocol, service_packet, Version};
use crate::protocol::body::ENCRYPTION_RESERVED;
const VERSION: &'static str = "1.2.0";
pub enum HandshakeEnum {
NotSecret,
@@ -24,7 +23,7 @@ pub enum HandshakeEnum {
fn handshake_request_packet(secret: bool) -> crate::Result<NetPacket<Vec<u8>>> {
let mut request = HandshakeRequest::new();
request.secret = secret;
request.version = VERSION.to_string();
request.version = crate::VNT_VERSION.to_string();
let bytes = request.write_to_bytes()?;
let buf = vec![0u8; 12 + bytes.len()];
let mut net_packet = NetPacket::new(buf)?;
+1 -1
View File
@@ -193,7 +193,7 @@ fn registration_request_packet(
request.virtual_ip = ip.into();
request.allow_ip_change = allow_ip_change;
request.is_fast = is_fast;
request.version = "1.2.0".to_string();
request.version = crate::VNT_VERSION.to_string();
request.client_secret = client_secret;
let bytes = request.write_to_bytes()?;
let buf = vec![0u8; 12 + bytes.len() + ENCRYPTION_RESERVED];
+1 -1
View File
@@ -1,5 +1,5 @@
use crate::error::Error;
pub const VNT_VERSION:&'static str = "1.2.1";
pub type Result<T> = std::result::Result<T, Error>;
pub mod error;
+1 -1
View File
@@ -79,7 +79,7 @@ pub fn create_device(device_type: DeviceType,
config.layer(tun::Layer::L2);
}
}
let dev = tun::create(&config).unwrap();
let dev = tun::create(&config).expect("tun/tap failed to create");
let packet_information = dev.has_packet_information();
let queue = dev.queue(0).unwrap();
let reader = queue.reader();