V0.1.1 Added env var and enabled websocket
This commit is contained in:
parent
b02370a69a
commit
8a75d7c0e7
@ -1,8 +1,12 @@
|
||||
import { SuricataSocketStream } from "./socket-server/server.ts";
|
||||
|
||||
// UGLY: take them from
|
||||
// UGLY: take them from
|
||||
const UNIXPATH = "/var/lib/suricata/eve.sock"
|
||||
const WEB_SOCKET_URI = ""
|
||||
const WEB_SOCKET_URI = Deno.env.get("WEBSOCKET_RELAY")
|
||||
|
||||
if (!WEB_SOCKET_URI) {
|
||||
throw Error("There's no value associated with WEBSOCKET_RELAY environment variable")
|
||||
}
|
||||
|
||||
const app = new SuricataSocketStream(
|
||||
UNIXPATH,
|
||||
|
||||
@ -17,7 +17,7 @@ export class SuricataSocketStream {
|
||||
});
|
||||
|
||||
this.webSocket = new WebSocket(webSocketURI);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async serve() {
|
||||
@ -31,7 +31,7 @@ export class SuricataSocketStream {
|
||||
const jsonParser = new JSON_Chunker()
|
||||
|
||||
do {
|
||||
|
||||
|
||||
let bytesRead: number | null = 0;
|
||||
const chunk: Uint8Array = new Uint8Array(this.maxBlobSize);
|
||||
|
||||
@ -48,28 +48,17 @@ export class SuricataSocketStream {
|
||||
|
||||
while (jsonParser.messageReady) {
|
||||
this.messageProcess(jsonParser.message!)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// UGLY: change this to a more flexible method
|
||||
private messageProcess(msg: string | Uint8Array) {
|
||||
// this.webSocket.send(msg);
|
||||
console.log(
|
||||
`
|
||||
Debug, found this message:
|
||||
|
||||
${msg}
|
||||
|
||||
END OF MESSAGE
|
||||
|
||||
|
||||
`
|
||||
)
|
||||
this.webSocket.send(msg);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user