@@ -13,7 +13,6 @@ use defguard_version::{
1313 ComponentInfo , DefguardComponent , Version , get_tracing_variables, server:: DefguardVersionLayer ,
1414} ;
1515use defguard_wireguard_rs:: { WireguardInterfaceApi , net:: IpAddrMask } ;
16- use gethostname:: gethostname;
1716use tokio:: {
1817 sync:: { mpsc, oneshot} ,
1918 time:: interval,
@@ -35,9 +34,12 @@ use crate::{
3534 } ,
3635 error:: GatewayError ,
3736 execute_command, mask,
38- proto:: gateway:: {
39- Configuration , ConfigurationRequest , CoreRequest , CoreResponse , LogEntry , Peer , Update ,
40- core_request, core_response, gateway_server, update,
37+ proto:: {
38+ common:: LogEntry ,
39+ gateway:: {
40+ Configuration , CoreRequest , CoreResponse , Peer , Update , core_request, core_response,
41+ gateway_server, update,
42+ } ,
4143 } ,
4244 setup:: run_setup,
4345 version:: is_core_version_supported,
@@ -110,7 +112,7 @@ pub async fn run_gateway_loop(
110112#[ derive( Clone , PartialEq ) ]
111113struct InterfaceConfiguration {
112114 name : String ,
113- prvkey : String ,
115+ private_key : String ,
114116 addresses : Vec < IpAddrMask > ,
115117 port : u16 ,
116118 mtu : u32 ,
@@ -127,7 +129,7 @@ impl From<Configuration> for InterfaceConfiguration {
127129 . collect ( ) ;
128130 Self {
129131 name : config. name ,
130- prvkey : config. prvkey ,
132+ private_key : config. private_key ,
131133 addresses,
132134 port : config. port as u16 ,
133135 mtu : config. mtu ,
@@ -384,7 +386,7 @@ impl Gateway {
384386 ) ;
385387 trace ! (
386388 "Received configuration: {:?}" ,
387- mask!( new_configuration, prvkey )
389+ mask!( new_configuration, private_key )
388390 ) ;
389391
390392 // check if new configuration is different than current one
@@ -405,7 +407,7 @@ impl Gateway {
405407 ) ;
406408 trace ! (
407409 "Reconfigured WireGuard interface. Configuration: {:?}" ,
408- mask!( new_configuration, prvkey )
410+ mask!( new_configuration, private_key )
409411 ) ;
410412 // store new configuration and peers
411413 self . interface_configuration = Some ( new_interface_configuration) ;
@@ -685,20 +687,11 @@ impl gateway_server::Gateway for GatewayServer {
685687 }
686688
687689 let ( tx, rx) = mpsc:: unbounded_channel ( ) ;
688- let Ok ( hostname) = gethostname ( ) . into_string ( ) else {
689- error ! ( "Unable to get hostname" ) ;
690- return Err ( Status :: internal ( "failed to get hostname" ) ) ;
691- } ;
692690
693691 // First, send configuration request.
694- #[ allow( deprecated) ]
695- let payload = ConfigurationRequest {
696- name : None , // TODO: remove?
697- hostname,
698- } ;
699692 let req = CoreRequest {
700693 id : self . message_id . fetch_add ( 1 , Ordering :: Relaxed ) ,
701- payload : Some ( core_request:: Payload :: ConfigRequest ( payload ) ) ,
694+ payload : Some ( core_request:: Payload :: ConfigRequest ( ( ) ) ) ,
702695 } ;
703696
704697 match tx. send ( Ok ( req) ) {
@@ -906,7 +899,7 @@ mod tests {
906899 async fn test_configuration_comparison ( ) {
907900 let old_config = InterfaceConfiguration {
908901 name : "gateway" . to_string ( ) ,
909- prvkey : "FGqcPuaSlGWC2j50TBA4jHgiefPgQQcgTNLwzKUzBS8=" . to_string ( ) ,
902+ private_key : "FGqcPuaSlGWC2j50TBA4jHgiefPgQQcgTNLwzKUzBS8=" . to_string ( ) ,
910903 addresses : vec ! [ "10.6.1.1/24" . parse( ) . unwrap( ) ] ,
911904 port : 50051 ,
912905 mtu : 1420 ,
@@ -954,7 +947,7 @@ mod tests {
954947 // only interface config is different
955948 let new_config = InterfaceConfiguration {
956949 name : "gateway" . to_string ( ) ,
957- prvkey : "FGqcPuaSlGWC2j50TBA4jHgiefPgQQcgTNLwzKUzBS8=" . to_string ( ) ,
950+ private_key : "FGqcPuaSlGWC2j50TBA4jHgiefPgQQcgTNLwzKUzBS8=" . to_string ( ) ,
958951 addresses : vec ! [ "10.6.1.2/24" . parse( ) . unwrap( ) ] ,
959952 port : 50051 ,
960953 mtu : 1420 ,
0 commit comments