Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13b7b1761d | ||
|
|
352f322f61 | ||
|
|
be966c4f83 | ||
|
|
b8cbf2cdac | ||
|
|
05cf0e1a6f | ||
|
|
aa332b4f4d |
Generated
+9
-8
@@ -307,7 +307,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "common"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@@ -881,7 +881,7 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
|
||||
[[package]]
|
||||
name = "libsm"
|
||||
version = "0.5.1"
|
||||
source = "git+https://github.com/lbl8603/libsm#f9e1b8cf20d0829efb4934a940d0ba4f3ee0ac14"
|
||||
source = "git+https://github.com/vnt-dev/libsm#f9e1b8cf20d0829efb4934a940d0ba4f3ee0ac14"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"getrandom",
|
||||
@@ -955,7 +955,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "lwip-rs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/lbl8603/lwip-rs#3133f0c3bde55333a27641182ae3550e7acc2a39"
|
||||
source = "git+https://github.com/vnt-dev/lwip-rs#3133f0c3bde55333a27641182ae3550e7acc2a39"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
@@ -1121,7 +1121,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.93"
|
||||
source = "git+https://github.com/lbl8603/rust-openssl#e8b3d2c02d2d07a0e4a82ff4e4bef210f4bc71c8"
|
||||
source = "git+https://github.com/vnt-dev/rust-openssl#e8b3d2c02d2d07a0e4a82ff4e4bef210f4bc71c8"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@@ -1968,6 +1968,7 @@ dependencies = [
|
||||
"libloading",
|
||||
"log",
|
||||
"rand",
|
||||
"sha2",
|
||||
"widestring",
|
||||
"winapi",
|
||||
]
|
||||
@@ -2105,7 +2106,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "vn-link"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"crossbeam-utils",
|
||||
@@ -2118,7 +2119,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vn-link-cli"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
dependencies = [
|
||||
"common",
|
||||
"log",
|
||||
@@ -2128,7 +2129,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vnt"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"aes-gcm",
|
||||
@@ -2175,7 +2176,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "vnt-cli"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
|
||||
@@ -4,7 +4,7 @@ A virtual network tool (VPN)
|
||||
|
||||
将不同网络下的多个设备虚拟到一个局域网下
|
||||
|
||||
### vnt-cli参数详解 [参数说明](https://github.com/lbl8603/vnt/blob/main/vnt-cli/README.md)
|
||||
### vnt-cli参数详解 [参数说明](https://github.com/vnt-dev/vnt/blob/main/vnt-cli/README.md)
|
||||
|
||||
### 快速使用:
|
||||
|
||||
@@ -39,7 +39,7 @@ A virtual network tool (VPN)
|
||||
```
|
||||
4. 最后可以用虚拟ip实现设备间相互访问
|
||||
|
||||
<img width="506" alt="ssh" src="https://raw.githubusercontent.com/lbl8603/vnt/main/documents/img/ssh.jpg">
|
||||
<img width="506" alt="ssh" src="https://raw.githubusercontent.com/vnt-dev/vnt/main/documents/img/ssh.jpg">
|
||||
5. 帮助,使用-h命令查看
|
||||
|
||||
### 更多玩法
|
||||
@@ -56,7 +56,7 @@ A virtual network tool (VPN)
|
||||
- 需要root/管理员权限
|
||||
- vnt-cli需要使用命令行运行
|
||||
- Mac和Linux下需要加可执行权限(例如:chmod +x ./vnt-cli)
|
||||
- 可以自己搭注册和中继服务器([server](https://github.com/lbl8603/vnts))
|
||||
- 可以自己搭注册和中继服务器([server](https://github.com/vnt-dev/vnts))
|
||||
- vnt使用stun服务器探测网络NAT类型,默认使用谷歌和腾讯的stun服务器,也可自己搭建(-e参数指定)
|
||||
|
||||
### 编译
|
||||
@@ -181,7 +181,7 @@ sudo pfctl -f /etc/pf.conf -e
|
||||
|
||||
### GUI
|
||||
|
||||
支持安卓和Windows [下载](https://github.com/lbl8603/VntApp/releases/)
|
||||
支持安卓和Windows [下载](https://github.com/vnt-dev/VntApp/releases/)
|
||||
|
||||
### 特性
|
||||
|
||||
@@ -291,7 +291,7 @@ QQ: 1034868233
|
||||
### 赞助
|
||||
如果VNT对你有帮助,欢迎打赏作者
|
||||
|
||||
<img width="300" alt="" src="https://github.com/lbl8603/vnt/assets/49143209/0d3a7311-43fc-4ed7-9507-863b5d69b6b2">
|
||||
<img width="300" alt="" src="https://github.com/vnt-dev/vnt/assets/49143209/0d3a7311-43fc-4ed7-9507-863b5d69b6b2">
|
||||
|
||||
### 其他
|
||||
|
||||
@@ -302,6 +302,6 @@ QQ: 1034868233
|
||||
|
||||
### 参与贡献
|
||||
|
||||
<a href="https://github.com/lbl8603/vnt/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=lbl8603/vnt" />
|
||||
<a href="https://github.com/vnt-dev/vnt/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=vnt-dev/vnt" />
|
||||
</a>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "common"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "vn-link-cli"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
[package]
|
||||
name = "vn-link"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
lwip-rs = { git = "https://github.com/lbl8603/lwip-rs" }
|
||||
lwip-rs = { git = "https://github.com/vnt-dev/lwip-rs" }
|
||||
vnt = { path = "../vnt", package = "vnt", default-features = false }
|
||||
log = "0.4.17"
|
||||
anyhow = "1.0.82"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "vnt-cli"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
+11
-1
@@ -135,7 +135,7 @@ aes_gcm/aes_cbc/aes_ecb/sm4_cbc/chacha20_poly1305/chacha20/xor,默认使用aes
|
||||
### --no-proxy
|
||||
|
||||
关闭内置的ip代理,内置的代理较为简单,而且一般来说直接使用网卡NAT转发性能会更高,
|
||||
有需要可以自行配置NAT转发,[可参考‘编译’小节中的NAT配置](https://github.com/lbl8603/vnt#%E7%BC%96%E8%AF%91)
|
||||
有需要可以自行配置NAT转发,[可参考‘编译’小节中的NAT配置](https://github.com/vnt-dev/vnt#%E7%BC%96%E8%AF%91)
|
||||
|
||||
### --dns `<223.5.5.5>`
|
||||
|
||||
@@ -201,6 +201,8 @@ mapping:
|
||||
- udp:0.0.0.0:80-10.26.0.10:80 # 映射udp数据
|
||||
- tcp:0.0.0.0:80-10.26.0.10:81 # 映射tcp数据
|
||||
- tcp:0.0.0.0:82-localhost:83 # 映射tcp数据
|
||||
disable_stats: false # 为true表示关闭统计
|
||||
allow_wire_guard: false # 为true则表示允许接入wg
|
||||
```
|
||||
|
||||
或者需要哪个配置就加哪个,当然token是必须的
|
||||
@@ -223,6 +225,14 @@ token: xxx #组网token
|
||||
|
||||
模拟延迟,整数,单位毫秒(ms),程序会按设定的值延迟发包,可用于模拟弱网
|
||||
|
||||
### --disable-stats
|
||||
|
||||
关闭流量统计
|
||||
|
||||
### --allow-wg
|
||||
|
||||
允许接入WireGuard客户端,和wg混用时必须开启此参数
|
||||
|
||||
### --list
|
||||
|
||||
在后台运行时,查看其他设备列表
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "vnt"
|
||||
version = "1.2.11"
|
||||
version = "1.2.12"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
@@ -29,8 +29,8 @@ aes = "0.8.3"
|
||||
stun-format = { version = "1.0.1", features = ["fmt", "rfc3489"] }
|
||||
rsa = { version = "0.9.2", features = [], optional = true }
|
||||
spki = { version = "0.7.2", features = ["fingerprint", "alloc", "base64"], optional = true }
|
||||
openssl-sys = { git = "https://github.com/lbl8603/rust-openssl", optional = true }
|
||||
libsm = { git = "https://github.com/lbl8603/libsm", optional = true }
|
||||
openssl-sys = { git = "https://github.com/vnt-dev/rust-openssl", optional = true }
|
||||
libsm = { git = "https://github.com/vnt-dev/libsm", optional = true }
|
||||
|
||||
mio = { version = "=0.8.11", features = ["os-poll", "net", "os-ext"] }
|
||||
crossbeam-queue = "0.3.11"
|
||||
|
||||
@@ -97,9 +97,12 @@ fn broadcast(
|
||||
.filter(|info| !info.wireguard && info.status.is_online())
|
||||
.map(|info| info.virtual_ip)
|
||||
.collect();
|
||||
if list.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
const MAX_COUNT: usize = 8;
|
||||
let mut p2p_ips = Vec::with_capacity(8);
|
||||
let mut relay_ips = Vec::with_capacity(8);
|
||||
let mut relay = false;
|
||||
let mut overflow = false;
|
||||
for (index, peer_ip) in list.into_iter().enumerate() {
|
||||
if index > MAX_COUNT {
|
||||
@@ -112,38 +115,22 @@ fn broadcast(
|
||||
continue;
|
||||
}
|
||||
}
|
||||
relay_ips.push(peer_ip);
|
||||
relay = true;
|
||||
}
|
||||
if !overflow && relay_ips.is_empty() {
|
||||
if !overflow && !relay {
|
||||
//全部p2p,不需要服务器中转
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if p2p_ips.is_empty() {
|
||||
//都没有p2p则直接由服务器转发
|
||||
if current_device.status.online() {
|
||||
sender.send_default(&net_packet, current_device.connect_server)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
if !overflow && relay_ips.len() == 2 {
|
||||
// 如果转发的ip数不多就直接发
|
||||
for peer_ip in relay_ips {
|
||||
//非直连的广播要改变目的地址,不然服务端收到了会再次广播
|
||||
net_packet.set_destination(peer_ip);
|
||||
sender.send_ipv4_by_id(
|
||||
&net_packet,
|
||||
&peer_ip,
|
||||
current_device.connect_server,
|
||||
current_device.status.online(),
|
||||
)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
if current_device.status.offline() {
|
||||
//离线的不再转发
|
||||
return Ok(());
|
||||
}
|
||||
if p2p_ips.is_empty() {
|
||||
//都没有p2p则直接由服务器转发
|
||||
sender.send_default(&net_packet, current_device.connect_server)?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let buf = vec![0u8; 12 + 1 + p2p_ips.len() * 4 + net_packet.data_len() + ENCRYPTION_RESERVED];
|
||||
//剩余的发送到服务端,需要告知哪些已发送过
|
||||
let mut server_packet = NetPacket::new_encrypt(buf)?;
|
||||
@@ -256,10 +243,10 @@ pub(crate) fn handle(
|
||||
// 如果是wg客户端则发到vnts转发
|
||||
let guard = device_map.lock();
|
||||
if let Some(peer_info) = guard.1.get(&dest_ip) {
|
||||
if peer_info.status.is_offline() {
|
||||
return Ok(());
|
||||
}
|
||||
if peer_info.wireguard {
|
||||
if peer_info.status.is_offline() {
|
||||
return Ok(());
|
||||
}
|
||||
drop(guard);
|
||||
send_to_wg(context, &mut net_packet, server_cipher, ¤t_device)?;
|
||||
return Ok(());
|
||||
@@ -279,7 +266,7 @@ pub(crate) fn handle(
|
||||
} else {
|
||||
net_packet
|
||||
};
|
||||
if dest_ip.is_broadcast() || current_device.broadcast_ip == dest_ip {
|
||||
if is_broadcast {
|
||||
// 广播 发送到直连目标
|
||||
client_cipher.encrypt_ipv4(&mut net_packet)?;
|
||||
broadcast(
|
||||
|
||||
@@ -11,6 +11,7 @@ libc = "0.2.153"
|
||||
|
||||
log = { version = "0.4.20", features = [] }
|
||||
rand = "0.8.5"
|
||||
sha2 = { version = "0.10.6", features = ["oid"] }
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
ioctl = { version = "0.8", package = "ioctl-sys" }
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#![allow(dead_code)]
|
||||
use libloading::Library;
|
||||
use sha2::Digest;
|
||||
use std::io;
|
||||
use std::net::Ipv4Addr;
|
||||
|
||||
use rand::Rng;
|
||||
use winapi::um::winbase;
|
||||
use winapi::um::{synchapi, winnt};
|
||||
|
||||
@@ -81,8 +80,7 @@ impl Device {
|
||||
if Self::delete_for_name(&win_tun, &name_utf16).is_ok() {
|
||||
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||
}
|
||||
let mut guid_bytes: [u8; 16] = [0u8; 16];
|
||||
rand::thread_rng().fill(&mut guid_bytes);
|
||||
let guid_bytes: [u8; 16] = hash_guid(&name);
|
||||
let guid = u128::from_ne_bytes(guid_bytes);
|
||||
//SAFETY: guid is a unique integer so transmuting either all zeroes or the user's preferred
|
||||
//guid to the winapi guid type is safe and will allow the windows kernel to see our GUID
|
||||
@@ -154,7 +152,14 @@ impl Device {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn hash_guid(input: &str) -> [u8; 16] {
|
||||
let mut hasher = sha2::Sha256::new();
|
||||
hasher.update(b"VNT");
|
||||
hasher.update(input.as_bytes());
|
||||
hasher.update(b"2024");
|
||||
let hash: [u8; 32] = hasher.finalize().into();
|
||||
hash[..16].try_into().unwrap()
|
||||
}
|
||||
impl IFace for Device {
|
||||
fn version(&self) -> io::Result<String> {
|
||||
let version = unsafe { self.win_tun.WintunGetRunningDriverVersion() };
|
||||
|
||||
Reference in New Issue
Block a user