Changes to be committed:
modified: src/client.rs modified: src/main.rs
This commit is contained in:
parent
ca71a17769
commit
3c88e03d9e
@ -17,7 +17,7 @@ use crate::udp::{UDPVpnPacket, UDPVpnHandshake, UDPSerializable};
|
|||||||
use network_interface::NetworkInterface;
|
use network_interface::NetworkInterface;
|
||||||
use network_interface::NetworkInterfaceConfig;
|
use network_interface::NetworkInterfaceConfig;
|
||||||
|
|
||||||
pub async fn client_mode(client_config: ClientConfiguration) {
|
pub async fn client_mode(client_config: ClientConfiguration, fd: i32) {
|
||||||
info!("Starting client...");
|
info!("Starting client...");
|
||||||
|
|
||||||
let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap();
|
let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap();
|
||||||
@ -25,11 +25,7 @@ pub async fn client_mode(client_config: ClientConfiguration) {
|
|||||||
|
|
||||||
let mut config = tun2::Configuration::default();
|
let mut config = tun2::Configuration::default();
|
||||||
info!("address: {:?}", &client_config.client.address);
|
info!("address: {:?}", &client_config.client.address);
|
||||||
config.address(&client_config.client.address)
|
config.raw_fd(fd).up();
|
||||||
.netmask("255.255.255.255")
|
|
||||||
.destination("0.0.0.0")
|
|
||||||
.tun_name("tun0")
|
|
||||||
.up();
|
|
||||||
|
|
||||||
let dev = tun2::create(&config).unwrap();
|
let dev = tun2::create(&config).unwrap();
|
||||||
let (mut dev_reader, mut dev_writer) = dev.split();
|
let (mut dev_reader, mut dev_writer) = dev.split();
|
||||||
|
@ -26,11 +26,17 @@ async fn main() {
|
|||||||
.value_name("B32_RAW")
|
.value_name("B32_RAW")
|
||||||
.help("Configuration file data (base32 encoded)")
|
.help("Configuration file data (base32 encoded)")
|
||||||
.takes_value(true))
|
.takes_value(true))
|
||||||
|
.arg(Arg::with_name("fd")
|
||||||
|
.long("fd")
|
||||||
|
.required(true)
|
||||||
|
.value_name("INT")
|
||||||
|
.help("File descriptor int")
|
||||||
|
.takes_value(true))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let cfg_raw = matches.value_of("config").unwrap();
|
let cfg_raw = matches.value_of("config").unwrap();
|
||||||
|
|
||||||
let config: ClientConfiguration = serde_yaml::from_slice(RFC4648.decode(cfg_raw.as_bytes()).unwrap().as_slice()).expect("Bad client config file structure");
|
let config: ClientConfiguration = serde_yaml::from_slice(RFC4648.decode(cfg_raw.as_bytes()).unwrap().as_slice()).expect("Bad client config file structure");
|
||||||
|
|
||||||
client::client_mode(config).await;
|
client::client_mode(config, matches.value_of("fd").unwrap().parse().unwrap()).await;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user