mirror of
https://github.com/EasyTier/EasyTier.git
synced 2024-11-16 11:42:27 +08:00
use workspace, prepare for config server and gui (#48)
This commit is contained in:
parent
bb4ae71869
commit
4eb7efe5fc
4
.github/workflows/rust.yml
vendored
4
.github/workflows/rust.yml
vendored
|
@ -95,8 +95,8 @@ jobs:
|
||||||
# windows is the only OS using a different convention for executable file name
|
# windows is the only OS using a different convention for executable file name
|
||||||
if [[ $OS =~ ^windows.*$ ]]; then
|
if [[ $OS =~ ^windows.*$ ]]; then
|
||||||
SUFFIX=.exe
|
SUFFIX=.exe
|
||||||
cp third_party/Packet.dll ./artifacts/objects/
|
cp easytier/third_party/Packet.dll ./artifacts/objects/
|
||||||
cp third_party/wintun.dll ./artifacts/objects/
|
cp easytier/third_party/wintun.dll ./artifacts/objects/
|
||||||
fi
|
fi
|
||||||
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
|
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
|
||||||
TAG=$GITHUB_REF_NAME
|
TAG=$GITHUB_REF_NAME
|
||||||
|
|
148
Cargo.toml
148
Cargo.toml
|
@ -1,148 +1,6 @@
|
||||||
[package]
|
[workspace]
|
||||||
name = "easytier"
|
resolver = "2"
|
||||||
description = "A full meshed p2p VPN, connecting all your devices in one network with one command."
|
members = ["easytier"]
|
||||||
homepage = "https://github.com/KKRainbow/EasyTier"
|
|
||||||
repository = "https://github.com/KKRainbow/EasyTier"
|
|
||||||
version = "0.1.2"
|
|
||||||
edition = "2021"
|
|
||||||
authors = ["kkrainbow"]
|
|
||||||
keywords = ["vpn", "p2p", "network", "easytier"]
|
|
||||||
categories = ["network-programming", "command-line-utilities"]
|
|
||||||
rust-version = "1.75"
|
|
||||||
license-file = "LICENSE"
|
|
||||||
readme = "README.md"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "easytier-core"
|
|
||||||
path = "src/easytier-core.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "easytier-cli"
|
|
||||||
path = "src/easytier-cli.rs"
|
|
||||||
test = false
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
tracing = { version = "0.1", features = ["log"] }
|
|
||||||
tracing-subscriber = { version = "0.3", features = [
|
|
||||||
"env-filter",
|
|
||||||
"local-time",
|
|
||||||
"time",
|
|
||||||
] }
|
|
||||||
tracing-appender = "0.2.3"
|
|
||||||
log = "0.4"
|
|
||||||
thiserror = "1.0"
|
|
||||||
auto_impl = "1.1.0"
|
|
||||||
crossbeam = "0.8.4"
|
|
||||||
time = "0.3"
|
|
||||||
toml = "0.8.12"
|
|
||||||
chrono = "0.4.35"
|
|
||||||
|
|
||||||
gethostname = "0.4.3"
|
|
||||||
|
|
||||||
futures = "0.3"
|
|
||||||
|
|
||||||
tokio = { version = "1", features = ["full"] }
|
|
||||||
tokio-stream = "0.1"
|
|
||||||
tokio-util = { version = "0.7.9", features = ["codec", "net"] }
|
|
||||||
|
|
||||||
async-stream = "0.3.5"
|
|
||||||
async-trait = "0.1.74"
|
|
||||||
|
|
||||||
dashmap = "5.5.3"
|
|
||||||
timedmap = "=1.0.1"
|
|
||||||
|
|
||||||
# for tap device
|
|
||||||
tun = { version = "0.6.1", features = ["async"] }
|
|
||||||
# for net ns
|
|
||||||
nix = { version = "0.27", features = ["sched", "socket", "ioctl"] }
|
|
||||||
|
|
||||||
uuid = { version = "1.5.0", features = [
|
|
||||||
"v4",
|
|
||||||
"fast-rng",
|
|
||||||
"macro-diagnostics",
|
|
||||||
"serde",
|
|
||||||
] }
|
|
||||||
|
|
||||||
# for ring tunnel
|
|
||||||
crossbeam-queue = "0.3"
|
|
||||||
once_cell = "1.18.0"
|
|
||||||
|
|
||||||
# for packet
|
|
||||||
rkyv = { "version" = "0.7.42", features = [
|
|
||||||
"validation",
|
|
||||||
"archive_le",
|
|
||||||
"strict",
|
|
||||||
"copy_unsafe",
|
|
||||||
"arbitrary_enum_discriminant",
|
|
||||||
] }
|
|
||||||
postcard = { "version" = "1.0.8", features = ["alloc"] }
|
|
||||||
|
|
||||||
# for rpc
|
|
||||||
tonic = "0.10"
|
|
||||||
prost = "0.12"
|
|
||||||
anyhow = "1.0"
|
|
||||||
tarpc = { version = "0.32", features = ["tokio1", "serde1"] }
|
|
||||||
|
|
||||||
url = { version = "2.5", features = ["serde"] }
|
|
||||||
percent-encoding = "2.3.1"
|
|
||||||
|
|
||||||
# for tun packet
|
|
||||||
byteorder = "1.5.0"
|
|
||||||
|
|
||||||
# for proxy
|
|
||||||
cidr = { version = "0.2.2", features = ["serde"] }
|
|
||||||
socket2 = "0.5.5"
|
|
||||||
|
|
||||||
# for hole punching
|
|
||||||
stun_codec = "0.3.4"
|
|
||||||
bytecodec = "0.4.15"
|
|
||||||
rand = "0.8.5"
|
|
||||||
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
pnet = { version = "0.34.0", features = ["serde"] }
|
|
||||||
public-ip = { version = "0.2", features = ["default"] }
|
|
||||||
|
|
||||||
clap = { version = "4.4.8", features = ["unicode", "derive", "wrap_help"] }
|
|
||||||
|
|
||||||
async-recursion = "1.0.5"
|
|
||||||
|
|
||||||
network-interface = "1.1.1"
|
|
||||||
|
|
||||||
# for ospf route
|
|
||||||
pathfinding = "4.9.1"
|
|
||||||
|
|
||||||
# for encryption
|
|
||||||
boringtun = { version = "0.6.0" }
|
|
||||||
|
|
||||||
# for cli
|
|
||||||
tabled = "0.15.*"
|
|
||||||
humansize = "2.1.3"
|
|
||||||
|
|
||||||
base64 = "0.21.7"
|
|
||||||
|
|
||||||
derivative = "2.2.0"
|
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
|
||||||
windows-sys = { version = "0.52", features = [
|
|
||||||
"Win32_Networking_WinSock",
|
|
||||||
"Win32_NetworkManagement_IpHelper",
|
|
||||||
"Win32_Foundation",
|
|
||||||
"Win32_System_IO",
|
|
||||||
] }
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
tonic-build = "0.10"
|
|
||||||
|
|
||||||
[target.'cfg(windows)'.build-dependencies]
|
|
||||||
reqwest = { version = "0.11", features = ["blocking"] }
|
|
||||||
zip = "0.6.6"
|
|
||||||
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
serial_test = "3.0.0"
|
|
||||||
rstest = "0.18.2"
|
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
panic = "unwind"
|
panic = "unwind"
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
```
|
```
|
||||||
Successful execution of the command will print the following.
|
Successful execution of the command will print the following.
|
||||||
|
|
||||||
![alt text](assets/image-2.png)
|
![alt text](/assets/image-2.png)
|
||||||
|
|
||||||
2. Execute on Node B
|
2. Execute on Node B
|
||||||
```sh
|
```sh
|
||||||
|
@ -85,11 +85,11 @@
|
||||||
```sh
|
```sh
|
||||||
easytier-cli peer
|
easytier-cli peer
|
||||||
```
|
```
|
||||||
![alt text](assets/image.png)
|
![alt text](/assets/image.png)
|
||||||
```sh
|
```sh
|
||||||
easytier-cli route
|
easytier-cli route
|
||||||
```
|
```
|
||||||
![alt text](assets/image-1.png)
|
![alt text](/assets/image-1.png)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
```sh
|
```sh
|
||||||
easytier-cli route
|
easytier-cli route
|
||||||
```
|
```
|
||||||
![alt text](assets/image-3.png)
|
![alt text](/assets/image-3.png)
|
||||||
|
|
||||||
2. Test whether Node A can access nodes under the proxied subnet
|
2. Test whether Node A can access nodes under the proxied subnet
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ nodea <-----> nodeb
|
||||||
```
|
```
|
||||||
命令执行成功会有如下打印。
|
命令执行成功会有如下打印。
|
||||||
|
|
||||||
![alt text](assets/image-2.png)
|
![alt text](/assets/image-2.png)
|
||||||
|
|
||||||
2. 在节点 B 执行
|
2. 在节点 B 执行
|
||||||
```sh
|
```sh
|
||||||
|
@ -85,11 +85,11 @@ nodea <-----> nodeb
|
||||||
```sh
|
```sh
|
||||||
easytier-cli peer
|
easytier-cli peer
|
||||||
```
|
```
|
||||||
![alt text](assets/image.png)
|
![alt text](/assets/image.png)
|
||||||
```sh
|
```sh
|
||||||
easytier-cli route
|
easytier-cli route
|
||||||
```
|
```
|
||||||
![alt text](assets/image-1.png)
|
![alt text](/assets/image-1.png)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ sudo easytier-core --ipv4 10.144.144.2 -n 10.1.1.0/24
|
||||||
```sh
|
```sh
|
||||||
easytier-cli route
|
easytier-cli route
|
||||||
```
|
```
|
||||||
![alt text](assets/image-3.png)
|
![alt text](/assets/image-3.png)
|
||||||
|
|
||||||
2. 测试节点 A 是否可访问被代理子网下的节点
|
2. 测试节点 A 是否可访问被代理子网下的节点
|
||||||
|
|
||||||
|
|
145
easytier/Cargo.toml
Normal file
145
easytier/Cargo.toml
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
[package]
|
||||||
|
name = "easytier"
|
||||||
|
description = "A full meshed p2p VPN, connecting all your devices in one network with one command."
|
||||||
|
homepage = "https://github.com/KKRainbow/EasyTier"
|
||||||
|
repository = "https://github.com/KKRainbow/EasyTier"
|
||||||
|
version = "0.1.2"
|
||||||
|
edition = "2021"
|
||||||
|
authors = ["kkrainbow"]
|
||||||
|
keywords = ["vpn", "p2p", "network", "easytier"]
|
||||||
|
categories = ["network-programming", "command-line-utilities"]
|
||||||
|
rust-version = "1.75"
|
||||||
|
license-file = "LICENSE"
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "easytier-core"
|
||||||
|
path = "src/easytier-core.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "easytier-cli"
|
||||||
|
path = "src/easytier-cli.rs"
|
||||||
|
test = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
tracing = { version = "0.1", features = ["log"] }
|
||||||
|
tracing-subscriber = { version = "0.3", features = [
|
||||||
|
"env-filter",
|
||||||
|
"local-time",
|
||||||
|
"time",
|
||||||
|
] }
|
||||||
|
tracing-appender = "0.2.3"
|
||||||
|
log = "0.4"
|
||||||
|
thiserror = "1.0"
|
||||||
|
auto_impl = "1.1.0"
|
||||||
|
crossbeam = "0.8.4"
|
||||||
|
time = "0.3"
|
||||||
|
toml = "0.8.12"
|
||||||
|
chrono = "0.4.35"
|
||||||
|
|
||||||
|
gethostname = "0.4.3"
|
||||||
|
|
||||||
|
futures = "0.3"
|
||||||
|
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
|
tokio-stream = "0.1"
|
||||||
|
tokio-util = { version = "0.7.9", features = ["codec", "net"] }
|
||||||
|
|
||||||
|
async-stream = "0.3.5"
|
||||||
|
async-trait = "0.1.74"
|
||||||
|
|
||||||
|
dashmap = "5.5.3"
|
||||||
|
timedmap = "=1.0.1"
|
||||||
|
|
||||||
|
# for tap device
|
||||||
|
tun = { version = "0.6.1", features = ["async"] }
|
||||||
|
# for net ns
|
||||||
|
nix = { version = "0.27", features = ["sched", "socket", "ioctl"] }
|
||||||
|
|
||||||
|
uuid = { version = "1.5.0", features = [
|
||||||
|
"v4",
|
||||||
|
"fast-rng",
|
||||||
|
"macro-diagnostics",
|
||||||
|
"serde",
|
||||||
|
] }
|
||||||
|
|
||||||
|
# for ring tunnel
|
||||||
|
crossbeam-queue = "0.3"
|
||||||
|
once_cell = "1.18.0"
|
||||||
|
|
||||||
|
# for packet
|
||||||
|
rkyv = { "version" = "0.7.42", features = [
|
||||||
|
"validation",
|
||||||
|
"archive_le",
|
||||||
|
"strict",
|
||||||
|
"copy_unsafe",
|
||||||
|
"arbitrary_enum_discriminant",
|
||||||
|
] }
|
||||||
|
postcard = { "version" = "1.0.8", features = ["alloc"] }
|
||||||
|
|
||||||
|
# for rpc
|
||||||
|
tonic = "0.10"
|
||||||
|
prost = "0.12"
|
||||||
|
anyhow = "1.0"
|
||||||
|
tarpc = { version = "0.32", features = ["tokio1", "serde1"] }
|
||||||
|
|
||||||
|
url = { version = "2.5", features = ["serde"] }
|
||||||
|
percent-encoding = "2.3.1"
|
||||||
|
|
||||||
|
# for tun packet
|
||||||
|
byteorder = "1.5.0"
|
||||||
|
|
||||||
|
# for proxy
|
||||||
|
cidr = { version = "0.2.2", features = ["serde"] }
|
||||||
|
socket2 = "0.5.5"
|
||||||
|
|
||||||
|
# for hole punching
|
||||||
|
stun_codec = "0.3.4"
|
||||||
|
bytecodec = "0.4.15"
|
||||||
|
rand = "0.8.5"
|
||||||
|
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
pnet = { version = "0.34.0", features = ["serde"] }
|
||||||
|
public-ip = { version = "0.2", features = ["default"] }
|
||||||
|
|
||||||
|
clap = { version = "4.4.8", features = ["unicode", "derive", "wrap_help"] }
|
||||||
|
|
||||||
|
async-recursion = "1.0.5"
|
||||||
|
|
||||||
|
network-interface = "1.1.1"
|
||||||
|
|
||||||
|
# for ospf route
|
||||||
|
pathfinding = "4.9.1"
|
||||||
|
|
||||||
|
# for encryption
|
||||||
|
boringtun = { version = "0.6.0" }
|
||||||
|
|
||||||
|
# for cli
|
||||||
|
tabled = "0.15.*"
|
||||||
|
humansize = "2.1.3"
|
||||||
|
|
||||||
|
base64 = "0.21.7"
|
||||||
|
|
||||||
|
derivative = "2.2.0"
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
windows-sys = { version = "0.52", features = [
|
||||||
|
"Win32_Networking_WinSock",
|
||||||
|
"Win32_NetworkManagement_IpHelper",
|
||||||
|
"Win32_Foundation",
|
||||||
|
"Win32_System_IO",
|
||||||
|
] }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tonic-build = "0.10"
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
|
reqwest = { version = "0.11", features = ["blocking"] }
|
||||||
|
zip = "0.6.6"
|
||||||
|
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
serial_test = "3.0.0"
|
||||||
|
rstest = "0.18.2"
|
1
easytier/README.md
Symbolic link
1
easytier/README.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../README.md
|
1
easytier/README_CN.md
Symbolic link
1
easytier/README_CN.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../README_CN.md
|
1
easytier/assets
Symbolic link
1
easytier/assets
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../assets
|
|
@ -75,7 +75,7 @@ impl WindowsBuild {
|
||||||
|
|
||||||
pub fn check_for_win() {
|
pub fn check_for_win() {
|
||||||
// add third_party dir to link search path
|
// add third_party dir to link search path
|
||||||
println!("cargo:rustc-link-search=native=third_party/");
|
println!("cargo:rustc-link-search=native=easytier/third_party/");
|
||||||
let protoc_path = if let Some(o) = Self::check_protoc_exist() {
|
let protoc_path = if let Some(o) = Self::check_protoc_exist() {
|
||||||
println!("cargo:info=use os exist protoc: {:?}", o);
|
println!("cargo:info=use os exist protoc: {:?}", o);
|
||||||
o
|
o
|
|
@ -1,29 +0,0 @@
|
||||||
CWD=$(dirname `cargo locate-project | jq '.root' -r`)
|
|
||||||
cargo build --release --all-targets
|
|
||||||
|
|
||||||
TARGET_HOSTS=("root@public.kkrainbow.top" "root@47.242.85.82" "root@192.168.60.162")
|
|
||||||
CARGO_BUILD_OUTPUT_DIR="$CWD/target/release"
|
|
||||||
|
|
||||||
copy_bin_to_remote() {
|
|
||||||
local TARGET_HOST=$1
|
|
||||||
scp ${CARGO_BUILD_OUTPUT_DIR}/easytier-core $TARGET_HOST:/tmp/easytier-core &
|
|
||||||
scp ${CARGO_BUILD_OUTPUT_DIR}/easytier-cli $TARGET_HOST:/tmp/easytier-cli &
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for TARGET_HOST in ${TARGET_HOSTS[@]}; do
|
|
||||||
ssh $TARGET_HOST "killall easytier-core"
|
|
||||||
copy_bin_to_remote $TARGET_HOST
|
|
||||||
done
|
|
||||||
|
|
||||||
wait
|
|
||||||
|
|
||||||
run_with_args() {
|
|
||||||
local TARGET_HOST=$1
|
|
||||||
local ARGS=$2
|
|
||||||
ssh $TARGET_HOST "nohup /tmp/easytier-core $ARGS > /tmp/easytier-core.log 2>&1 &"
|
|
||||||
}
|
|
||||||
|
|
||||||
run_with_args "root@192.168.60.162" "--ipv4 10.144.144.10 --peers tcp://public.kkrainbow.top:11010"
|
|
||||||
run_with_args "root@public.kkrainbow.top" "--ipv4 10.144.144.20"
|
|
||||||
run_with_args "root@47.242.85.82" "--ipv4 10.144.144.30 --peers tcp://public.kkrainbow.top:11010"
|
|
|
@ -1,10 +0,0 @@
|
||||||
ip netns add net_a
|
|
||||||
ip netns add net_b
|
|
||||||
ip netns add net_c
|
|
||||||
ip link add veth0 type veth peer name veth1
|
|
||||||
ip link set veth0 netns net_a
|
|
||||||
ip link set veth1 netns net_b
|
|
||||||
ip netns exec net_a ip addr add 10.144.145.1/24 dev veth0
|
|
||||||
ip netns exec net_b ip addr add 10.144.145.2/24 dev veth1
|
|
||||||
ip netns exec net_a ip link set veth0 up
|
|
||||||
ip netns exec net_b ip link set veth1 up
|
|
Loading…
Reference in New Issue
Block a user