Skip to content

Commit

Permalink
Merge pull request firewalla#732 from MelvinTo/beta_6_0
Browse files Browse the repository at this point in the history
Add two bug fixes
  • Loading branch information
MelvinTo authored Feb 6, 2018
2 parents 0776f62 + a19179d commit be27f52
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
11 changes: 8 additions & 3 deletions alarm/AlarmManager2.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ module.exports = class {
if(needArchive) {
await (this.archiveAlarm(alarm.aid))
} else {
await (this.removeFromActiveQueueAsync(alarm.alarmID))
await (this.removeFromActiveQueueAsync(alarm.aid))
}

log.info(`Alarm ${alarm.aid} is blocked successfully`)
Expand Down Expand Up @@ -697,7 +697,7 @@ module.exports = class {
})()
}

allowAlarmByException(alarm, exception, info) {
allowAlarmByException(alarm, exception, info, needArchive) {
return async(() => {
if(!alarm || !exception) {
return
Expand All @@ -713,8 +713,13 @@ module.exports = class {
}

await (this.updateAlarm(alarm))
await (this.archiveAlarm(alarm.aid))

if(needArchive) {
await (this.archiveAlarm(alarm.aid))
} else {
await (this.removeFromActiveQueueAsync(alarm.aid))
}

log.info(`Alarm ${alarm.aid} is allowed successfully`)
})()
}
Expand Down
1 change: 1 addition & 0 deletions firewalla.package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@
"child-process-promise": "*"
}
}

35 changes: 30 additions & 5 deletions net2/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,43 @@ function getConfig() {

function isFeatureOn_Static(featureName) {
let config = getConfig()
return config.userFeatures && config.userFeatures[featureName]
if(config.userFeatures && featureName in config.userFeatures) {
if(config.userFeatures[featureName]) {
return true
} else {
return false
}
} else {
return undefined
}
}

// undefined: feature not exists
// true: feature enabled
// false: feature disabled
function isFeatureOn_Dynamic(featureName) {
return dynamicConfigs && dynamicConfigs[featureName] && dynamicConfigs[featureName] === '1'
if(dynamicConfigs && featureName in dynamicConfigs) {
if(dynamicConfigs[featureName] === '1' ) {
return true
} else {
return false
}
} else {
return undefined
}
}

function isFeatureOn(featureName) {
if(isFeatureOn_Static(featureName) || isFeatureOn_Dynamic(featureName)) {
return true
const dynamicFlag = isFeatureOn_Dynamic(featureName)
if(dynamicFlag !== undefined) {
return dynamicFlag
}

const staticFlag = isFeatureOn_Static(featureName)
if(staticFlag !== undefined) {
return staticFlag
} else {
return false
return false // default disabled
}
}

Expand Down

0 comments on commit be27f52

Please sign in to comment.