refactor(MikrotikConfig): extend MikroTik credentials handling to support home routers and update related error messages for improved clarity
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m40s

This commit is contained in:
2026-02-16 23:04:43 +07:00
parent 7af6719f4b
commit a3023daac9
3 changed files with 11 additions and 10 deletions
+4 -4
View File
@@ -72,9 +72,9 @@ async function loadPasswordMap() {
return map;
}
/** Получить MikroTik credentials из сервера (jumphost) */
/** Получить MikroTik credentials из сервера (jumphost или home — входной роутер) */
function getMikrotikCredentials(server) {
if (!server || server.type !== 'jumphost') return null;
if (!server || (server.type !== 'jumphost' && server.type !== 'home')) return null;
const host = server.mikrotikHost || server.ip || server.dns;
if (!host) return null;
const port = server.mikrotikPort;
@@ -182,8 +182,8 @@ async function testMikrotikConnection(req, res) {
if (serverId) {
const servers = await readServersFromS3();
const server = servers.find(s => (s.id || s.dns || s.ip) === serverId);
if (!server || server.type !== 'jumphost') {
return sendError(res, 400, 'Jumphost server not found', 'E_NOT_FOUND');
if (!server || (server.type !== 'jumphost' && server.type !== 'home')) {
return sendError(res, 400, 'Сервер (jumphost или входной роутер) не найден', 'E_NOT_FOUND');
}
creds = getMikrotikCredentials(server);
if (!creds) {
+5 -4
View File
@@ -1,6 +1,6 @@
/**
* Кастомные роуты для серверов с поддержкой зашифрованных MikroTik учётных данных
* Для jumphost: mikrotikHost, mikrotikPort, mikrotikUser, encryptedMikrotikPassword
* Для jumphost и home (входной роутер): mikrotikHost, mikrotikPort, mikrotikUser, encryptedMikrotikPassword
*/
const { GetObjectCommand, PutObjectCommand, HeadObjectCommand } = require('@aws-sdk/client-s3');
@@ -80,10 +80,11 @@ async function getServers(req, res) {
const servers = await readServersFromS3();
const sanitized = servers.map(s => {
const out = { ...s };
if (s.type === 'jumphost' && out.encryptedMikrotikPassword) {
const hasMikrotikApi = s.type === 'jumphost' || s.type === 'home';
if (hasMikrotikApi && out.encryptedMikrotikPassword) {
out.hasMikrotikPassword = true;
delete out.encryptedMikrotikPassword;
} else if (s.type === 'jumphost') {
} else if (hasMikrotikApi) {
out.hasMikrotikPassword = false;
}
return out;
@@ -121,7 +122,7 @@ async function postServers(req, res) {
const toSave = items.map((srv) => {
const current = findCurrent(srv);
if (srv.type === 'jumphost') {
if (srv.type === 'jumphost' || srv.type === 'home') {
const out = { ...srv };
if (srv.mikrotikPassword !== undefined && srv.mikrotikPassword !== null && String(srv.mikrotikPassword).trim() !== '') {
try {
@@ -565,8 +565,8 @@ function ServerModal({ show, mode = 'add', server, onSave, onClose, error: exter
</div>
)}
{/* MikroTik — только для jumphost */}
{localServer.type === 'jumphost' && (
{/* MikroTik RouterOS API — для jumphost и домашних (входных) роутеров */}
{(localServer.type === 'jumphost' || localServer.type === 'home') && (
<div className="mt-4 pt-3 border-top">
<label className="form-label d-flex align-items-center gap-2">
<IconRouter size={18} />