punchnet 1.0.1 is ok, no permission is checked
This commit is contained in:
parent
814ab9181a
commit
5249a271c5
66
Cargo.lock
generated
66
Cargo.lock
generated
@ -2,6 +2,16 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aead"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
|
||||||
|
dependencies = [
|
||||||
|
"crypto-common",
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aes"
|
name = "aes"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
@ -347,6 +357,30 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chacha20"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cipher",
|
||||||
|
"cpufeatures",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chacha20poly1305"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
|
||||||
|
dependencies = [
|
||||||
|
"aead",
|
||||||
|
"chacha20",
|
||||||
|
"cipher",
|
||||||
|
"poly1305",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.43"
|
version = "0.4.43"
|
||||||
@ -368,6 +402,7 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
"inout",
|
"inout",
|
||||||
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -555,6 +590,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"generic-array",
|
"generic-array",
|
||||||
|
"rand_core 0.6.4",
|
||||||
"typenum",
|
"typenum",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1757,6 +1793,12 @@ version = "1.70.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "opaque-debug"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-probe"
|
name = "openssl-probe"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@ -1856,6 +1898,17 @@ version = "0.3.32"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "poly1305"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
|
||||||
|
dependencies = [
|
||||||
|
"cpufeatures",
|
||||||
|
"opaque-debug",
|
||||||
|
"universal-hash",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "potential_utf"
|
name = "potential_utf"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@ -2009,10 +2062,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "punchnet"
|
name = "punchnet"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"cargo-deb",
|
"cargo-deb",
|
||||||
|
"chacha20poly1305",
|
||||||
"clap 4.5.60",
|
"clap 4.5.60",
|
||||||
"crc",
|
"crc",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
@ -3443,6 +3497,16 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
|
checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "universal-hash"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea"
|
||||||
|
dependencies = [
|
||||||
|
"crypto-common",
|
||||||
|
"subtle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "untrusted"
|
name = "untrusted"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "punchnet"
|
name = "punchnet"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@ -35,6 +35,7 @@ rustls-pemfile = "2.2.0"
|
|||||||
clap = { version = "4.5.60", features = ["derive", "env"] }
|
clap = { version = "4.5.60", features = ["derive", "env"] }
|
||||||
rpassword = "7.4.0"
|
rpassword = "7.4.0"
|
||||||
serde_json = "1.0.149"
|
serde_json = "1.0.149"
|
||||||
|
chacha20poly1305 = "0.10.1"
|
||||||
# rolling-file = { path = "../rolling-file" }
|
# rolling-file = { path = "../rolling-file" }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
|
|||||||
2
Makefile
2
Makefile
@ -16,7 +16,7 @@ win:
|
|||||||
|
|
||||||
pb:
|
pb:
|
||||||
cargo run --bin build_pb
|
cargo run --bin build_pb
|
||||||
mv src/pb/_.rs src/pb/message.rs
|
# mv src/pb/_.rs src/pb/message.rs
|
||||||
|
|
||||||
libtun-so-clang:
|
libtun-so-clang:
|
||||||
cd src/network && clang -fPIC -shared -o libtuntap.so tuntap.c && cd -
|
cd src/network && clang -fPIC -shared -o libtuntap.so tuntap.c && cd -
|
||||||
|
|||||||
@ -68,9 +68,9 @@ where T: Serialize,
|
|||||||
return Err(SDLanError::IOError("failed to do request".to_owned()));
|
return Err(SDLanError::IOError("failed to do request".to_owned()));
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("status: {}", response.status());
|
// println!("status: {}", response.status());
|
||||||
let text = response.text().await.unwrap();
|
let text = response.text().await.unwrap();
|
||||||
println!("text = {}", text);
|
// println!("text = {}", text);
|
||||||
|
|
||||||
let data = serde_json::from_str(&text).unwrap();
|
let data = serde_json::from_str(&text).unwrap();
|
||||||
|
|
||||||
|
|||||||
@ -118,8 +118,6 @@ async fn daemonize_me(
|
|||||||
) {
|
) {
|
||||||
let _guard = log::init_log(&format!("{}/.output", get_base_dir()));
|
let _guard = log::init_log(&format!("{}/.output", get_base_dir()));
|
||||||
|
|
||||||
println!("identity_id = {}", connect_info.identity_id);
|
|
||||||
|
|
||||||
let self_host_name = connect_info.hostname;
|
let self_host_name = connect_info.hostname;
|
||||||
|
|
||||||
let (tx, rx) = std::sync::mpsc::channel();
|
let (tx, rx) = std::sync::mpsc::channel();
|
||||||
@ -138,8 +136,6 @@ async fn daemonize_me(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("server is {}", server);
|
|
||||||
|
|
||||||
// mod_hostname::get_hostname();
|
// mod_hostname::get_hostname();
|
||||||
/*
|
/*
|
||||||
let hostname = if cmd.hostname.len() == 0 {
|
let hostname = if cmd.hostname.len() == 0 {
|
||||||
@ -249,8 +245,10 @@ async fn daemonize_me(
|
|||||||
|
|
||||||
match tokio::signal::ctrl_c().await {
|
match tokio::signal::ctrl_c().await {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
let _ = restore_dns();
|
edge.quic_endpoint.close(0u32.into(), "bye".as_bytes());
|
||||||
|
println!("quic is quitting");
|
||||||
delete_pid_file();
|
delete_pid_file();
|
||||||
|
let _ = restore_dns();
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("failed to listen for shutdown signal: {}", err);
|
eprintln!("failed to listen for shutdown signal: {}", err);
|
||||||
@ -350,7 +348,6 @@ fn main() {
|
|||||||
let out = OpenOptions::new()
|
let out = OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
.truncate(true)
|
.truncate(true)
|
||||||
.append(true)
|
|
||||||
.write(true)
|
.write(true)
|
||||||
.open("/tmp/punchnet.out").unwrap();
|
.open("/tmp/punchnet.out").unwrap();
|
||||||
let err = OpenOptions::new()
|
let err = OpenOptions::new()
|
||||||
|
|||||||
@ -307,10 +307,10 @@ impl TunTapPacketHandler for Iface {
|
|||||||
|
|
||||||
send_packet_to_net(edge, target, &msg, size as u64).await;
|
send_packet_to_net(edge, target, &msg, size as u64).await;
|
||||||
} else {
|
} else {
|
||||||
println!("erro 2");
|
error!("erro 2");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("erro 1");
|
error!("erro 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@ -122,11 +122,11 @@ impl Iface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let gw = ip_to_string(&default_gw);
|
let gw = ip_to_string(&default_gw);
|
||||||
println!("gw = {}", gw);
|
debug!("gw = {}", gw);
|
||||||
if let Err(e) = set_dns(&self.name, network_domain, &gw, self.if_idx) {
|
if let Err(e) = set_dns(&self.name, network_domain, &gw, self.if_idx) {
|
||||||
println!("failed to set dns: {:?}", e);
|
error!("failed to set dns: {:?}", e);
|
||||||
} else {
|
} else {
|
||||||
println!("set dns ok");
|
error!("set dns ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -420,7 +420,7 @@ fn create_wintun(path: &str, name: &str) -> Iface {
|
|||||||
.expect("failed to create tun adapter"),
|
.expect("failed to create tun adapter"),
|
||||||
};
|
};
|
||||||
let idx = adapter.get_adapter_index().expect("failed to get adapter index");
|
let idx = adapter.get_adapter_index().expect("failed to get adapter index");
|
||||||
println!("idx = {}", idx);
|
// println!("idx = {}", idx);
|
||||||
let session = Arc::new(adapter.start_session(wintun::MAX_RING_CAPACITY).unwrap());
|
let session = Arc::new(adapter.start_session(wintun::MAX_RING_CAPACITY).unwrap());
|
||||||
Iface {
|
Iface {
|
||||||
if_idx: idx,
|
if_idx: idx,
|
||||||
@ -451,7 +451,7 @@ pub fn set_dns(name: &str, _network_domain: &str, gw: &str, ifidx: u32) -> std::
|
|||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
println!("res1: {}", res.status.success());
|
//println!("res1: {}", res.status.success());
|
||||||
|
|
||||||
println!("route set ok");
|
println!("route set ok");
|
||||||
let res = Command::new("netsh")
|
let res = Command::new("netsh")
|
||||||
@ -464,7 +464,7 @@ pub fn set_dns(name: &str, _network_domain: &str, gw: &str, ifidx: u32) -> std::
|
|||||||
.arg("validate=no")
|
.arg("validate=no")
|
||||||
.creation_flags(0x08000000)
|
.creation_flags(0x08000000)
|
||||||
.output()?;
|
.output()?;
|
||||||
println!("res2: {}", res.status.success());
|
// println!("res2: {}", res.status.success());
|
||||||
|
|
||||||
println!("netsh set ok");
|
println!("netsh set ok");
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use futures_util::pin_mut;
|
|||||||
use prost::Message;
|
use prost::Message;
|
||||||
use quinn::SendStream;
|
use quinn::SendStream;
|
||||||
use sdlan_sn_rs::{config::AF_INET, peer::{SdlanSock, V6Info}, utils::{Result, SDLanError, get_current_timestamp, ip_to_string, rsa_decrypt}};
|
use sdlan_sn_rs::{config::AF_INET, peer::{SdlanSock, V6Info}, utils::{Result, SDLanError, get_current_timestamp, ip_to_string, rsa_decrypt}};
|
||||||
use tokio::{sync::mpsc::{Receiver, Sender, channel}};
|
use tokio::{sync::mpsc::{Receiver, Sender, channel}, time::sleep};
|
||||||
|
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
@ -534,7 +534,7 @@ impl ReadWriteActor {
|
|||||||
Ok(conn) => conn,
|
Ok(conn) => conn,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("failed to connect: {}", e);
|
error!("failed to connect: {}", e);
|
||||||
println!("failed to connect: {}", e);
|
// println!("failed to connect: {}", e);
|
||||||
|
|
||||||
self.connected.store(false, Ordering::Relaxed);
|
self.connected.store(false, Ordering::Relaxed);
|
||||||
if keep_reconnect {
|
if keep_reconnect {
|
||||||
@ -548,7 +548,7 @@ impl ReadWriteActor {
|
|||||||
|
|
||||||
let conn = match conn.await {
|
let conn = match conn.await {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("failed to connect await: {}", e);
|
// println!("failed to connect await: {}", e);
|
||||||
error!("failed to connect await: {}", e);
|
error!("failed to connect await: {}", e);
|
||||||
self.connected.store(false, Ordering::Relaxed);
|
self.connected.store(false, Ordering::Relaxed);
|
||||||
if keep_reconnect {
|
if keep_reconnect {
|
||||||
@ -574,6 +574,8 @@ impl ReadWriteActor {
|
|||||||
|
|
||||||
self.connected.store(true, Ordering::Relaxed);
|
self.connected.store(true, Ordering::Relaxed);
|
||||||
debug!("connected");
|
debug!("connected");
|
||||||
|
|
||||||
|
sleep(Duration::from_millis(200)).await;
|
||||||
on_connected_callback(local_ip, &mut send, start_pkt_id.take()).await;
|
on_connected_callback(local_ip, &mut send, start_pkt_id.take()).await;
|
||||||
|
|
||||||
if let Some(ref connecting_chan) = self.connecting_chan {
|
if let Some(ref connecting_chan) = self.connecting_chan {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user