Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c76d101b9 | ||
|
|
91f9a8f54b | ||
|
|
68b6a786bf | ||
|
|
9fde3ad5d5 | ||
|
|
3fa299cbee | ||
|
|
b8e3260e75 | ||
|
|
47f7282a27 | ||
|
|
4e57b7124a | ||
|
|
650efa9bec | ||
|
|
4284fded99 | ||
|
|
4bede83ccd | ||
|
|
fe8e782e9f | ||
|
|
3eb89e5dc6 | ||
|
|
1362eb4cd9 |
No files matched your search
@@ -84,7 +84,7 @@ connectionRequest = (deviceId, callback) ->
|
||||
)
|
||||
|
||||
request.on('socket', (socket) ->
|
||||
socket.setTimeout(2000)
|
||||
socket.setTimeout(config.get('CONNECTION_REQUEST_TIMEOUT', deviceId))
|
||||
socket.on('timeout', () ->
|
||||
request.abort()
|
||||
)
|
||||
|
||||
@@ -50,6 +50,7 @@ options = {
|
||||
GET_PARAMETER_NAMES_DEPTH_THRESHOLD : {type : 'int', default : 0},
|
||||
TASK_PARAMETERS_BATCH_SIZE : {type : 'int', default : 32},
|
||||
COOKIES_PATH : {type : 'string'},
|
||||
CONNECTION_REQUEST_TIMEOUT : {type : 'int', default : 2000},
|
||||
|
||||
# Libxml related configuration
|
||||
XML_PARSE_RECOVER : {type : 'bool'},
|
||||
|
||||
@@ -15,22 +15,31 @@
|
||||
# along with GenieACS. If not, see <http://www.gnu.org/licenses/>.
|
||||
###
|
||||
|
||||
path = require 'path'
|
||||
config = require './config'
|
||||
common = require './common'
|
||||
|
||||
|
||||
FILES = {}
|
||||
getFile = (filename) ->
|
||||
if filename not of FILES
|
||||
FILES[filename] = require(path.resolve(config.get('CONFIG_DIR'), "custom_commands/#{filename}"))
|
||||
|
||||
return FILES[filename]
|
||||
|
||||
|
||||
exports.execute = (deviceId, command, callback) ->
|
||||
args = command.split(/\s+/)
|
||||
f = args.shift()
|
||||
c = args.shift()
|
||||
|
||||
file = require "../config/custom_commands/#{f}"
|
||||
file = getFile(f)
|
||||
file[c](deviceId, args.join(' '), callback)
|
||||
|
||||
|
||||
exports.getFileCommands = (filename) ->
|
||||
commands = []
|
||||
f = require("../config/custom_commands/#{filename}")
|
||||
f = getFile(filename)
|
||||
for k,v of f
|
||||
commands.push(k)
|
||||
return commands
|
||||
|
||||
+1
-1
@@ -185,7 +185,7 @@ inform = (currentRequest, cwmpRequest) ->
|
||||
deviceCustomCommands[k] = v._timestamp for k,v of device._customCommands
|
||||
|
||||
for cmd in customCommands.getDeviceCustomCommandNames(currentRequest.session.deviceId)
|
||||
if not (deviceCustomCommands[cmd]?._timestamp < lastBootstrap)
|
||||
if not deviceCustomCommands[cmd]? or deviceCustomCommands[cmd] < lastBootstrap
|
||||
# Increment timestamp by one millisecond to ensure it runs after any refresh task
|
||||
_tasks.push({device: currentRequest.session.deviceId, name: 'customCommand', command: "#{cmd} init", timestamp: new Date(now.getTime() + 1)})
|
||||
delete deviceCustomCommands[cmd]
|
||||
|
||||
+37
-7
@@ -290,20 +290,26 @@ listener = (request, response) ->
|
||||
action = r[2]
|
||||
if not action? or action is '/'
|
||||
if request.method == 'DELETE'
|
||||
db.tasksCollection.remove({'_id' : taskId}, (err, removedCount) ->
|
||||
if err
|
||||
response.writeHead(500)
|
||||
response.end(errorToString(err))
|
||||
return
|
||||
db.tasksCollection.findOne({'_id' : taskId}, {'device' : 1}, (err, task) ->
|
||||
throw err if err
|
||||
|
||||
if removedCount == 0
|
||||
if not task
|
||||
response.writeHead(404)
|
||||
response.end()
|
||||
return
|
||||
|
||||
deviceId = task.device
|
||||
db.tasksCollection.remove({'_id' : taskId}, (err, removedCount) ->
|
||||
throw err if err
|
||||
|
||||
db.redisClient.del("#{deviceId}_presets_hash", (err) ->
|
||||
throw err if err
|
||||
|
||||
response.writeHead(200)
|
||||
response.end()
|
||||
)
|
||||
)
|
||||
)
|
||||
else
|
||||
response.writeHead 405, {'Allow': 'PUT DELETE'}
|
||||
response.end('405 Method Not Allowed')
|
||||
@@ -338,6 +344,11 @@ listener = (request, response) ->
|
||||
|
||||
gs = new mongodb.GridStore(db.mongoDb, filename, 'w', {metadata : metadata})
|
||||
gs.open((err, gs) ->
|
||||
if err
|
||||
response.writeHead(500)
|
||||
response.end(errorToString(err))
|
||||
return
|
||||
|
||||
gs.write(body, (err, res) ->
|
||||
throw err if err
|
||||
gs.close((err) ->
|
||||
@@ -349,6 +360,11 @@ listener = (request, response) ->
|
||||
)
|
||||
else if request.method == 'DELETE'
|
||||
mongodb.GridStore.unlink(db.mongoDb, filename, (err) ->
|
||||
if err
|
||||
response.writeHead(500)
|
||||
response.end(errorToString(err))
|
||||
return
|
||||
|
||||
response.writeHead(200)
|
||||
response.end()
|
||||
)
|
||||
@@ -421,7 +437,14 @@ listener = (request, response) ->
|
||||
sort = {}
|
||||
for k,v of s
|
||||
if aliases[k]?
|
||||
sort[a] = v for a in aliases[k]
|
||||
for a in aliases[k]
|
||||
if a[a.lastIndexOf('.')+1] != '_' and collectionName is 'devices'
|
||||
sort["#{a}._value"] = v
|
||||
else
|
||||
sort[a] = v
|
||||
else
|
||||
if k[k.lastIndexOf('.') + 1] != '_' and collectionName is 'devices'
|
||||
sort["#{k}._value"] = v
|
||||
else
|
||||
sort[k] = v
|
||||
cur.sort(sort)
|
||||
@@ -429,6 +452,11 @@ listener = (request, response) ->
|
||||
cur.skip(parseInt(urlParts.query.skip)) if urlParts.query.skip?
|
||||
cur.limit(parseInt(urlParts.query.limit)) if urlParts.query.limit?
|
||||
cur.count((err, total) ->
|
||||
if err
|
||||
response.writeHead(500)
|
||||
response.end(errorToString(err))
|
||||
return
|
||||
|
||||
response.writeHead(200, {'Content-Type' : 'application/json', 'total' : total})
|
||||
if request.method is 'HEAD'
|
||||
response.end()
|
||||
@@ -436,6 +464,8 @@ listener = (request, response) ->
|
||||
response.write("[\n")
|
||||
i = 0
|
||||
cur.each((err, item) ->
|
||||
throw err if err
|
||||
|
||||
if item is null
|
||||
response.end("\n]")
|
||||
else
|
||||
|
||||
@@ -68,7 +68,7 @@ normalizers.default = (input, normType) ->
|
||||
|
||||
r = stringToRegexp(input)
|
||||
if r isnt false
|
||||
vals.push({'$regex' : r})
|
||||
vals.push(r)
|
||||
|
||||
return vals
|
||||
return input
|
||||
@@ -90,7 +90,7 @@ normalizers.date = (input, normType) ->
|
||||
normalizers.string = (input, normType) ->
|
||||
if normType is 'query'
|
||||
if (m = /^\/(.*?)\/(g?i?m?y?)$/.exec(input))
|
||||
return [{'$regex' : new RegExp(m[1], m[2])}, input]
|
||||
return [new RegExp(m[1], m[2]), input]
|
||||
return input
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ normalizers.mac = (input, normType) ->
|
||||
if input.length == 17
|
||||
return [input, input.toLowerCase()]
|
||||
|
||||
return {'$regex' : new RegExp(input, 'i')}
|
||||
return new RegExp(input, 'i')
|
||||
|
||||
|
||||
exports.normalize = (path, value, normType) ->
|
||||
|
||||
+15
-4
@@ -51,8 +51,17 @@ expandValue = (param, value) ->
|
||||
while i < indices.length
|
||||
obj = {}
|
||||
for i in [0...keys.length]
|
||||
if common.typeOf(values[i][indices[i]]) is common.REGEXP_TYPE
|
||||
if keys[i] == '$ne'
|
||||
obj['$not'] = values[i][indices[i]]
|
||||
continue
|
||||
else if keys[i] == '$not' and common.typeOf(values[i][indices[i]]) isnt common.OBJECT_TYPE
|
||||
# Only a regex or decoument (object) are allowed within a $not operator.
|
||||
# This is needed in order to discard string from which a regex is generated.
|
||||
continue
|
||||
|
||||
obj[keys[i]] = values[i][indices[i]]
|
||||
objs.push(obj)
|
||||
objs.push(obj) if Object.keys(obj).length
|
||||
|
||||
for i in [0...indices.length]
|
||||
indices[i] += 1
|
||||
@@ -95,10 +104,12 @@ expand = (query, aliases) ->
|
||||
else
|
||||
conditions = permute(k, v, aliases)
|
||||
if conditions.length > 1
|
||||
if new_query['$and']?
|
||||
new_query['$and'].push({'$or' : conditions})
|
||||
new_query['$and'] ?= []
|
||||
if v?['$ne']? or v?['$nin']? or v?['$not']?
|
||||
for c in conditions
|
||||
new_query['$and'].push(c)
|
||||
else
|
||||
new_query['$and'] = [{'$or' : conditions}]
|
||||
new_query['$and'].push({'$or' : conditions})
|
||||
else
|
||||
common.extend(new_query, conditions[0])
|
||||
|
||||
|
||||
+14
-6
@@ -322,13 +322,21 @@ this.download = (task, methodResponse, callback) ->
|
||||
return
|
||||
|
||||
if methodResponse.type isnt 'DownloadResponse'
|
||||
if task.url?
|
||||
methodRequest = {
|
||||
type : 'Download',
|
||||
fileType : task.fileType or '1 Firmware Upgrade Image',
|
||||
url : task.url,
|
||||
username: task.username,
|
||||
password: task.password,
|
||||
successUrl : task.successUrl,
|
||||
failureUrl : task.failureUrl
|
||||
}
|
||||
callback(null, STATUS_OK, methodRequest)
|
||||
else
|
||||
db.filesCollection.findOne({_id : mongodb.ObjectID(String(task.file))}, (err, file) ->
|
||||
if not file?
|
||||
callback('File not found')
|
||||
return
|
||||
else if err?
|
||||
callback(err)
|
||||
return
|
||||
if err or not file?
|
||||
return callback(err or new Error('File not found'))
|
||||
|
||||
l = {
|
||||
protocol : if config.get('FS_SSL') then 'https' else 'http',
|
||||
|
||||
@@ -53,8 +53,8 @@ commitUpdates = (deviceId, deviceUpdates, commitQueue, callback) ->
|
||||
processBatch = (updatesBatch, cb) ->
|
||||
if updatesBatch.informEvents?
|
||||
update['$set']['_lastInform'] = now
|
||||
update['$set']['_lastBoot'] if '1 BOOT' in updatesBatch.informEvents
|
||||
update['$set']['_lastBootstrap'] if '0 BOOTSTRAP' in updatesBatch.informEvents
|
||||
update['$set']['_lastBoot'] = now if '1 BOOT' in updatesBatch.informEvents
|
||||
update['$set']['_lastBootstrap'] = now if '0 BOOTSTRAP' in updatesBatch.informEvents
|
||||
|
||||
if updatesBatch.parameterValues?
|
||||
for p in updatesBatch.parameterValues
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "genieacs",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.7",
|
||||
"description": "A blazing fast TR-069 auto configuration server (ACS) built with Node.js, Redis, and MongoDB",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in new issue
Block a user