1
0
Fork 0
mirror of https://gitlab.com/Shinobi-Systems/ShinobiCE.git synced 2025-03-09 15:40:15 +00:00

Solar Plexus

- New Plugin structure with pluginBase.js
- New plugins : Object Detection with YoloV3 and Face Detection with Dlib
- Fix 2-Factor Authentication
This commit is contained in:
Moe 2018-11-17 10:45:40 -08:00
parent e0f7c135af
commit 24de55e45a
22 changed files with 1268 additions and 899 deletions

View file

@ -53,7 +53,11 @@ module.exports = function(s,config){
var regions = s.createPamDiffRegionArray(regionJson,globalColorThreshold,globalSensitivity,fullFrame)
s.group[e.ke].mon[e.id].pamDiff = new PamDiff({grayscale: 'luminosity', regions : regions.forPam});
s.group[e.ke].mon[e.id].pamDiff = new PamDiff({
grayscale: 'luminosity',
regions : regions.forPam,
drawMatrix : e.details.detector_show_matrix
});
s.group[e.ke].mon[e.id].p2p = new P2P();
var sendTrigger = function(trigger){
var detectorObject = {

View file

@ -44,6 +44,7 @@ class PamDiff extends Transform {
this.difference = PamDiff._parseOptions('difference', options);//global option, can be overridden per region
this.percent = PamDiff._parseOptions('percent', options);//global option, can be overridden per region
this.regions = PamDiff._parseOptions('regions', options);//can be no regions or a single region or multiple regions. if no regions, all pixels will be compared.
this.drawMatrix = PamDiff._parseOptions('drawMatrix', options);//can be no regions or a single region or multiple regions. if no regions, all pixels will be compared.
this.callback = callback;//callback function to be called when pixel difference is detected
this._parseChunk = this._parseFirstChunk;//first parsing will be reading settings and configuring internal pixel reading
}
@ -331,7 +332,7 @@ class PamDiff extends Transform {
* @param chunk
* @private
*/
_grayScalePixelDiff(chunk) {
_grayScalePixelDiffWithMatrices(chunk) {
this._newPix = chunk.pixels;
for (let j = 0; j < this._regionsLength; j++) {
this._regions[j].topLeft = {
@ -430,6 +431,71 @@ class PamDiff extends Transform {
this._oldPix = this._newPix;
}
/**
*
* @param chunk
* @private
*/
_grayScalePixelDiff(chunk) {
this._newPix = chunk.pixels;
for (let y = 0, i = 0; y < this._height; y++) {
for (let x = 0; x < this._width; x++, i++) {
if (this._oldPix[i] !== this._newPix[i]) {
const diff = Math.abs(this._oldPix[i] - this._newPix[i]);
if (this._regions && diff >= this._minDiff) {
for (let j = 0; j < this._regionsLength; j++) {
if (this._pointsInPolygons[j][i] && diff >= this._regions[j].difference) {
this._regions[j].diffs++;
}
}
} else {
if (diff >= this._difference) {
this._diffs++;
}
}
}
}
}
if (this._regions) {
const regionDiffArray = [];
for (let i = 0; i < this._regionsLength; i++) {
const percent = Math.floor(100 * this._regions[i].diffs / this._regions[i].pointsLength);
if (percent >= this._regions[i].percent) {
regionDiffArray.push({name: this._regions[i].name, percent: percent});
}
this._regions[i].diffs = 0;
}
if (regionDiffArray.length > 0) {
const data = {trigger: regionDiffArray, pam: chunk.pam};
if (this._callback) {
this._callback(data);
}
if (this._readableState.pipesCount > 0) {
this.push(data);
}
if (this.listenerCount('diff') > 0) {
this.emit('diff', data);
}
}
} else {
const percent = Math.floor(100 * this._diffs / this._length);
if (percent >= this._percent) {
const data = {trigger: [{name: 'percent', percent: percent}], pam: chunk.pam};
if (this._callback) {
this._callback(data);
}
if (this._readableState.pipesCount > 0) {
this.push(data);
}
if (this.listenerCount('diff') > 0) {
this.emit('diff', data);
}
}
this._diffs = 0;
}
this._oldPix = this._newPix;
}
/**
*
* @param chunk
@ -576,7 +642,11 @@ class PamDiff extends Transform {
this._parseChunk = this._blackAndWhitePixelDiff;
break;
case 'grayscale' :
this._parseChunk = this._grayScalePixelDiff;
if(this.drawMatrix === "1"){
this._parseChunk = this._grayScalePixelDiffWithMatrices;
}else{
this._parseChunk = this._grayScalePixelDiff;
}
break;
case 'rgb' :
this._parseChunk = this._rgbPixelDiff;

View file

@ -59,14 +59,14 @@ module.exports = function(s,config,lang,io){
var tx;
//set "client" detector plugin event function
cn.on('ocv',function(d){
if(!cn.pluginEngine&&d.f==='init'){
if(config.pluginKeys[d.plug]===d.pluginKey){
if(!cn.pluginEngine && d.f === 'init'){
if(config.pluginKeys[d.plug] === d.pluginKey){
s.pluginInitiatorSuccess("client",d,cn)
}else{
s.pluginInitiatorFail("client",d,cn)
}
}else{
if(config.pluginKeys[d.plug]===d.pluginKey){
if(config.pluginKeys[d.plug] === d.pluginKey){
s.pluginEventController(d)
}else{
cn.disconnect()

View file

@ -364,6 +364,36 @@ module.exports = function(s,config,lang,app){
},res,req)
})
/**
* API : Administrator : Get Monitor State Presets List
*/
app.get([
config.webPaths.apiPrefix+':auth/monitorStates/:ke',
config.webPaths.adminApiPrefix+':auth/monitorStates/:ke'
],function (req,res){
s.auth(req.params,function(user){
var endData = {
ok : false
}
if(user.details.sub){
endData.msg = user.lang['Not Permitted']
s.closeJsonResponse(res,endData)
return
}
s.sqlQuery("SELECT * FROM Presets WHERE ke=? AND type=?",[req.params.ke,'monitorStates'],function(err,presets){
if(presets && presets[0]){
endData.ok = true
presets.forEach(function(preset){
preset.details = JSON.parse(preset.details)
})
endData.presets = presets
}else{
endData.msg = user.lang['State Configuration Not Found']
}
s.closeJsonResponse(res,endData)
})
})
})
/**
* API : Administrator : Change Group Preset. Currently affects Monitors only.
*/
app.all([

View file

@ -18,6 +18,7 @@ module.exports = function(s,config,lang,app,io){
s.renderPage = function(req,res,paths,passables,callback){
passables.window = {}
passables.originalURL = s.getOriginalUrl(req)
passables.config = config
res.render(paths,passables,callback)
}
//child node proxy check