@@ -29,6 +29,8 @@ import {
2929 InputRTCMediaTrackClosed ,
3030 InputRTCExternalPeerAttached ,
3131 InputRuleEvent ,
32+ InputRawPassthrough ,
33+ InputRawPassthroughData ,
3234 InputRequest
3335} from '../../types' ;
3436
@@ -46,6 +48,7 @@ import { parseHar } from '../http/har';
4648
4749import { FailedTlsConnection } from '../tls/failed-tls-connection' ;
4850import { TlsTunnel } from '../tls/tls-tunnel' ;
51+ import { RawTunnel } from '../raw-tunnel' ;
4952import { HttpExchange } from '../http/http-exchange' ;
5053import { WebSocketStream } from '../websockets/websocket-stream' ;
5154import { RTCConnection } from '../webrtc/rtc-connection' ;
@@ -71,6 +74,9 @@ type EventTypesMap = {
7174 'tls-passthrough-opened' : InputTlsPassthrough ,
7275 'tls-passthrough-closed' : InputTlsPassthrough ,
7376 'client-error' : InputClientError ,
77+ 'raw-passthrough-opened' : InputRawPassthrough ,
78+ 'raw-passthrough-closed' : InputRawPassthrough ,
79+ 'raw-passthrough-data' : InputRawPassthroughData ,
7480 'rule-event' : InputRuleEvent
7581} & {
7682 // MockRTC:
@@ -91,6 +97,9 @@ const mockttpEventTypes = [
9197 'tls-passthrough-opened' ,
9298 'tls-passthrough-closed' ,
9399 'client-error' ,
100+ 'raw-passthrough-opened' ,
101+ 'raw-passthrough-closed' ,
102+ 'raw-passthrough-data' ,
94103 'rule-event'
95104] as const ;
96105
@@ -137,6 +146,8 @@ type OrphanableQueuedEvent<T extends
137146 | 'media-track-stats'
138147 | 'media-track-closed'
139148 | 'tls-passthrough-closed'
149+ | 'raw-passthrough-closed'
150+ | 'raw-passthrough-data'
140151> = { type : T , event : EventTypesMap [ T ] } ;
141152
142153const LARGE_QUEUE_BATCH_SIZE = 1033 ; // Off by 33 for a new ticking UI effect
@@ -255,6 +266,13 @@ export class EventsStore {
255266 case 'client-error' :
256267 return this . addClientError ( queuedEvent . event ) ;
257268
269+ case 'raw-passthrough-opened' :
270+ return this . addRawTunnel ( queuedEvent . event ) ;
271+ case 'raw-passthrough-closed' :
272+ return this . markRawTunnelClosed ( queuedEvent . event ) ;
273+ case 'raw-passthrough-data' :
274+ return this . addRawTunnelChunk ( queuedEvent . event ) ;
275+
258276 case 'rule-event' :
259277 return this . addRuleEvent ( queuedEvent . event ) ;
260278
@@ -453,6 +471,42 @@ export class EventsStore {
453471 tunnel . markClosed ( closeEvent ) ;
454472 }
455473
474+ @action
475+ private addRawTunnel ( openEvent : InputRawPassthrough ) {
476+ const tunnel = new RawTunnel ( openEvent ) ;
477+ this . eventsList . push ( tunnel ) ;
478+ }
479+
480+ @action
481+ private markRawTunnelClosed ( closeEvent : InputRawPassthrough ) {
482+ const tunnel = this . eventsList . getRawTunnelById ( closeEvent . id ) ;
483+
484+ if ( ! tunnel ) {
485+ // Handle this later, once the tunnel open event has arrived
486+ this . orphanedEvents [ closeEvent . id ] = {
487+ type : 'raw-passthrough-closed' , event : closeEvent
488+ } ;
489+ return ;
490+ }
491+
492+ tunnel . markClosed ( closeEvent ) ;
493+ }
494+
495+ @action
496+ private addRawTunnelChunk ( dataEvent : InputRawPassthroughData ) {
497+ const tunnel = this . eventsList . getRawTunnelById ( dataEvent . id ) ;
498+
499+ if ( ! tunnel ) {
500+ // Handle this later, once the tunnel open event has arrived
501+ this . orphanedEvents [ dataEvent . id ] = {
502+ type : 'raw-passthrough-data' , event : dataEvent
503+ } ;
504+ return ;
505+ }
506+
507+ tunnel . addChunk ( dataEvent ) ;
508+ }
509+
456510 @action
457511 private addFailedTlsRequest ( request : InputTlsFailure ) {
458512 if ( this . tlsFailures . some ( ( failure ) =>
0 commit comments