fix AllowIps and Address fields for WireGuard client (#99)
- add Wireguard client cidr into AllowIps - change subnet number to 32 in Address field
This commit is contained in:
@@ -360,8 +360,15 @@ async fn main() -> Result<(), Error> {
|
||||
.into_inner()
|
||||
.vpn_portal_info
|
||||
.unwrap_or_default();
|
||||
println!("portal_name: {}\n", resp.vpn_type);
|
||||
println!("client_config:{}", resp.client_config);
|
||||
println!("portal_name: {}", resp.vpn_type);
|
||||
println!(
|
||||
r#"
|
||||
############### client_config_start ###############
|
||||
{}
|
||||
############### client_config_end ###############
|
||||
"#,
|
||||
resp.client_config
|
||||
);
|
||||
println!("connected_clients:\n{:#?}", resp.connected_clients);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ pub async fn async_main(cli: Cli) {
|
||||
});
|
||||
|
||||
println!("Starting easytier with config:");
|
||||
println!("############### TOML ##############\n");
|
||||
println!("############### TOML ###############\n");
|
||||
println!("{}", cfg.dump());
|
||||
println!("-----------------------------------");
|
||||
|
||||
|
||||
@@ -264,33 +264,35 @@ impl VpnPortal for WireGuard {
|
||||
break;
|
||||
}
|
||||
|
||||
let vpn_cfg = global_ctx.config.get_vpn_portal_config().unwrap();
|
||||
let client_cidr = vpn_cfg.client_cidr;
|
||||
|
||||
allow_ips.push(client_cidr.to_string());
|
||||
|
||||
let allow_ips = allow_ips
|
||||
.into_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
|
||||
let vpn_cfg = global_ctx.config.get_vpn_portal_config().unwrap();
|
||||
let client_cidr = vpn_cfg.client_cidr;
|
||||
|
||||
let cfg = self.inner.as_ref().unwrap().wg_config.clone();
|
||||
let cfg_str = format!(
|
||||
r#"
|
||||
[Interface]
|
||||
PrivateKey = {peer_secret_key}
|
||||
Address = {client_cidr} # should assign an ip from this cidr manually
|
||||
Address = {address} # should assign an ip from this cidr manually
|
||||
|
||||
[Peer]
|
||||
PublicKey = {my_public_key}
|
||||
AllowedIPs = {allow_ips}
|
||||
Endpoint = {listenr_addr} # should be the public ip of the vpn server
|
||||
Endpoint = {listenr_addr} # should be the public ip(or domain) of the vpn server
|
||||
PersistentKeepalive = 25
|
||||
"#,
|
||||
peer_secret_key = BASE64_STANDARD.encode(cfg.peer_secret_key()),
|
||||
my_public_key = BASE64_STANDARD.encode(cfg.my_public_key()),
|
||||
listenr_addr = self.inner.as_ref().unwrap().listenr_addr,
|
||||
allow_ips = allow_ips,
|
||||
client_cidr = client_cidr,
|
||||
address = client_cidr.first_address().to_string() + "/32",
|
||||
);
|
||||
|
||||
cfg_str
|
||||
|
||||
Reference in New Issue
Block a user