Changes to be committed:
modified: src/client.rs modified: src/main.rs modified: src/server.rs
This commit is contained in:
parent
8653b8c7a9
commit
ed0d9c4b33
@ -1,7 +1,7 @@
|
|||||||
use crossbeam_channel::{unbounded, Receiver};
|
use crossbeam_channel::{unbounded, Receiver};
|
||||||
use tokio::{io::AsyncWriteExt, net::UdpSocket, sync::{mpsc, Mutex}};
|
use tokio::{net::UdpSocket, sync::{mpsc, Mutex}};
|
||||||
use tokio::task::JoinSet;
|
use tokio::task::JoinSet;
|
||||||
use packet::{builder::Builder, icmp, ip, Packet};
|
use packet::{builder::Builder, icmp, ip};
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use tun2::BoxError;
|
use tun2::BoxError;
|
||||||
use log::{error, info, warn, LevelFilter};
|
use log::{error, info, warn, LevelFilter};
|
||||||
@ -9,7 +9,6 @@ use std::sync::Arc;
|
|||||||
use std::net::{ SocketAddr, Ipv4Addr };
|
use std::net::{ SocketAddr, Ipv4Addr };
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tokio::io::AsyncReadExt;
|
|
||||||
use x25519_dalek::{PublicKey, SharedSecret, StaticSecret};
|
use x25519_dalek::{PublicKey, SharedSecret, StaticSecret};
|
||||||
use aes_gcm::{
|
use aes_gcm::{
|
||||||
aead::{Aead, AeadCore, KeyInit, OsRng},
|
aead::{Aead, AeadCore, KeyInit, OsRng},
|
||||||
@ -70,7 +69,7 @@ pub async fn client_mode(client_config: ClientConfiguration) {
|
|||||||
config.address(&client_config.client.address)
|
config.address(&client_config.client.address)
|
||||||
.netmask("128.0.0.0")
|
.netmask("128.0.0.0")
|
||||||
.destination("0.0.0.0")
|
.destination("0.0.0.0")
|
||||||
.name("tun0")
|
.tun_name("tun0")
|
||||||
.up();
|
.up();
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@ -165,7 +164,7 @@ pub async fn client_mode(client_config: ClientConfiguration) {
|
|||||||
let s_cipher = cipher_shared.clone();
|
let s_cipher = cipher_shared.clone();
|
||||||
loop {
|
loop {
|
||||||
if let Ok(bytes) = mx.recv() {
|
if let Ok(bytes) = mx.recv() {
|
||||||
let mut s_c = s_cipher.lock().await;
|
let s_c = s_cipher.lock().await;
|
||||||
|
|
||||||
if s_c.is_some() {
|
if s_c.is_some() {
|
||||||
let aes = Aes256Gcm::new(s_c.as_ref().unwrap().as_bytes().into());
|
let aes = Aes256Gcm::new(s_c.as_ref().unwrap().as_bytes().into());
|
||||||
|
@ -40,7 +40,7 @@ fn generate_peer_config(matches: &ArgMatches, config_path: &str, cfg_raw: &Strin
|
|||||||
|
|
||||||
let mut config: ServerConfiguration = serde_yaml::from_str(cfg_raw).expect("Bad server config file structure");
|
let mut config: ServerConfiguration = serde_yaml::from_str(cfg_raw).expect("Bad server config file structure");
|
||||||
|
|
||||||
let mut prs = &mut config.peers[..];
|
let prs = &mut config.peers[..];
|
||||||
prs.sort_by(|a, b| a.ip.octets()[3].cmp(&b.ip.octets()[3]));
|
prs.sort_by(|a, b| a.ip.octets()[3].cmp(&b.ip.octets()[3]));
|
||||||
|
|
||||||
let mut internal_address = prs.iter()
|
let mut internal_address = prs.iter()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||||
use tokio::{io::AsyncWriteExt, net::{TcpListener, TcpSocket, TcpStream, UdpSocket}, sync::{mpsc, Mutex}};
|
use tokio::{net::{TcpListener, TcpSocket, TcpStream, UdpSocket}, sync::{mpsc, Mutex}};
|
||||||
use tokio::task::JoinSet;
|
use tokio::task::JoinSet;
|
||||||
use packet::{builder::Builder, icmp, ip, AsPacket, Packet};
|
use packet::{builder::Builder, icmp, ip, AsPacket};
|
||||||
use x25519_dalek::{PublicKey, SharedSecret, StaticSecret};
|
use x25519_dalek::{PublicKey, SharedSecret, StaticSecret};
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use tun2::BoxError;
|
use tun2::BoxError;
|
||||||
@ -9,7 +9,6 @@ use log::{error, info, LevelFilter};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::net::{ SocketAddr, Ipv4Addr, IpAddr };
|
use std::net::{ SocketAddr, Ipv4Addr, IpAddr };
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tokio::io::AsyncReadExt;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use aes_gcm::{ aead::{Aead, AeadCore, KeyInit, OsRng},
|
use aes_gcm::{ aead::{Aead, AeadCore, KeyInit, OsRng},
|
||||||
Aes256Gcm, Key, Nonce };
|
Aes256Gcm, Key, Nonce };
|
||||||
@ -102,7 +101,7 @@ pub async fn server_mode(server_config: ServerConfiguration) {
|
|||||||
loop {
|
loop {
|
||||||
if let Ok((len, addr)) = sock_rec.recv_from(&mut buf).await {
|
if let Ok((len, addr)) = sock_rec.recv_from(&mut buf).await {
|
||||||
let mut mp = addrs_lp.lock().await;
|
let mut mp = addrs_lp.lock().await;
|
||||||
let mut plp = peers_lp.lock().await;
|
let plp = peers_lp.lock().await;
|
||||||
match buf.first() {
|
match buf.first() {
|
||||||
Some(h) => {
|
Some(h) => {
|
||||||
match h {
|
match h {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user