fix(mikrotikApplyService, ServerModal): update default port for MikroTik connections to 80 and ensure proper number conversion for port input
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m41s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 2m41s
This commit is contained in:
@@ -15,7 +15,10 @@ const https = require('https');
|
|||||||
*/
|
*/
|
||||||
function createRosClient(opts) {
|
function createRosClient(opts) {
|
||||||
const { host, port = 80, user, password, secure = false } = opts;
|
const { host, port = 80, user, password, secure = false } = opts;
|
||||||
const useHttp = port === 80;
|
// Порт может прийти строкой из JSON — приводим к числу
|
||||||
|
const portNumber = Number(port) || 80;
|
||||||
|
// REST API по умолчанию висит на HTTP:80, HTTPS обычно на 443/8443
|
||||||
|
const useHttp = portNumber === 80;
|
||||||
const protocol = useHttp ? http : https;
|
const protocol = useHttp ? http : https;
|
||||||
|
|
||||||
const makeRequest = (method, urlPath, body = null) => {
|
const makeRequest = (method, urlPath, body = null) => {
|
||||||
@@ -32,7 +35,7 @@ function createRosClient(opts) {
|
|||||||
if (bodyStr) headers['Content-Length'] = Buffer.byteLength(bodyStr, 'utf8');
|
if (bodyStr) headers['Content-Length'] = Buffer.byteLength(bodyStr, 'utf8');
|
||||||
const options = {
|
const options = {
|
||||||
hostname: host,
|
hostname: host,
|
||||||
port,
|
port: portNumber,
|
||||||
path: pathStr,
|
path: pathStr,
|
||||||
method,
|
method,
|
||||||
headers,
|
headers,
|
||||||
|
|||||||
@@ -588,9 +588,9 @@ function ServerModal({ show, mode = 'add', server, onSave, onClose, error: exter
|
|||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
value={localServer.mikrotikPort || '8728'}
|
value={localServer.mikrotikPort || '80'}
|
||||||
onChange={(e) => handleFieldChange('mikrotikPort', e.target.value)}
|
onChange={(e) => handleFieldChange('mikrotikPort', e.target.value)}
|
||||||
placeholder="8728"
|
placeholder="80"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-3">
|
<div className="col-md-3">
|
||||||
@@ -627,7 +627,7 @@ function ServerModal({ show, mode = 'add', server, onSave, onClose, error: exter
|
|||||||
const payload = hasPassword
|
const payload = hasPassword
|
||||||
? {
|
? {
|
||||||
host: localServer.mikrotikHost || localServer.ip,
|
host: localServer.mikrotikHost || localServer.ip,
|
||||||
port: localServer.mikrotikPort || 8728,
|
port: localServer.mikrotikPort || 80,
|
||||||
user: localServer.mikrotikUser || 'admin',
|
user: localServer.mikrotikUser || 'admin',
|
||||||
password: localServer.mikrotikPassword,
|
password: localServer.mikrotikPassword,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user