mirror of
https://github.com/djhackersdev/minime.git
synced 2026-03-21 17:54:13 -05:00
Make hostname configurable
This commit is contained in:
parent
443c327680
commit
f224e466c5
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@ bin/
|
|||
node_modules/
|
||||
pki/
|
||||
state/
|
||||
hostname.txt
|
||||
|
|
|
|||
25
src/hostname.ts
Normal file
25
src/hostname.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { existsSync, readFileSync } from "fs";
|
||||
import * as os from "os";
|
||||
|
||||
const path = "./hostname.txt";
|
||||
let myHostname: string;
|
||||
|
||||
if (!existsSync(path)) {
|
||||
const osHostname = os.hostname();
|
||||
|
||||
console.log(
|
||||
`Hostname: ${path} does not exist, sending OS hostname "${osHostname}" to clients. This may be unreliable!`
|
||||
);
|
||||
|
||||
myHostname = osHostname;
|
||||
} else {
|
||||
myHostname = readFileSync(path, { encoding: "ascii" }).trim();
|
||||
|
||||
console.log(
|
||||
`Hostname: Sending configured hostname "${myHostname}" to clients`
|
||||
);
|
||||
}
|
||||
|
||||
export function hostname(): string {
|
||||
return myHostname;
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
import { hostname } from "os";
|
||||
|
||||
import { LoadServerListRequest } from "../request/loadServerList";
|
||||
import { LoadServerListResponse } from "../response/loadServerList";
|
||||
import { World } from "../world";
|
||||
import { hostname } from "../../hostname";
|
||||
|
||||
export function loadServerList(
|
||||
w: World,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ import express = require("express");
|
|||
import read = require("raw-body");
|
||||
|
||||
import { unzipSync } from "zlib";
|
||||
import { hostname } from "os";
|
||||
|
||||
import { hostname } from "./hostname";
|
||||
|
||||
const myHost = hostname();
|
||||
const uris = new Map<string, string>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user