@@ -74,6 +74,7 @@ pub(crate) trait SerialConsoleStreamBuilder: Send {
74
74
& mut self ,
75
75
address : SocketAddr ,
76
76
offset : WSClientOffset ,
77
+ readonly : bool ,
77
78
) -> Result < Box < dyn SerialConsoleStream > , WSError > ;
78
79
}
79
80
@@ -95,6 +96,7 @@ impl SerialConsoleStreamBuilder for PropolisSerialBuilder {
95
96
& mut self ,
96
97
address : SocketAddr ,
97
98
offset : WSClientOffset ,
99
+ readonly : bool ,
98
100
) -> Result < Box < dyn SerialConsoleStream > , WSError > {
99
101
let client = PropolisClient :: new ( & format ! ( "http://{}" , address) ) ;
100
102
let mut req = client. instance_serial ( ) ;
@@ -108,6 +110,7 @@ impl SerialConsoleStreamBuilder for PropolisSerialBuilder {
108
110
}
109
111
}
110
112
113
+ req = req. writable ( !readonly) ;
111
114
let upgraded = req
112
115
. send ( )
113
116
. await
@@ -157,6 +160,7 @@ impl<St: SerialConsoleStream + 'static> SerialConsoleStreamBuilder
157
160
// offset is currently unused by this builder. Worth testing in
158
161
// the future.
159
162
_offset : WSClientOffset ,
163
+ _readonly : bool ,
160
164
) -> Result < Box < dyn SerialConsoleStream > , WSError > {
161
165
if let Some ( ( delay, stream) ) =
162
166
self . client_conns_and_delays . remove ( & address)
@@ -191,6 +195,7 @@ pub enum WSClientOffset {
191
195
pub struct InstanceSerialConsoleHelper {
192
196
stream_builder : Box < dyn SerialConsoleStreamBuilder > ,
193
197
ws_stream : WebSocketStream < Box < dyn SerialConsoleStream > > ,
198
+ readonly : bool ,
194
199
log : Option < Logger > ,
195
200
}
196
201
@@ -202,10 +207,12 @@ impl InstanceSerialConsoleHelper {
202
207
pub async fn new (
203
208
address : SocketAddr ,
204
209
offset : WSClientOffset ,
210
+ readonly : bool ,
205
211
log : Option < Logger > ,
206
212
) -> Result < Self , WSError > {
207
213
let stream_builder = PropolisSerialBuilder :: new ( ) ;
208
- Self :: new_with_builder ( stream_builder, address, offset, log) . await
214
+ Self :: new_with_builder ( stream_builder, address, offset, readonly, log)
215
+ . await
209
216
}
210
217
211
218
/// Creates a new serial console helper for testing.
@@ -217,14 +224,16 @@ impl InstanceSerialConsoleHelper {
217
224
connections : impl IntoIterator < Item = ( SocketAddr , St ) > ,
218
225
address : SocketAddr ,
219
226
offset : WSClientOffset ,
227
+ readonly : bool ,
220
228
log : Option < Logger > ,
221
229
) -> Result < Self , WSError > {
222
230
let stream_builder = TestSerialBuilder :: new (
223
231
connections
224
232
. into_iter ( )
225
233
. map ( |( addr, stream) | ( addr, Duration :: ZERO , stream) ) ,
226
234
) ;
227
- Self :: new_with_builder ( stream_builder, address, offset, log) . await
235
+ Self :: new_with_builder ( stream_builder, address, offset, readonly, log)
236
+ . await
228
237
}
229
238
230
239
/// Creates a new serial console helper for testing, with delays before
@@ -238,23 +247,31 @@ impl InstanceSerialConsoleHelper {
238
247
connections : impl IntoIterator < Item = ( SocketAddr , Duration , St ) > ,
239
248
address : SocketAddr ,
240
249
offset : WSClientOffset ,
250
+ readonly : bool ,
241
251
log : Option < Logger > ,
242
252
) -> Result < Self , WSError > {
243
253
let stream_builder = TestSerialBuilder :: new ( connections) ;
244
- Self :: new_with_builder ( stream_builder, address, offset, log) . await
254
+ Self :: new_with_builder ( stream_builder, address, offset, readonly, log)
255
+ . await
245
256
}
246
257
247
258
// Currently used for testing, and not exposed to clients.
248
259
pub ( crate ) async fn new_with_builder (
249
260
mut stream_builder : impl SerialConsoleStreamBuilder + ' static ,
250
261
address : SocketAddr ,
251
262
offset : WSClientOffset ,
263
+ readonly : bool ,
252
264
log : Option < Logger > ,
253
265
) -> Result < Self , WSError > {
254
- let stream = stream_builder. build ( address, offset) . await ?;
266
+ let stream = stream_builder. build ( address, offset, readonly ) . await ?;
255
267
let ws_stream =
256
268
WebSocketStream :: from_raw_socket ( stream, Role :: Client , None ) . await ;
257
- Ok ( Self { stream_builder : Box :: new ( stream_builder) , ws_stream, log } )
269
+ Ok ( Self {
270
+ stream_builder : Box :: new ( stream_builder) ,
271
+ ws_stream,
272
+ readonly,
273
+ log,
274
+ } )
258
275
}
259
276
260
277
/// Receives the next [WSMessage] from the server, holding it in
@@ -401,6 +418,7 @@ impl InstanceSerialConsoleMessage<'_> {
401
418
. build (
402
419
destination,
403
420
WSClientOffset :: FromStart ( from_start) ,
421
+ self . helper . readonly ,
404
422
)
405
423
. await ?;
406
424
self . helper . ws_stream = WebSocketStream :: from_raw_socket (
@@ -463,6 +481,7 @@ mod test {
463
481
[ ( address, client_conn) ] ,
464
482
address,
465
483
WSClientOffset :: FromStart ( 0 ) ,
484
+ false ,
466
485
None ,
467
486
)
468
487
. await
@@ -514,6 +533,7 @@ mod test {
514
533
] ,
515
534
address_1,
516
535
WSClientOffset :: FromStart ( 0 ) ,
536
+ false ,
517
537
None ,
518
538
)
519
539
. await
0 commit comments