@@ -3,11 +3,9 @@ use super::{
3
3
helpers:: { connect_and_wait, send_guest_probes} ,
4
4
Error , TestContext ,
5
5
} ;
6
- use crate :: { assert_tunnel_state, vm:: network:: DUMMY_LAN_INTERFACE_IP } ;
7
6
8
7
use mullvad_management_interface:: MullvadProxyClient ;
9
- use mullvad_types:: states:: TunnelState ;
10
- use std:: net:: { IpAddr , SocketAddr } ;
8
+ use std:: net:: SocketAddr ;
11
9
use test_macro:: test_function;
12
10
use test_rpc:: ServiceClient ;
13
11
@@ -22,12 +20,9 @@ pub async fn test_lan(
22
20
rpc : ServiceClient ,
23
21
mut mullvad_client : MullvadProxyClient ,
24
22
) -> Result < ( ) , Error > {
25
- let lan_destination = SocketAddr :: new ( IpAddr :: V4 ( DUMMY_LAN_INTERFACE_IP ) , 1234 ) ;
26
-
27
- // Connect
28
- //
29
-
30
- connect_and_wait ( & mut mullvad_client) . await ?;
23
+ // Take care not to use some bogus IP in the guest's subnet, lest we just send ARP requests
24
+ // These will fail if there's no actual host present
25
+ let lan_destination = "10.1.2.3:1234" . parse ( ) . unwrap ( ) ;
31
26
32
27
// Disable LAN sharing
33
28
//
@@ -39,14 +34,19 @@ pub async fn test_lan(
39
34
. await
40
35
. expect ( "failed to disable LAN sharing" ) ;
41
36
37
+ // Connect
38
+ //
39
+
40
+ connect_and_wait ( & mut mullvad_client) . await ?;
41
+
42
42
// Ensure LAN is not reachable
43
43
//
44
44
45
45
log:: info!( "Test whether outgoing LAN traffic is blocked" ) ;
46
46
47
47
let default_interface = rpc. get_default_interface ( ) . await ?;
48
48
let detected_probes =
49
- send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , lan_destination) . await ? ;
49
+ send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , lan_destination) . await ;
50
50
assert ! (
51
51
detected_probes. none( ) ,
52
52
"observed unexpected outgoing LAN packets: {detected_probes:?}"
@@ -67,8 +67,7 @@ pub async fn test_lan(
67
67
68
68
log:: info!( "Test whether outgoing LAN traffic is blocked" ) ;
69
69
70
- let detected_probes =
71
- send_guest_probes ( rpc. clone ( ) , default_interface, lan_destination) . await ?;
70
+ let detected_probes = send_guest_probes ( rpc. clone ( ) , default_interface, lan_destination) . await ;
72
71
assert ! (
73
72
detected_probes. all( ) ,
74
73
"did not observe all outgoing LAN packets: {detected_probes:?}"
@@ -96,19 +95,11 @@ pub async fn test_lockdown(
96
95
rpc : ServiceClient ,
97
96
mut mullvad_client : MullvadProxyClient ,
98
97
) -> Result < ( ) , Error > {
99
- let lan_destination: SocketAddr = SocketAddr :: new ( IpAddr :: V4 ( DUMMY_LAN_INTERFACE_IP ) , 1337 ) ;
98
+ // Take care not to use some bogus IP in the guest's subnet, lest we just send ARP requests
99
+ // These will fail if there's no actual host present
100
+ let lan_destination = "10.1.2.3:1234" . parse ( ) . unwrap ( ) ;
100
101
let inet_destination: SocketAddr = "1.1.1.1:1337" . parse ( ) . unwrap ( ) ;
101
102
102
- log:: info!( "Verify tunnel state: disconnected" ) ;
103
- assert_tunnel_state ! ( & mut mullvad_client, TunnelState :: Disconnected { .. } ) ;
104
-
105
- // Enable lockdown mode
106
- //
107
- mullvad_client
108
- . set_block_when_disconnected ( true )
109
- . await
110
- . expect ( "failed to enable lockdown mode" ) ;
111
-
112
103
// Disable LAN sharing
113
104
//
114
105
@@ -119,20 +110,27 @@ pub async fn test_lockdown(
119
110
. await
120
111
. expect ( "failed to disable LAN sharing" ) ;
121
112
113
+ // Enable lockdown mode
114
+ //
115
+ mullvad_client
116
+ . set_block_when_disconnected ( true )
117
+ . await
118
+ . expect ( "failed to enable lockdown mode" ) ;
119
+
122
120
// Ensure all destinations are unreachable
123
121
//
124
122
125
123
let default_interface = rpc. get_default_interface ( ) . await ?;
126
124
127
125
let detected_probes =
128
- send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , lan_destination) . await ? ;
126
+ send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , lan_destination) . await ;
129
127
assert ! (
130
128
detected_probes. none( ) ,
131
129
"observed outgoing packets to LAN: {detected_probes:?}"
132
130
) ;
133
131
134
132
let detected_probes =
135
- send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , inet_destination) . await ? ;
133
+ send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , inet_destination) . await ;
136
134
assert ! (
137
135
detected_probes. none( ) ,
138
136
"observed outgoing packets to internet: {detected_probes:?}"
@@ -152,14 +150,14 @@ pub async fn test_lockdown(
152
150
//
153
151
154
152
let detected_probes =
155
- send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , lan_destination) . await ? ;
153
+ send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , lan_destination) . await ;
156
154
assert ! (
157
155
detected_probes. all( ) ,
158
156
"did not observe some outgoing packets: {detected_probes:?}"
159
157
) ;
160
158
161
159
let detected_probes =
162
- send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , inet_destination) . await ? ;
160
+ send_guest_probes ( rpc. clone ( ) , default_interface. clone ( ) , inet_destination) . await ;
163
161
assert ! (
164
162
detected_probes. none( ) ,
165
163
"observed outgoing packets to internet: {detected_probes:?}"
@@ -180,19 +178,11 @@ pub async fn test_lockdown(
180
178
181
179
// Send traffic outside the tunnel to sanity check that the internet is *not* reachable via non-
182
180
// tunnel interfaces.
183
- let detected_probes =
184
- send_guest_probes ( rpc. clone ( ) , default_interface, inet_destination) . await ?;
181
+ let detected_probes = send_guest_probes ( rpc. clone ( ) , default_interface, inet_destination) . await ;
185
182
assert ! (
186
183
detected_probes. none( ) ,
187
184
"observed outgoing packets to internet: {detected_probes:?}"
188
185
) ;
189
186
190
- // Disable lockdown mode
191
- //
192
- mullvad_client
193
- . set_block_when_disconnected ( false )
194
- . await
195
- . expect ( "failed to disable lockdown mode" ) ;
196
-
197
187
Ok ( ( ) )
198
188
}
0 commit comments