File tree 3 files changed +14
-6
lines changed
implementations/rust/ockam/ockam_app_lib/src
3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -44,14 +44,15 @@ impl AppState {
44
44
Ok ( port) => {
45
45
if let Some ( service) = guard. find_mut_by_id ( service. id ( ) ) {
46
46
if let Some ( port) = port {
47
- service. set_port ( port)
47
+ service. set_port ( port) ;
48
48
}
49
+ service. set_connected ( true ) ;
49
50
}
50
51
}
51
52
Err ( err) => {
52
53
warn ! ( %err, "Failed to refresh TCP inlet for accepted invitation" ) ;
53
54
if let Some ( service) = guard. find_mut_by_id ( service. id ( ) ) {
54
- service. remove_port ( )
55
+ service. set_connected ( false ) ;
55
56
}
56
57
}
57
58
}
Original file line number Diff line number Diff line change @@ -175,6 +175,8 @@ pub struct IncomingService {
175
175
// this field contains the current port number
176
176
// it also reflects if the inlet is connected with the destination node
177
177
port : Option < Port > ,
178
+ // true when connected to the destination node
179
+ connected : bool ,
178
180
// whether the service should be enabled or not, this is the driver for the inlet
179
181
// and may not reflect the current status
180
182
enabled : bool ,
@@ -216,6 +218,7 @@ impl IncomingService {
216
218
shared_node_identifier,
217
219
original_name,
218
220
enrollment_ticket,
221
+ connected : false ,
219
222
removed : false ,
220
223
}
221
224
}
@@ -240,6 +243,11 @@ impl IncomingService {
240
243
self . port
241
244
}
242
245
246
+ /// Returns true if the inlet is connected to the destination node
247
+ pub fn is_connected ( & self ) -> bool {
248
+ self . connected
249
+ }
250
+
243
251
/// The address of the inlet, if service is connected to the destination node
244
252
pub fn address ( & self ) -> Option < SocketAddr > {
245
253
self . port
@@ -259,16 +267,15 @@ impl IncomingService {
259
267
self . port = Some ( port) ;
260
268
}
261
269
262
- pub fn remove_port ( & mut self ) {
263
- self . port = None ;
270
+ pub fn set_connected ( & mut self , connected : bool ) {
271
+ self . connected = connected ;
264
272
}
265
273
266
274
pub fn enable ( & mut self ) {
267
275
self . enabled = true ;
268
276
}
269
277
pub fn disable ( & mut self ) {
270
278
self . enabled = false ;
271
- self . port = None ;
272
279
}
273
280
274
281
/// True when the service is marked as removed
Original file line number Diff line number Diff line change @@ -622,7 +622,7 @@ impl AppState {
622
622
address : service. address ( ) . map ( |addr| addr. ip ( ) . to_string ( ) ) ,
623
623
port : service. port ( ) ,
624
624
scheme : None ,
625
- available : service. port ( ) . is_some ( ) ,
625
+ available : service. is_connected ( ) ,
626
626
enabled : service. enabled ( ) ,
627
627
} )
628
628
. collect ( ) ;
You can’t perform that action at this time.
0 commit comments