47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import express from "express";
|
|
import * as os from "os";
|
|
import config from "../config";
|
|
import { NetworkInterfaceDetails } from "@/types/types";
|
|
|
|
export default async function AdminPanel() {
|
|
// 無効
|
|
if (!config.admin.panel.isEnabled) {
|
|
return;
|
|
}
|
|
|
|
// 管理パネル
|
|
const app = express();
|
|
const port = config.admin.panel.port;
|
|
|
|
// ルーティング
|
|
app.use((await import("./route/ueuse")).default);
|
|
app.use((await import("./route/command")).default);
|
|
app.use((await import("./route/weather")).default);
|
|
app.use((await import("./route/api")).default);
|
|
app.use((await import("./route/token")).default);
|
|
app.use((await import("./route/debug")).default);
|
|
app.use(express.static("panel/public"));
|
|
|
|
app.listen(port, () => {
|
|
console.log(`http://${LocalIP()}:${port} で管理パネルを起動しました`);
|
|
});
|
|
}
|
|
|
|
function LocalIP() {
|
|
const interfaces = os.networkInterfaces();
|
|
|
|
for (const name in interfaces) {
|
|
const iface: any = interfaces[name];
|
|
|
|
for (const i of iface) {
|
|
const details: NetworkInterfaceDetails = i;
|
|
|
|
if (details.family === 'IPv4' && details.internal !== true) {
|
|
return details.address;
|
|
}
|
|
}
|
|
}
|
|
|
|
return "localhost";
|
|
}
|