stuff
This commit is contained in:
Vendored
+3
-1
@@ -2,6 +2,7 @@ import { Socket } from "./RPCSocketServer";
|
||||
declare type rpcType = 'hook' | 'unhook' | 'call';
|
||||
declare type visibility = 'public' | 'private';
|
||||
export declare type Outcome = "Success" | "Error";
|
||||
export declare type Visibility = "127.0.0.1" | "0.0.0.0";
|
||||
export declare class Response {
|
||||
message?: string | undefined;
|
||||
constructor(message?: string | undefined);
|
||||
@@ -86,10 +87,11 @@ export declare type RPCSocketConf = {
|
||||
export declare class RPCSocketServer {
|
||||
private port;
|
||||
private rpcExporters;
|
||||
private visibility;
|
||||
private conf;
|
||||
private io;
|
||||
private wsServer;
|
||||
constructor(port: number, rpcExporters?: RPCExporter[], conf?: RPCSocketConf);
|
||||
constructor(port: number, rpcExporters?: RPCExporter[], visibility?: Visibility, conf?: RPCSocketConf);
|
||||
private startWebsocket;
|
||||
protected initApis(socket: any): void;
|
||||
}
|
||||
|
||||
@@ -107,13 +107,14 @@ const extractArgs = (f) => {
|
||||
return ret;
|
||||
};
|
||||
class RPCSocketServer {
|
||||
constructor(port, rpcExporters = [], conf = {
|
||||
constructor(port, rpcExporters = [], visibility = "127.0.0.1", conf = {
|
||||
errorHandler: (socket) => (error) => { socket.destroy(); console.error(error); },
|
||||
closeHandler: (socket) => () => { console.log("Socket closing"); },
|
||||
connectionHandler: (socket) => { console.log("New websocket connection in port " + socket.port); }
|
||||
}) {
|
||||
this.port = port;
|
||||
this.rpcExporters = rpcExporters;
|
||||
this.visibility = visibility;
|
||||
this.conf = conf;
|
||||
this.io = bsock.createServer();
|
||||
this.wsServer = http.createServer();
|
||||
@@ -127,7 +128,7 @@ class RPCSocketServer {
|
||||
socket.on('close', this.conf.closeHandler(socket));
|
||||
this.initApis(socket);
|
||||
});
|
||||
this.wsServer.listen(this.port);
|
||||
this.wsServer.listen(this.port, this.visibility);
|
||||
}
|
||||
catch (e) {
|
||||
//@ts-ignore
|
||||
|
||||
Reference in New Issue
Block a user