@@ -21,14 +21,14 @@ export class AppDebugSocketProxyFactory
2121 private $lockService : ILockService ,
2222 private $options : IOptions ,
2323 private $tempService : ITempService ,
24- private $net : INet
24+ private $net : INet ,
2525 ) {
2626 super ( ) ;
2727 }
2828
2929 public getTCPSocketProxy (
3030 deviceIdentifier : string ,
31- appId : string
31+ appId : string ,
3232 ) : net . Server {
3333 return this . deviceTcpServers [ `${ deviceIdentifier } -${ appId } ` ] ;
3434 }
@@ -37,18 +37,18 @@ export class AppDebugSocketProxyFactory
3737 device : Mobile . IiOSDevice ,
3838 appId : string ,
3939 projectName : string ,
40- projectDir : string
40+ projectDir : string ,
4141 ) : Promise < net . Server > {
4242 const cacheKey = `${ device . deviceInfo . identifier } -${ appId } ` ;
4343 const existingServer = this . deviceTcpServers [ cacheKey ] ;
4444 if ( existingServer ) {
4545 this . $errors . fail (
46- `TCP socket proxy is already running for device '${ device . deviceInfo . identifier } ' and app '${ appId } '`
46+ `TCP socket proxy is already running for device '${ device . deviceInfo . identifier } ' and app '${ appId } '` ,
4747 ) ;
4848 }
4949
5050 this . $logger . info (
51- "\nSetting up proxy...\nPress Ctrl + C to terminate, or disconnect.\n"
51+ "\nSetting up proxy...\nPress Ctrl + C to terminate, or disconnect.\n" ,
5252 ) ;
5353
5454 const server = net . createServer ( {
@@ -69,7 +69,7 @@ export class AppDebugSocketProxyFactory
6969 const appDebugSocket = await device . getDebugSocket (
7070 appId ,
7171 projectName ,
72- projectDir
72+ projectDir ,
7373 ) ;
7474 this . $logger . info ( "Backend socket created." ) ;
7575
@@ -112,7 +112,7 @@ export class AppDebugSocketProxyFactory
112112 device : Mobile . IiOSDevice ,
113113 appId : string ,
114114 projectName : string ,
115- projectDir : string
115+ projectDir : string ,
116116 ) : Promise < ws . Server > {
117117 const existingWebProxy =
118118 this . deviceWebServers [ `${ device . deviceInfo . identifier } -${ appId } ` ] ;
@@ -130,22 +130,22 @@ export class AppDebugSocketProxyFactory
130130 device : Mobile . IiOSDevice ,
131131 appId : string ,
132132 projectName : string ,
133- projectDir : string
133+ projectDir : string ,
134134 ) : Promise < ws . Server > {
135135 let clientConnectionLockRelease : ( ) => void ;
136136 const cacheKey = `${ device . deviceInfo . identifier } -${ appId } ` ;
137137 const existingServer = this . deviceWebServers [ cacheKey ] ;
138138 if ( existingServer ) {
139139 this . $errors . fail (
140- `Web socket proxy is already running for device '${ device . deviceInfo . identifier } ' and app '${ appId } '`
140+ `Web socket proxy is already running for device '${ device . deviceInfo . identifier } ' and app '${ appId } '` ,
141141 ) ;
142142 }
143143
144144 // NOTE: We will try to provide command line options to select ports, at least on the localhost.
145145 const localPort = await this . $net . getAvailablePortInRange ( 41000 ) ;
146146
147147 this . $logger . info (
148- "\nSetting up debugger proxy...\nPress Ctrl + C to terminate, or disconnect.\n"
148+ "\nSetting up debugger proxy...\nPress Ctrl + C to terminate, or disconnect.\n" ,
149149 ) ;
150150
151151 // NB: When the inspector frontend connects we might not have connected to the inspector backend yet.
@@ -156,17 +156,18 @@ export class AppDebugSocketProxyFactory
156156 let currentAppSocket : net . Socket = null ;
157157 let currentWebSocket : ws = null ;
158158 const server = new ws . Server ( < any > {
159+ host : "127.0.0.1" ,
159160 port : localPort ,
160161 verifyClient : async (
161162 info : any ,
162- callback : ( res : boolean , code ?: number , message ?: string ) => void
163+ callback : ( res : boolean , code ?: number , message ?: string ) => void ,
163164 ) => {
164165 let acceptHandshake = true ;
165166 clientConnectionLockRelease = null ;
166167
167168 try {
168169 clientConnectionLockRelease = await this . $lockService . lock (
169- `debug-connection-${ device . deviceInfo . identifier } -${ appId } .lock`
170+ `debug-connection-${ device . deviceInfo . identifier } -${ appId } .lock` ,
170171 ) ;
171172
172173 this . $logger . info ( "Frontend client connected." ) ;
@@ -184,7 +185,7 @@ export class AppDebugSocketProxyFactory
184185 appDebugSocket = await device . getDebugSocket (
185186 appId ,
186187 projectName ,
187- projectDir
188+ projectDir ,
188189 ) ;
189190 currentAppSocket = appDebugSocket ;
190191 this . $logger . info ( "Backend socket created." ) ;
@@ -198,7 +199,7 @@ export class AppDebugSocketProxyFactory
198199 this . emit ( CONNECTION_ERROR_EVENT_NAME , err ) ;
199200 acceptHandshake = false ;
200201 this . $logger . warn (
201- `Cannot connect to device socket. The error message is '${ err . message } '.`
202+ `Cannot connect to device socket. The error message is '${ err . message } '.` ,
202203 ) ;
203204 }
204205
@@ -225,7 +226,7 @@ export class AppDebugSocketProxyFactory
225226 webSocket . send ( message ) ;
226227 } else {
227228 this . $logger . trace (
228- `Received message ${ message } , but unable to send it to webSocket as its state is: ${ webSocket . readyState } `
229+ `Received message ${ message } , but unable to send it to webSocket as its state is: ${ webSocket . readyState } ` ,
229230 ) ;
230231 }
231232 } ) ;
0 commit comments