From 872bc207bc0adffc9ae5d393ac1493f4c481a654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Felipe=20Torres=20Garfe?= Date: Tue, 11 Aug 2020 15:00:33 -0400 Subject: [PATCH] bug and its related dependencies, solved --- libs/control/ptz.js | 25 ++++++++++++++----------- libs/webServerPaths.js | 6 ++++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/libs/control/ptz.js b/libs/control/ptz.js index 5b37d33c..580f312a 100644 --- a/libs/control/ptz.js +++ b/libs/control/ptz.js @@ -1,5 +1,6 @@ var os = require('os'); var exec = require('child_process').exec; +var request = require('request') module.exports = function(s,config,lang,app,io){ const moveLock = {} const startMove = async function(options,callback){ @@ -195,14 +196,14 @@ module.exports = function(s,config,lang,app,io){ }else{ const controlUrlStopTimeout = parseInt(monitorConfig.details.control_url_stop_timeout) || 1000 var stopCamera = function(){ - var stopURL = controlBaseUrl + monitorConfig.details[`control_url_${options.direction}_stop`] - var options = s.cameraControlOptionsFromUrl(stopURL,monitorConfig) - var requestOptions = { + let stopURL = controlBaseUrl + monitorConfig.details[`control_url_${options.direction}_stop`] + let controlOptions = s.cameraControlOptionsFromUrl(stopURL,monitorConfig) + let requestOptions = { url : stopURL, - method : options.method, + method : controlOptions.method, auth : { - user : options.username, - pass : options.password + user : controlOptions.username, + pass : controlOptions.password } } if(monitorConfig.details.control_digest_auth === '1'){ @@ -221,12 +222,14 @@ module.exports = function(s,config,lang,app,io){ if(options.direction === 'stopMove'){ stopCamera() }else{ - var requestOptions = { + let controlURL = controlBaseUrl + monitorConfig.details[`control_url_${options.direction}`] + let controlOptions = s.cameraControlOptionsFromUrl(controlURL,monitorConfig) + let requestOptions = { url: controlURL, - method: controlURLOptions.method, + method: controlOptions.method, auth: { - user: controlURLOptions.username, - pass: controlURLOptions.password + user: controlOptions.username, + pass: controlOptions.password } } if(monitorConfig.details.control_digest_auth === '1'){ @@ -257,4 +260,4 @@ module.exports = function(s,config,lang,app,io){ startMove: startMove, stopMove: stopMove, } -} +} \ No newline at end of file diff --git a/libs/webServerPaths.js b/libs/webServerPaths.js index 9646791b..938fbaef 100644 --- a/libs/webServerPaths.js +++ b/libs/webServerPaths.js @@ -1719,6 +1719,12 @@ module.exports = function(s,config,lang,app,io){ res.setHeader('Content-Type', 'application/json'); s.auth(req.params,function(user){ s.cameraControl(req.params,function(msg){ + let d = { + id: req.params.id, + ke: req.params.ke, + direction: req.params.direction, + details: s.parseJSON(req.query.data) + } s.userLog(d,msg) res.end(s.prettyPrint(msg)) });