Compare commits
	
		
			2 Commits
		
	
	
		
			4ca652cea5
			...
			8e9d179d49
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 8e9d179d49 | |||
| bc17ffac68 | 
							
								
								
									
										12
									
								
								Cargo.toml
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								Cargo.toml
									
									
									
									
									
								
							| @ -28,13 +28,23 @@ rayon = "1.10.0" | ||||
| readonly = "0.2.13" | ||||
| sha2 = "0.10.9" | ||||
| smol = "2.0.2" | ||||
| tappers = "0.4.2" | ||||
| 
 | ||||
| 
 | ||||
| [target.'cfg(windows)'.dependencies] | ||||
| winapi = { version = "0.3", features = ["winsock2", "mswsock", "minwindef"] } | ||||
| tappers = { version = "0.4.2", features = ["wintun"] } | ||||
| 
 | ||||
| [target.'cfg(unix)'.dependencies] | ||||
| libc = "0.2" | ||||
| tappers = "0.4.2" | ||||
| 
 | ||||
| [target.x86_64-pc-windows-gnu] | ||||
| linker = "/usr/bin/x86_64-w64-mingw32-gcc" | ||||
| ar = "/usr/bin/x86_64-w64-mingw32-ar" | ||||
| 
 | ||||
| [target.i686-pc-windows-gnu] | ||||
| linker = "/usr/bin/i686-w64-mingw32-gcc" | ||||
| ar = "/usr/bin/i686-w64-mingw32-ar" | ||||
| 
 | ||||
| 
 | ||||
| [features] | ||||
|  | ||||
| @ -1,9 +1,9 @@ | ||||
| use std::sync::{Arc, RwLock}; | ||||
| 
 | ||||
| use pea_2_pea::*; | ||||
| use rand::RngCore; | ||||
| use rayon::prelude::*; | ||||
| use sha2::Digest; | ||||
| use std::sync::{Arc, RwLock}; | ||||
| use tappers::Interface; | ||||
| 
 | ||||
| use crate::types::Network; | ||||
| 
 | ||||
| @ -11,15 +11,36 @@ pub fn create_tun_interface( | ||||
|     private_ip: std::net::Ipv4Addr, | ||||
|     if_name: Option<String>, | ||||
| ) -> Result<tappers::Tun, std::io::Error> { | ||||
|     let mut tun_iface: tappers::Tun = tappers::Tun::new_named(tappers::Interface::new( | ||||
|         if_name.unwrap_or("pea0".to_owned()), | ||||
|     #[cfg(not(target_os = "windows"))] | ||||
|     let mut tun_iface: tappers::Tun = tappers::Tun::new_named(Interface::new( | ||||
|         &if_name.unwrap_or(DEFAULT_INTERFACE_NAME.to_owned()), | ||||
|     )?)?; | ||||
|     #[cfg(target_os = "windows")] | ||||
|     let mut tun_iface: tappers::Tun = tappers::Tun::new()?; | ||||
|     #[cfg(not(target_os = "windows"))] | ||||
|     { | ||||
|         let mut addr_req = tappers::AddAddressV4::new(private_ip); | ||||
|         addr_req.set_netmask(24); | ||||
|         let mut broadcast_addr_oct = private_ip.octets(); | ||||
|         broadcast_addr_oct[3] = 255; | ||||
|         addr_req.set_broadcast(std::net::Ipv4Addr::from(broadcast_addr_oct)); | ||||
|         tun_iface.add_addr(addr_req)?; | ||||
|     } | ||||
|     #[cfg(target_os = "windows")] | ||||
|     std::process::Command::new("netsh").args([ | ||||
|         "interface", | ||||
|         "ipv4", | ||||
|         "set", | ||||
|         "address", | ||||
|         &format!( | ||||
|             "name=\"{}\"", | ||||
|             tun_iface.name()?.name().into_string().unwrap() | ||||
|         ), | ||||
|         "static", | ||||
|         &private_ip.to_string(), | ||||
|         "255.255.255.0", | ||||
|     ]); | ||||
| 
 | ||||
|     tun_iface.set_up()?; | ||||
|     return Ok(tun_iface); | ||||
| } | ||||
|  | ||||
| @ -4,7 +4,7 @@ pub const SERVER_PORT: u16 = 3543; | ||||
| pub const UDP_BUFFER_SIZE: usize = 65527; | ||||
| pub const IP_BUFFER_SIZE: usize = 65535; | ||||
| pub const DEFAULT_TIMEOUT: u64 = 30; | ||||
| pub const VERSION: &str = "v0.1"; | ||||
| pub const VERSION: &str = "v1.0"; | ||||
| pub const BLOCK_SIZE: usize = 16; | ||||
| pub const STANDARD_RETRY_MAX: usize = 10; | ||||
| 
 | ||||
| @ -15,6 +15,8 @@ pub const MAPPING_SHOT_COUNT: u8 = 5; | ||||
| 
 | ||||
| pub const DEFAULT_NETWORK_PREFIX: [u8; 3] = [172, 22, 44]; | ||||
| 
 | ||||
| pub const DEFAULT_INTERFACE_NAME: &str = "pea0"; | ||||
| 
 | ||||
| #[repr(u8)] | ||||
| #[allow(non_camel_case_types)] | ||||
| pub enum ServerMethods { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user