11use std:: {
22 error:: Error ,
3- fs:: { read_to_string , File } ,
3+ fs:: { File , read_to_string } ,
44 io:: Write ,
55 path:: Path ,
66 str:: FromStr ,
@@ -9,12 +9,19 @@ use std::{
99
1010use base64:: Engine ;
1111use defguard_wireguard_rs:: {
12- host:: Peer , key:: Key , net:: IpAddrMask , InterfaceConfiguration , WGApi , WireguardInterfaceApi ,
12+ InterfaceConfiguration , WGApi , WireguardInterfaceApi , host:: Peer , key:: Key , net:: IpAddrMask ,
1313} ;
1414use serde:: { Deserialize , Serialize } ;
1515use tokio:: time:: sleep;
1616use x25519_dalek:: { PublicKey , StaticSecret } ;
1717
18+ #[ cfg( not( any( target_os = "macos" , target_os = "windows" , target_arch = "arm" ) ) ) ]
19+ use tikv_jemallocator:: Jemalloc ;
20+
21+ #[ cfg( not( any( target_os = "macos" , target_os = "windows" , target_arch = "arm" ) ) ) ]
22+ #[ global_allocator]
23+ static GLOBAL : Jemalloc = Jemalloc ;
24+
1825#[ derive( Debug , Clone , Serialize , Deserialize ) ]
1926struct ServerConfig {
2027 pub name : Option < String > ,
@@ -79,14 +86,14 @@ async fn fetch_and_apply_config(
7986 return Ok ( ( ) ) ;
8087 }
8188 let my_config = my_config. unwrap ( ) ;
82- if my_config. internal_cidr != interface_config. address
89+ if my_config. internal_cidr != interface_config. addresses [ 0 ] . to_string ( )
8390 || my_config. port != interface_config. port
8491 || Some ( r. mtu ) != interface_config. mtu
8592 {
8693 if interface_config. port == 0 {
8794 wgapi. create_interface ( ) ?;
8895 }
89- interface_config. address = my_config. internal_cidr . clone ( ) ;
96+ interface_config. addresses = vec ! [ IpAddrMask :: from_str ( & my_config. internal_cidr) ? ] ;
9097 interface_config. port = my_config. port ;
9198 interface_config. mtu = Some ( r. mtu ) ;
9299 wgapi. configure_interface ( & interface_config) ?;
@@ -174,7 +181,7 @@ async fn main() {
174181 let mut interface_config = InterfaceConfiguration {
175182 name : config. interface_name . clone ( ) ,
176183 prvkey : base64:: engine:: general_purpose:: STANDARD . encode ( secret_key. as_bytes ( ) ) ,
177- address : "" . to_owned ( ) ,
184+ addresses : vec ! [ ] ,
178185 port : 0 ,
179186 peers : vec ! [ ] ,
180187 mtu : None ,
0 commit comments