-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from docheio/dev
0.2.0
- Loading branch information
Showing
10 changed files
with
396 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
Cargo.lock | ||
Cargo.lock | ||
.memo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
[package] | ||
name = "tardis" | ||
version = "0.1.1" | ||
version = "0.2.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
futures = "0.1" | ||
tokio = { version = "1.31.0", features = ["full"] } | ||
tokio-core = "0.1.18" | ||
tun-tap = { path="./modules/tuntap" } | ||
anyhow = "1.0" | ||
tun-tap = { path = "./modules/tuntap" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Tardis VPN | ||
Tardis is a high-speed VPN (not encrypted) for server-to-server communication. | ||
|
||
## Usage | ||
- **Install Tardis (Ubuntu)** | ||
```bash | ||
sudo apt install -y cargo make | ||
git clone https://github.com/docheio/tardis.git | ||
cd tardis | ||
make all | ||
make install | ||
``` | ||
|
||
- **Update Tardis** | ||
```bash | ||
make update | ||
make re | ||
make install | ||
``` | ||
|
||
- **Tardis command usage** | ||
```bash | ||
# Peer mode [peer-to-peer] | ||
tardis peer <LISTEN-IP>:<PORT> <TARGET-IP>:<PORT> <INTERFACE-NAME> <INTERFACE-IP>/<IP-RANGE> | ||
|
||
# Server mode [server-to-client] | ||
tardis server <LISTEN-IP>:<PORT> <INTERFACE-NAME> <INTERFACE-IP>/<IP-RANGE> | ||
|
||
# Client mode [client-to-server] | ||
tardis client <TARGET-IP>:<PORT> <INTERFACE-NAME> <INTERFACE-IP>/<IP-RANGE> | ||
``` | ||
- **Start Service** | ||
```bash | ||
# Must edit config „/etc/systemd/system/tardisd.service“ | ||
systemctl enable --now tardisd | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* ********************************************************************************************************** */ | ||
/* */ | ||
/* ::::::::: :::::::: :::::::: ::: ::: :::::::::: */ | ||
/* client.rs :+: :+: :+: :+: :+: :+: :+: :+: :+: */ | ||
/* +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ */ | ||
/* By: se-yukun <[email protected]> +#+ +:+ +#+ +:+ +#+ +#++:++#++ +#++:++# */ | ||
/* +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ */ | ||
/* Created: 2023/08/18 02:58:41 by se-yukun #+# #+# #+# #+# #+# #+# #+# #+# #+# */ | ||
/* Updated: 2023/08/18 02:58:44 by se-yukun ######### ######## ######## ### ### ##########.io. */ | ||
/* */ | ||
/* ********************************************************************************************************** */ | ||
|
||
use std::net::SocketAddr; | ||
use std::process::Command; | ||
use std::sync::Arc; | ||
use std::time::Duration; | ||
use std::{env, process, thread}; | ||
|
||
use std::net::UdpSocket; | ||
|
||
use tun_tap::{Iface, Mode}; | ||
|
||
fn cmd(cmd: &str, args: &[&str]) { | ||
let ecode = Command::new(cmd) | ||
.args(args) | ||
.spawn() | ||
.unwrap() | ||
.wait() | ||
.unwrap(); | ||
assert!(ecode.success(), "Failed to execte {}", cmd); | ||
} | ||
|
||
pub async fn client() { | ||
// Read Local & Remote IP from args | ||
let loc_address = "0.0.0.0:0".parse::<SocketAddr>().unwrap_or_else(|err| { | ||
eprintln!("Unable to bind udp socket: {}", err); | ||
process::exit(1); | ||
}); | ||
let rem_address = env::args() | ||
.nth(2) | ||
.unwrap() | ||
.parse::<SocketAddr>() | ||
.unwrap_or_else(|err| { | ||
eprintln!("Unable to recognize listen ip: {}", err); | ||
process::exit(1); | ||
}); | ||
|
||
// Create socket | ||
let socket = UdpSocket::bind(&loc_address).unwrap(); | ||
let socket = Arc::new(socket); | ||
|
||
// Create interface | ||
let name = &env::args().nth(3).expect("Unable to read Interface name"); | ||
let iface = Iface::new(&name, Mode::Tap).unwrap_or_else(|err| { | ||
eprintln!("Failed to configure the interface name: {}", err); | ||
process::exit(1); | ||
}); | ||
let iface = Arc::new(iface); | ||
|
||
// Configure the „local“ (kernel) endpoint. | ||
let ip = &env::args() | ||
.nth(4) | ||
.expect("Unable to recognize remote interface IP"); | ||
cmd("ip", &["addr", "add", "dev", iface.name(), &ip]); | ||
cmd("ip", &["link", "set", "up", "dev", iface.name()]); | ||
|
||
let iface = Arc::new(iface); | ||
let iface_writer = Arc::clone(&iface); | ||
let iface_reader = Arc::clone(&iface); | ||
let socket_keep = socket.clone(); | ||
let socket_send = socket.clone(); | ||
let socket_recv = socket.clone(); | ||
|
||
socket.connect(&rem_address).unwrap(); | ||
let buf = vec![0; 1]; | ||
socket.send(&buf).unwrap(); | ||
|
||
let keeper = thread::spawn(move || loop { | ||
thread::sleep(Duration::from_secs(4)); | ||
socket_keep.send(&[]).unwrap(); | ||
}); | ||
let writer = thread::spawn(move || { | ||
println!("w loaded"); | ||
loop { | ||
let mut buf = vec![0; 1518]; | ||
let len = socket_recv.recv(&mut buf).unwrap(); | ||
println!("recv: {:?}", len); | ||
iface_writer.send(&buf[..len]).unwrap(); | ||
} | ||
}); | ||
let reader = thread::spawn(move || { | ||
println!("r loaded"); | ||
loop { | ||
let mut buf = vec![0; 1518]; | ||
let len = iface_reader.recv(&mut buf).unwrap(); | ||
println!("{:?}", buf); | ||
println!("if recv"); | ||
if len > 18 { | ||
socket_send.send(&buf[..len]).unwrap(); | ||
println!("send: {:?}", len); | ||
} | ||
} | ||
}); | ||
keeper.join().unwrap(); | ||
writer.join().unwrap(); | ||
reader.join().unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* ********************************************************************************************************** */ | ||
/* */ | ||
/* ::::::::: :::::::: :::::::: ::: ::: :::::::::: */ | ||
/* mod.rs :+: :+: :+: :+: :+: :+: :+: :+: :+: */ | ||
/* +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ */ | ||
/* By: se-yukun <[email protected]> +#+ +:+ +#+ +:+ +#+ +#++:++#++ +#++:++# */ | ||
/* +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ */ | ||
/* Created: 2023/08/18 02:58:47 by se-yukun #+# #+# #+# #+# #+# #+# #+# #+# #+# */ | ||
/* Updated: 2023/08/18 02:58:48 by se-yukun ######### ######## ######## ### ### ##########.io. */ | ||
/* */ | ||
/* ********************************************************************************************************** */ | ||
|
||
pub mod peer; | ||
pub mod server; | ||
pub mod client; |
Oops, something went wrong.