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
+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 {