Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export const config = convict({
default: false,
arg: "allowDeletingFiles",
},
host: {
doc: "The host to bind to.",
format: "String",
nullable: true,
default: null,
arg: "host",
},
port: {
doc: "The port to bind to.",
format: "Number",
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export async function start() {
signal.emit(EventType.MessageSend, fileRemovalEventToMsg(fileEvent)),
);

console.log(`Server is ready, running on ${config.get("port")}!`);
const configHost = config.get("host");
console.log(`Server is ready, running on ${configHost != null ? configHost + ":" : ""}${config.get("port")}!`);

process.on("SIGINT", function () {
console.log("Shutting down!");
Expand Down
3 changes: 2 additions & 1 deletion src/networking/webSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { Message } from "../interfaces.js";
import { messageTracker } from "./messageTracker.js";

export function setupSocket(signaller: Signal) {
const wss = new WebSocketServer({ port: config.get("port") });
const configHost: string | null = config.get("host");
const wss = new WebSocketServer({ port: config.get("port"), host: configHost ?? undefined });

wss.on("connection", function connection(ws) {
function sendMessage(msg: Message) {
Expand Down