fix
This commit is contained in:
@@ -92,15 +92,16 @@ document.getElementById('serverForm').addEventListener('submit', async (e) => {
|
||||
`).join('')}
|
||||
`;
|
||||
|
||||
// Determine port for widget: use SRV-resolved port if available, else user-provided or default
|
||||
let widgetPort = port;
|
||||
if (result.srvPort) {
|
||||
widgetPort = result.srvPort;
|
||||
// Use SRV-resolved host and port if available, else user-provided or default
|
||||
if (host.includes("my-mc.link")){
|
||||
host = "my-mc.link"
|
||||
}
|
||||
let widgetHost = host;
|
||||
let widgetPort = result.srvPort || port;
|
||||
|
||||
// Show widget section and set widget code with static my-mc.link hostname
|
||||
// Show widget section and set widget code
|
||||
widgetSection.classList.remove('hidden');
|
||||
const widgetIframe = `<iframe src="https://my-mc.link/widget/${edition}/my-mc.link/${widgetPort}" width="280" height="145" frameborder="0" scrolling="no"></iframe>`;
|
||||
const widgetIframe = `<iframe src="https://my-mc.link/widget/${edition}/${widgetHost}/${widgetPort}" width="280" height="145" frameborder="0" scrolling="no"></iframe>`;
|
||||
widgetCode.textContent = widgetIframe;
|
||||
} else {
|
||||
statusContent.innerHTML = `
|
||||
|
@@ -1,7 +1,7 @@
|
||||
const express = require('express');
|
||||
const { promisify } = require('util');
|
||||
const { exec } = require('child_process');
|
||||
const dns = require('dns').promises; // Add DNS module for SRV lookup
|
||||
const dns = require('dns').promises;
|
||||
const rateLimit = require('express-rate-limit');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
@@ -174,7 +174,7 @@ async function checkConnectionStatus(hostname, port) {
|
||||
}
|
||||
const data = JSON.parse(stdout);
|
||||
if (isInfo) logger.info('Java server status check completed', { requestId, isOnline: true, resolvedHost: finalHost, resolvedPort: finalPort });
|
||||
return { isOnline: true, data };
|
||||
return { isOnline: true, data, srvHost: finalHost, srvPort: finalPort };
|
||||
} catch (error) {
|
||||
logger.error('Java server status check failed', { requestId, error: error.message });
|
||||
return { isOnline: false, error: error.message };
|
||||
@@ -205,7 +205,7 @@ async function checkGeyserStatus(hostname, port) {
|
||||
}
|
||||
const data = JSON.parse(stdout);
|
||||
if (isInfo) logger.info('Bedrock server status check completed', { requestId, isOnline: true, resolvedHost: finalHost, resolvedPort: finalPort });
|
||||
return { isOnline: true, data };
|
||||
return { isOnline: true, data, srvHost: finalHost, srvPort: finalPort };
|
||||
} catch (error) {
|
||||
logger.error('Bedrock server status check failed', { requestId, error: error.message });
|
||||
return { isOnline: false, error: error.message };
|
||||
@@ -433,11 +433,6 @@ app.get('/widget/:edition/:host/:port', (req, res) => {
|
||||
try {
|
||||
validateEdition(edition);
|
||||
validateHostname(host);
|
||||
// Uncomment this to only allow our system servers to have widgets.
|
||||
// if (host !== 'my-mc.link') {
|
||||
// logger.error('Unauthorized hostname', { host });
|
||||
// throw new Error('Hostname must be my-mc.link');
|
||||
// }
|
||||
validatePort(port);
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
res.send(widgetTemplate(edition, host, port));
|
||||
|
Reference in New Issue
Block a user