File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,18 @@ def do_proxy(self, target):
222
222
tqueue .extend (bufs )
223
223
224
224
if closed :
225
+
226
+ while (len (tqueue ) != 0 ):
227
+ # Send queued client data to the target
228
+ dat = tqueue .pop (0 )
229
+ sent = target .send (dat )
230
+ if sent == len (dat ):
231
+ self .print_traffic (">" )
232
+ else :
233
+ # requeue the remaining data
234
+ tqueue .insert (0 , dat [sent :])
235
+ self .print_traffic (".>" )
236
+
225
237
# TODO: What about blocking on client socket?
226
238
if self .verbose :
227
239
self .log_message ("%s:%s: Client closed connection" ,
@@ -245,6 +257,16 @@ def do_proxy(self, target):
245
257
# Receive target data, encode it and queue for client
246
258
buf = target .recv (self .buffer_size )
247
259
if len (buf ) == 0 :
260
+
261
+ # Target socket closed, flushing queues and closing client-side websocket
262
+ # Send queued target data to the client
263
+ if len (cqueue ) != 0 :
264
+ c_pend = True
265
+ while (c_pend ):
266
+ c_pend = self .send_frames (cqueue )
267
+
268
+ cqueue = []
269
+
248
270
if self .verbose :
249
271
self .log_message ("%s:%s: Target closed connection" ,
250
272
self .server .target_host , self .server .target_port )
You can’t perform that action at this time.
0 commit comments