Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f65ecd3f9 | ||
|
|
70ffd8b653 | ||
|
|
5bd7c99eea |
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ exports.parseAuthHeader = (authHeader) ->
|
|||||||
res['method'] = authHeader.slice(0, i)
|
res['method'] = authHeader.slice(0, i)
|
||||||
|
|
||||||
options = authHeader.slice(i + 1)
|
options = authHeader.slice(i + 1)
|
||||||
regex = /([a-z]+)="([a-zA-Z0-9\/\.@\-,=]+)"/g
|
regex = /([a-z]+)="([a-zA-Z0-9\/\.@\-,= ]+)"/g
|
||||||
while (r = regex.exec(options)) != null
|
while (r = regex.exec(options)) != null
|
||||||
res[r[1]] = r[2]
|
res[r[1]] = r[2]
|
||||||
|
|
||||||
|
|||||||
+21
-19
@@ -64,8 +64,7 @@ updateDevice = (currentRequest, actions, callback) ->
|
|||||||
return
|
return
|
||||||
|
|
||||||
now = new Date(Date.now())
|
now = new Date(Date.now())
|
||||||
updates = {}
|
update = {'$set' : {}, '$unset' : {}}
|
||||||
deletes = {}
|
|
||||||
|
|
||||||
if actions.parameterValues?
|
if actions.parameterValues?
|
||||||
for p in actions.parameterValues
|
for p in actions.parameterValues
|
||||||
@@ -74,36 +73,36 @@ updateDevice = (currentRequest, actions, callback) ->
|
|||||||
|
|
||||||
path = if common.endsWith(p[0], '.') then p[0] else "#{p[0]}."
|
path = if common.endsWith(p[0], '.') then p[0] else "#{p[0]}."
|
||||||
if v == origValue
|
if v == origValue
|
||||||
deletes["#{path}_orig"] = 1
|
update['$unset']["#{path}_orig"] = 1
|
||||||
else
|
else
|
||||||
updates["#{path}_orig"] = origValue
|
update['$set']["#{path}_orig"] = origValue
|
||||||
updates["#{path}_value"] = v
|
update['$set']["#{path}_value"] = v
|
||||||
updates["#{path}_timestamp"] = now
|
update['$set']["#{path}_timestamp"] = now
|
||||||
if p[2]?
|
if p[2]?
|
||||||
updates["#{path}_type"] = p[2]
|
update['$set']["#{path}_type"] = p[2]
|
||||||
else
|
else
|
||||||
deletes["#{path}_type"] = 1
|
update['$unset']["#{path}_type"] = 1
|
||||||
|
|
||||||
if actions.deletedObjects?
|
if actions.deletedObjects?
|
||||||
for p in actions.deletedObjects
|
for p in actions.deletedObjects
|
||||||
deletes[p] = 1
|
update['$unset'][p] = 1
|
||||||
|
|
||||||
if actions.instanceName?
|
if actions.instanceName?
|
||||||
for i in actions.instanceName
|
for i in actions.instanceName
|
||||||
updates["#{i[0]}._name"] = i[1]
|
update['$set']["#{i[0]}._name"] = i[1]
|
||||||
|
|
||||||
if actions.parameterNames?
|
if actions.parameterNames?
|
||||||
for p in actions.parameterNames
|
for p in actions.parameterNames
|
||||||
if OBJECT_REGEX.test(p[0])
|
if OBJECT_REGEX.test(p[0])
|
||||||
path = p[0]
|
path = p[0]
|
||||||
if INSTANCE_REGEX.test(p[0])
|
if INSTANCE_REGEX.test(p[0])
|
||||||
updates["#{path}_instance"] = true
|
update['$set']["#{path}_instance"] = true
|
||||||
else
|
else
|
||||||
updates["#{path}_object"] = true
|
update['$set']["#{path}_object"] = true
|
||||||
else
|
else
|
||||||
path = "#{p[0]}."
|
path = "#{p[0]}."
|
||||||
updates["#{path}_writable"] = p[1] if p[1]?
|
update['$set']["#{path}_writable"] = p[1] if p[1]?
|
||||||
updates["#{path}_timestamp"] = now
|
update['$set']["#{path}_timestamp"] = now
|
||||||
|
|
||||||
# Add parameter (sans any dot suffix) if has an alias
|
# Add parameter (sans any dot suffix) if has an alias
|
||||||
if (a = parameters.getAlias(pp = path.slice(0, -1)))?
|
if (a = parameters.getAlias(pp = path.slice(0, -1)))?
|
||||||
@@ -113,14 +112,17 @@ updateDevice = (currentRequest, actions, callback) ->
|
|||||||
if actions.customCommands?
|
if actions.customCommands?
|
||||||
for p in actions.customCommands
|
for p in actions.customCommands
|
||||||
commandName = p[0]
|
commandName = p[0]
|
||||||
updates["_customCommands.#{commandName}._value"] = p[1]
|
update['$set']["_customCommands.#{commandName}._value"] = p[1]
|
||||||
updates["_customCommands.#{commandName}._timestamp"] = now
|
update['$set']["_customCommands.#{commandName}._timestamp"] = now
|
||||||
|
|
||||||
if actions.set?
|
if actions.set?
|
||||||
common.extend(updates, actions.set)
|
common.extend(update['$set'], actions.set)
|
||||||
|
|
||||||
if Object.keys(updates).length > 0 or Object.keys(deletes).length > 0
|
for k of update
|
||||||
db.devicesCollection.update({'_id' : currentRequest.deviceId}, {'$set' : updates, '$unset' : deletes}, {}, (err, count) ->
|
delete update[k] if Object.keys(update[k]).length == 0
|
||||||
|
|
||||||
|
if Object.keys(update).length
|
||||||
|
db.devicesCollection.update({'_id' : currentRequest.deviceId}, update, {}, (err, count) ->
|
||||||
throw err if err
|
throw err if err
|
||||||
# Clear aliases cache if there's a new aliased parameter that has not been included in aliases cache
|
# Clear aliases cache if there's a new aliased parameter that has not been included in aliases cache
|
||||||
if newAliases?
|
if newAliases?
|
||||||
|
|||||||
+5
-1
@@ -28,7 +28,11 @@ exports.getDevicePreset = (deviceId, presets, objects, aliases, callback) ->
|
|||||||
# only fetch relevant params
|
# only fetch relevant params
|
||||||
projection = {_id : 1}
|
projection = {_id : 1}
|
||||||
for p in presets
|
for p in presets
|
||||||
p.precondition = query.expand(p.precondition, aliases)
|
if common.typeOf(p.precondition) is common.STRING_TYPE
|
||||||
|
p.precondition = query.expand(JSON.parse(p.precondition), aliases)
|
||||||
|
else
|
||||||
|
# Accept an object for backward compatiblity
|
||||||
|
p.precondition = query.expand(p.precondition ? {}, aliases)
|
||||||
mongoQuery.projection(p.precondition, projection)
|
mongoQuery.projection(p.precondition, projection)
|
||||||
|
|
||||||
for c in p.configurations
|
for c in p.configurations
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "genieacs",
|
"name": "genieacs",
|
||||||
"version": "0.9.8",
|
"version": "0.9.9",
|
||||||
"description": "A blazing fast TR-069 auto configuration server (ACS) built with Node.js, Redis, and MongoDB",
|
"description": "A blazing fast TR-069 auto configuration server (ACS) built with Node.js, Redis, and MongoDB",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -20,10 +20,10 @@
|
|||||||
"bin": "bin"
|
"bin": "bin"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"libxmljs": "~0.8.1",
|
"libxmljs": "~0.9.0",
|
||||||
"redis": "~0.10.0",
|
"redis": "~0.10.1",
|
||||||
"hiredis": "~0.1.15",
|
"hiredis": "~0.1.16",
|
||||||
"mongodb": "~1.3.23"
|
"mongodb": "~1.4.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"coffee-script": "~1.7.1"
|
"coffee-script": "~1.7.1"
|
||||||
|
|||||||
Reference in new issue
Block a user