2 Commits

Author SHA1 Message Date
PoliEcho 8f2c66c195 Update README.md 2025-08-03 13:41:37 +00:00
PoliEcho 6898f946fa Update README.md 2025-08-03 13:38:18 +00:00
3 changed files with 13 additions and 21 deletions
+5 -1
View File
@@ -1,9 +1,13 @@
# Pea 2 Pea # Pea 2 Pea
very simple P2P VPN(Virtual Network yes, Private maybe), very simple P2P VPN(Virtual Network yes, Private maybe),
this program is intended to help you play LAN games over internet this program is intended to help you play LAN games over internet and as proof of concept
when all clients are behind Full-cone NAT, does not work with clients behind Symmetric NAT when all clients are behind Full-cone NAT, does not work with clients behind Symmetric NAT
at least for now at least for now
> [!WARNING]
> Piercing NAT may fail based on network configuration
## how to run ## how to run
> install rustc and cargo or rustup, you will need 2024 edition > install rustc and cargo or rustup, you will need 2024 edition
> build using > build using
+7 -19
View File
@@ -21,8 +21,7 @@ use crate::types::Network;
struct Cli { struct Cli {
#[arg(short = 'r', long = "registrar")] #[arg(short = 'r', long = "registrar")]
#[arg(help = "registrar ip address or hostname")] #[arg(help = "registrar ip address or hostname")]
#[arg(required_unless_present = "version")] registrar: String,
registrar: Option<String>,
#[arg(short = 'p', long = "registrar-port")] #[arg(short = 'p', long = "registrar-port")]
#[arg(help = format!("optional Port number for the registrar service (1-65535) Default: {}", SERVER_PORT))] #[arg(help = format!("optional Port number for the registrar service (1-65535) Default: {}", SERVER_PORT))]
@@ -30,8 +29,7 @@ struct Cli {
#[arg(short = 'n', long = "network-id")] #[arg(short = 'n', long = "network-id")]
#[arg(help = "your virtual network id that allows other people to connect to you")] #[arg(help = "your virtual network id that allows other people to connect to you")]
#[arg(required_unless_present = "version")] network_id: String,
network_id: Option<String>,
#[arg(short = 'P', long = "password")] #[arg(short = 'P', long = "password")]
#[arg( #[arg(
@@ -54,19 +52,9 @@ struct Cli {
symmetric_nat_bypass_mode: bool, symmetric_nat_bypass_mode: bool,
} }
fn print_version() {
println!("Pea 2 Pea {}", VERSION);
}
fn main() -> std::io::Result<()> { fn main() -> std::io::Result<()> {
let cli = <Cli as clap::Parser>::parse(); let cli = <Cli as clap::Parser>::parse();
if cli.version { if cli.network_id.len() > 0xff {
print_version();
exit(0);
}
let network_id = cli.network_id.unwrap();
let registrar = cli.registrar.unwrap();
if network_id.len() > 0xff {
eprintln!("network id cannot have more then 255 charactes"); eprintln!("network id cannot have more then 255 charactes");
exit(7); // posix for E2BIG exit(7); // posix for E2BIG
} }
@@ -93,11 +81,11 @@ fn main() -> std::io::Result<()> {
})(); })();
#[allow(non_snake_case)] // i think this is valid snake case but rustc doesnt think so #[allow(non_snake_case)] // i think this is valid snake case but rustc doesnt think so
let server_SocketAddr: core::net::SocketAddr = format!("{}:{}", registrar, server_port) let server_SocketAddr: core::net::SocketAddr = format!("{}:{}", cli.registrar, server_port)
.parse() .parse()
.expect(&format!( .expect(&format!(
"{}:{} is invalid sock addr", "{}:{} is invalid sock addr",
registrar, server_port cli.registrar, server_port
)); ));
// query here // query here
@@ -146,7 +134,7 @@ fn main() -> std::io::Result<()> {
&mut buf, &mut buf,
&server_SocketAddr, &server_SocketAddr,
&socket, &socket,
&network_id, &cli.network_id,
&cli.password, &cli.password,
) { ) {
Ok(n) => { Ok(n) => {
@@ -173,7 +161,7 @@ fn main() -> std::io::Result<()> {
None => false, None => false,
}, },
encryption_key, encryption_key,
network_id, cli.network_id,
salt, salt,
Vec::with_capacity(1), Vec::with_capacity(1),
); );
+1 -1
View File
@@ -4,7 +4,7 @@ pub const SERVER_PORT: u16 = 3543;
pub const UDP_BUFFER_SIZE: usize = 65527; pub const UDP_BUFFER_SIZE: usize = 65527;
pub const IP_BUFFER_SIZE: usize = 65535; pub const IP_BUFFER_SIZE: usize = 65535;
pub const DEFAULT_TIMEOUT: u64 = 30; pub const DEFAULT_TIMEOUT: u64 = 30;
pub const VERSION: &str = "v1.1"; pub const VERSION: &str = "v1.0";
pub const BLOCK_SIZE: usize = 16; pub const BLOCK_SIZE: usize = 16;
pub const STANDARD_RETRY_MAX: usize = 10; pub const STANDARD_RETRY_MAX: usize = 10;