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) {
|
||||
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 makeRequest = (method, urlPath, body = null) => {
|
||||
@@ -32,7 +35,7 @@ function createRosClient(opts) {
|
||||
if (bodyStr) headers['Content-Length'] = Buffer.byteLength(bodyStr, 'utf8');
|
||||
const options = {
|
||||
hostname: host,
|
||||
port,
|
||||
port: portNumber,
|
||||
path: pathStr,
|
||||
method,
|
||||
headers,
|
||||
|
||||
@@ -588,9 +588,9 @@ function ServerModal({ show, mode = 'add', server, onSave, onClose, error: exter
|
||||
<input
|
||||
type="number"
|
||||
className="form-control form-control-sm"
|
||||
value={localServer.mikrotikPort || '8728'}
|
||||
value={localServer.mikrotikPort || '80'}
|
||||
onChange={(e) => handleFieldChange('mikrotikPort', e.target.value)}
|
||||
placeholder="8728"
|
||||
placeholder="80"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-md-3">
|
||||
@@ -627,7 +627,7 @@ function ServerModal({ show, mode = 'add', server, onSave, onClose, error: exter
|
||||
const payload = hasPassword
|
||||
? {
|
||||
host: localServer.mikrotikHost || localServer.ip,
|
||||
port: localServer.mikrotikPort || 8728,
|
||||
port: localServer.mikrotikPort || 80,
|
||||
user: localServer.mikrotikUser || 'admin',
|
||||
password: localServer.mikrotikPassword,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user