File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -33,11 +33,15 @@ pub enum WireguardInterfaceError {
33
33
KernelNotSupported ,
34
34
#[ error( "DNS error: {0}" ) ]
35
35
DnsError ( String ) ,
36
+ #[ cfg( target_os = "windows" ) ]
36
37
#[ error( "Service installation failed: `{message}`" ) ]
37
38
ServiceInstallationFailed {
38
39
err : std:: io:: Error ,
39
40
message : String ,
40
41
} ,
42
+ #[ cfg( target_os = "windows" ) ]
43
+ #[ error( "Tunnel service removal failed: `{0}`" ) ]
44
+ ServiceRemovalFailed ( String ) ,
41
45
#[ error( "Socket is closed: {0}" ) ]
42
46
SocketClosed ( String ) ,
43
47
}
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
251
251
fn remove_interface ( & self ) -> Result < ( ) , WireguardInterfaceError > {
252
252
debug ! ( "Removing interface {}" , self . ifname) ;
253
253
254
- Command :: new ( "wireguard" )
254
+ let command_output = Command :: new ( "wireguard" )
255
255
. arg ( "/uninstalltunnelservice" )
256
256
. arg ( & self . ifname )
257
257
. output ( )
@@ -260,6 +260,14 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
260
260
WireguardInterfaceError :: CommandExecutionFailed ( err)
261
261
} ) ?;
262
262
263
+ if !command_output. status . success ( ) {
264
+ let message = format ! (
265
+ "Failed to remove WireGuard tunnel service: {:?}" ,
266
+ command_output. stdout
267
+ ) ;
268
+ return Err ( WireguardInterfaceError :: ServiceRemovalError { message } ) ;
269
+ }
270
+
263
271
info ! ( "Interface {} removed successfully" , self . ifname) ;
264
272
Ok ( ( ) )
265
273
}
You can’t perform that action at this time.
0 commit comments