Changes to be committed:
new file: Cargo.lock modified: src/client.rs modified: src/main.rs modified: src/server.rs
This commit is contained in:
parent
e213a817dc
commit
edb9e01dd7
1082
Cargo.lock
generated
Normal file
1082
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@ use tun::platform::Device;
|
||||
use serde_derive::Serialize;
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
pub async fn client_mode() -> io::Result<()> {
|
||||
pub async fn client_mode(remote_addr: &str) -> io::Result<()> {
|
||||
info!("Starting client...");
|
||||
|
||||
let mut config = tun::Configuration::default();
|
||||
@ -22,7 +22,6 @@ pub async fn client_mode() -> io::Result<()> {
|
||||
let sock = Arc::new(Mutex::new(UdpSocket::bind("0.0.0.0:59611").await?));
|
||||
|
||||
let sock_main = sock.clone();
|
||||
let remote_addr = "127.0.0.1:8879";
|
||||
let sock_main_instance = sock_main.lock().await;
|
||||
sock_main_instance.connect(remote_addr).await?;
|
||||
|
||||
|
13
src/main.rs
13
src/main.rs
@ -41,6 +41,15 @@ async fn main() {
|
||||
.get_matches();
|
||||
|
||||
let is_server_mode = matches.value_of("mode").unwrap() == "server";
|
||||
|
||||
if is_server_mode { server::server_mode().await; } else { client::client_mode().await; }
|
||||
// "192.168.0.4:8879"
|
||||
if is_server_mode {
|
||||
server::server_mode().await;
|
||||
} else {
|
||||
if let Some(vpn_server_ip) = matches.value_of("vpn-server") {
|
||||
let server_address = format!("{}:8879", vpn_server_ip);
|
||||
client::client_mode(server_address.as_str()).await;
|
||||
} else {
|
||||
eprintln!("Error: For client mode, you shall provide the '--vpn-server' argument.");
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ pub async fn server_mode() -> io::Result<()> {
|
||||
|
||||
let tun_device = Arc::new(Mutex::new(tun::create(&config).unwrap()));
|
||||
|
||||
let sock = Arc::new(Mutex::new(UdpSocket::bind("127.0.0.1:8879".parse::<SocketAddr>().unwrap()).await?));
|
||||
let sock = Arc::new(Mutex::new(UdpSocket::bind("192.168.0.5:8879".parse::<SocketAddr>().unwrap()).await?));
|
||||
|
||||
let clients = Arc::new(Mutex::new(HashMap::new()));
|
||||
|
||||
@ -42,9 +42,7 @@ pub async fn server_mode() -> io::Result<()> {
|
||||
}*/
|
||||
|
||||
let sock_main = sock.clone();
|
||||
let remote_addr = "127.0.0.1:8879";
|
||||
let sock_main_instance = sock_main.lock().await;
|
||||
sock_main_instance.connect(remote_addr).await?;
|
||||
let clients_main = clients.clone();
|
||||
let clients_main_instance = clients_main.lock().await;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user