From 0067905feb4f4ab4710590cc4d763dac0d52b3cb Mon Sep 17 00:00:00 2001 From: Ruthenic Date: Tue, 8 Nov 2022 15:19:53 -0500 Subject: [PATCH] add ability to specify hostname to bind on --- config.template.json | 1 + src/bot.ts | 2 +- src/socket.ts | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config.template.json b/config.template.json index e70b090..3f0dee0 100644 --- a/config.template.json +++ b/config.template.json @@ -14,6 +14,7 @@ "websocket": { "enabled": true, "debug": false, + "hostname": "localhost", "port": 3012 }, "discord": { diff --git a/src/bot.ts b/src/bot.ts index fa86baf..41b660f 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -15,7 +15,7 @@ export class GoofyAhhException extends Error { } await initDB(); -if (config.websocket.enabled) initSocket(config.websocket.port); +if (config.websocket.enabled) initSocket(config.websocket.hostname, config.websocket.port); initOnMessage(); initLocalCommands(); initCommands(); diff --git a/src/socket.ts b/src/socket.ts index 0001962..0344fe7 100644 --- a/src/socket.ts +++ b/src/socket.ts @@ -1,4 +1,4 @@ -import { serve } from "https://deno.land/std@0.160.0/http/server.ts"; +import { serve } from "https://deno.land/std@0.162.0/http/server.ts"; import config from "./config.ts"; interface SockClient { @@ -59,8 +59,8 @@ function reqHandler(req: Request) { return response; } -export default function initialize(port: number) { - serve(reqHandler, { port: port }); +export default function initialize(hostname: string, port: number) { + serve(reqHandler, { hostname: hostname, port: port }); } export function sendSocketMessage(