Updates to refine the POST command processing for PTZ which allows more recent ReoLink cameras to function within Shinobi.

mitchross-coral-installer-update
Joshua Seltzer 2021-01-16 13:49:45 -05:00
parent 7a7794273a
commit be5b9e96ab
2 changed files with 26 additions and 14 deletions

View File

@ -217,13 +217,18 @@ module.exports = function(s,config,lang){
let stopURL = controlBaseUrl + monitorConfig.details[`control_url_${options.direction}_stop`]
let controlOptions = s.cameraControlOptionsFromUrl(stopURL,monitorConfig)
let requestOptions = {
url : stopURL,
method : controlOptions.method,
auth : {
user : controlOptions.username,
pass : controlOptions.password
url : controlBaseUrl + controlOptions.path,
method : controlOptions.method
}
if(controlOptions.username && controlOptions.password){
requestOptions.auth = {
user: controlOptions.username,
pass: controlOptions.password
}
}
if(controlOptions.postData){
requestOptions.form = controlOptions.postData
}
if(monitorConfig.details.control_digest_auth === '1'){
requestOptions.sendImmediately = true
}
@ -248,13 +253,18 @@ module.exports = function(s,config,lang){
let controlURL = controlBaseUrl + monitorConfig.details[`control_url_${options.direction}`]
let controlOptions = s.cameraControlOptionsFromUrl(controlURL,monitorConfig)
let requestOptions = {
url: controlURL,
method: controlOptions.method,
auth: {
url: controlBaseUrl + controlOptions.path,
method: controlOptions.method
}
if(controlOptions.username && controlOptions.password){
requestOptions.auth = {
user: controlOptions.username,
pass: controlOptions.password
}
}
if(controlOptions.postData){
requestOptions.form = controlOptions.postData
}
if(monitorConfig.details.control_digest_auth === '1'){
requestOptions.sendImmediately = true
}

View File

@ -450,12 +450,14 @@ module.exports = function(s,config,lang){
options = {
host: URLobject.hostname,
port: URLobject.port,
method: monitorConfig.details.control_url_method,
path: URLobject.pathname,
query: queryStringToObject(URLobject.query || ""),
};
if(URLobject.query){
options.path=options.path+'?'+URLobject.query
method: monitorConfig.details.control_url_method
}
const queryStringObjects = queryStringToObject(URLobject.query || "")
if (queryStringObjects && queryStringObjects.postData) {
options.postData = decodeURIComponent(queryStringObjects.postData)
options.path = URLobject.pathname + '?' + decodeURIComponent(URLobject.query.replace(/&postData(\=[^&]*)?(?=&|$)|^postData(\=[^&]*)?(&|$)/, ''))
} else {
options.path = URLobject.pathname
}
if(URLobject.username&&URLobject.password){
options.username = URLobject.username