|
@@ -5,9 +5,8 @@ import * as uuid from "uuid/v4"
|
5
|
5
|
import { Socket } from "./RPCSocketServer"
|
6
|
6
|
|
7
|
7
|
type rpcType = 'hook' | 'unhook' | 'call'
|
8
|
|
-type visibility = 'public' | 'private'
|
9
|
|
-
|
10
|
8
|
export type Outcome = "Success" | "Error"
|
|
9
|
+export type Visibility = "127.0.0.1" | "0.0.0.0"
|
11
|
10
|
|
12
|
11
|
/* Responses */
|
13
|
12
|
export class Response{
|
|
@@ -56,7 +55,6 @@ export interface RPCExporter{
|
56
|
55
|
type baseRPC = {
|
57
|
56
|
type: rpcType
|
58
|
57
|
name: string
|
59
|
|
- visibility: visibility
|
60
|
58
|
}
|
61
|
59
|
|
62
|
60
|
type hookRPC = baseRPC & {
|
|
@@ -211,6 +209,7 @@ export class RPCSocketServer{
|
211
|
209
|
constructor(
|
212
|
210
|
private port:number,
|
213
|
211
|
private rpcExporters: RPCExporter[] = [],
|
|
212
|
+ private visibility: Visibility = "127.0.0.1",
|
214
|
213
|
private conf: RPCSocketConf = {
|
215
|
214
|
errorHandler: (socket:Socket) => (error:any) => { socket.destroy(); console.error(error) },
|
216
|
215
|
closeHandler: (socket:Socket) => () => { console.log("Socket closing") },
|
|
@@ -228,7 +227,7 @@ export class RPCSocketServer{
|
228
|
227
|
socket.on('close', this.conf.closeHandler(socket))
|
229
|
228
|
this.initApis(socket)
|
230
|
229
|
})
|
231
|
|
- this.wsServer.listen(this.port)
|
|
230
|
+ this.wsServer.listen(this.port, this.visibility)
|
232
|
231
|
}catch(e){
|
233
|
232
|
//@ts-ignore
|
234
|
233
|
this.errorHandler(undefined)("Unable to connect to socket")
|