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,
|
||||
normalizeGateways,
|
||||
needsGateways as NEEDS_GATEWAYS,
|
||||
needsTunnel as NEEDS_TUNNEL,
|
||||
SERVER_TYPE_OPTIONS,
|
||||
TUNNEL_TYPES
|
||||
} 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>
|
||||
<select
|
||||
className="form-select"
|
||||
@@ -433,20 +434,22 @@ function ServerModal({ show, mode = 'add', server, onSave, onClose, error: exter
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Тип туннеля */}
|
||||
<div className="col-md-6">
|
||||
<label className="form-label required">Тип туннеля</label>
|
||||
<select
|
||||
className="form-select"
|
||||
value={localServer.tunnel || 'GRE'}
|
||||
onChange={(e) => handleFieldChange('tunnel', e.target.value)}
|
||||
required
|
||||
>
|
||||
{TUNNEL_TYPES.map((t) => (
|
||||
<option key={t} value={t}>{t}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
{/* Тип туннеля - только для типов, которым он нужен */}
|
||||
{NEEDS_TUNNEL(localServer.type) && (
|
||||
<div className="col-md-6">
|
||||
<label className="form-label required">Тип туннеля</label>
|
||||
<select
|
||||
className="form-select"
|
||||
value={localServer.tunnel || 'GRE'}
|
||||
onChange={(e) => handleFieldChange('tunnel', e.target.value)}
|
||||
required
|
||||
>
|
||||
{TUNNEL_TYPES.map((t) => (
|
||||
<option key={t} value={t}>{t}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Основной шлюз (текстовое поле для совместимости) */}
|
||||
<div className="col-12">
|
||||
|
||||
@@ -92,8 +92,20 @@ export const SERVER_TYPE_OPTIONS = [
|
||||
{ value: 'jumphost', label: 'Jumphost' },
|
||||
{ value: 'exit', label: 'Выходная нода' },
|
||||
{ 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