feat(ServerModal, serverUtils): implement conditional tunnel selection based on server type; add needsTunnel utility function for improved server configuration
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m41s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m41s
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
makeGateway,
|
makeGateway,
|
||||||
normalizeGateways,
|
normalizeGateways,
|
||||||
needsGateways as NEEDS_GATEWAYS,
|
needsGateways as NEEDS_GATEWAYS,
|
||||||
|
needsTunnel as NEEDS_TUNNEL,
|
||||||
SERVER_TYPE_OPTIONS,
|
SERVER_TYPE_OPTIONS,
|
||||||
TUNNEL_TYPES
|
TUNNEL_TYPES
|
||||||
} from '../../utils/serverUtils.js';
|
} from '../../utils/serverUtils.js';
|
||||||
@@ -417,7 +418,7 @@ function ServerModal({ show, mode = 'add', server, onSave, onClose, error: exter
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Тип сервера */}
|
{/* Тип сервера */}
|
||||||
<div className="col-md-6">
|
<div className={NEEDS_TUNNEL(localServer.type) ? "col-md-6" : "col-12"}>
|
||||||
<label className="form-label required">Тип сервера</label>
|
<label className="form-label required">Тип сервера</label>
|
||||||
<select
|
<select
|
||||||
className="form-select"
|
className="form-select"
|
||||||
@@ -433,20 +434,22 @@ function ServerModal({ show, mode = 'add', server, onSave, onClose, error: exter
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Тип туннеля */}
|
{/* Тип туннеля - только для типов, которым он нужен */}
|
||||||
<div className="col-md-6">
|
{NEEDS_TUNNEL(localServer.type) && (
|
||||||
<label className="form-label required">Тип туннеля</label>
|
<div className="col-md-6">
|
||||||
<select
|
<label className="form-label required">Тип туннеля</label>
|
||||||
className="form-select"
|
<select
|
||||||
value={localServer.tunnel || 'GRE'}
|
className="form-select"
|
||||||
onChange={(e) => handleFieldChange('tunnel', e.target.value)}
|
value={localServer.tunnel || 'GRE'}
|
||||||
required
|
onChange={(e) => handleFieldChange('tunnel', e.target.value)}
|
||||||
>
|
required
|
||||||
{TUNNEL_TYPES.map((t) => (
|
>
|
||||||
<option key={t} value={t}>{t}</option>
|
{TUNNEL_TYPES.map((t) => (
|
||||||
))}
|
<option key={t} value={t}>{t}</option>
|
||||||
</select>
|
))}
|
||||||
</div>
|
</select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Основной шлюз (текстовое поле для совместимости) */}
|
{/* Основной шлюз (текстовое поле для совместимости) */}
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
|
|||||||
@@ -92,8 +92,20 @@ export const SERVER_TYPE_OPTIONS = [
|
|||||||
{ value: 'jumphost', label: 'Jumphost' },
|
{ value: 'jumphost', label: 'Jumphost' },
|
||||||
{ value: 'exit', label: 'Выходная нода' },
|
{ value: 'exit', label: 'Выходная нода' },
|
||||||
{ value: 'bgp', label: 'BGP роутер' },
|
{ value: 'bgp', label: 'BGP роутер' },
|
||||||
|
{ value: 'dns', label: 'DNS сервер' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Проверяет, нужен ли туннель для данного типа сервера
|
||||||
|
* @param {string} type - Тип сервера
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export const needsTunnel = (type) => {
|
||||||
|
// BGP и DNS серверам туннель не нужен
|
||||||
|
const noTunnelTypes = ['bgp', 'dns'];
|
||||||
|
return !noTunnelTypes.includes(String(type || '').toLowerCase());
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Типы туннелей
|
* Типы туннелей
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user