Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b91bcb7442 | ||
|
|
a0c0a7938b | ||
|
|
82f354bf2b | ||
|
|
7f64b567db | ||
|
|
b17f842de7 | ||
|
|
ff68553bd7 | ||
|
|
22b11d6103 | ||
|
|
00987ea8e2 | ||
|
|
f0a1289818 | ||
|
|
38840d5b8d | ||
|
|
74008bc7de | ||
|
|
305558f186 | ||
|
|
4ad8aa5a1b | ||
|
|
c70354997a | ||
|
|
c88e5d6fe8 | ||
|
|
4e9186812c | ||
|
|
41740cbf0b | ||
|
|
2932b9ab6d | ||
|
|
3625f26134 | ||
|
|
c1d486b776 |
No files matched your search
@@ -1,3 +1,4 @@
|
||||
*~
|
||||
*.js
|
||||
node_modules
|
||||
debug/*
|
||||
@@ -19,10 +19,10 @@ Install [Node.js](http://nodejs.org/), [Redis](http://redis.io/), and [MongoDB](
|
||||
|
||||
You may need to modify the configuration files under "config" directory (in /lib/node_modules/genieacs/config) depending on your setup.
|
||||
|
||||
Alternatively, you can use git to get the latest development version (not recommended for production use):
|
||||
Alternatively, you can install from source by cloning the git repository:
|
||||
|
||||
cd /opt
|
||||
git clone https://github.com/zaidka/genieacs.git
|
||||
git clone https://github.com/zaidka/genieacs.git --branch v1.0
|
||||
cd genieacs
|
||||
npm install
|
||||
npm run configure
|
||||
@@ -54,13 +54,12 @@ You may now proceed with installing [GenieACS GUI front end](https://github.com/
|
||||
|
||||
## Support
|
||||
|
||||
Documentation is still work in progress. Feel free to contact me if you require any assistance in installation, configuration, or using the APIs.
|
||||
The [Users mailing list](http://lists.genieacs.com) is a good place to get guidance and help from the community. Head on over and join the conversation! In addition, the [wiki](https://github.com/zaidka/genieacs/wiki) provides useful documentation and tips from GenieACS users.
|
||||
|
||||
You may submit bug reports or feature requests [here](https://github.com/zaidka/genieacs/issues).
|
||||
You may submit bug reports or feature requests [here](https://github.com/zaidka/genieacs/issues). For device interoperability issues, please consult the mailing list first — it's likely that a workaround already exists.
|
||||
|
||||
For commercial support options, please contact me.
|
||||
For commercial support options and professional services, please visit [genieacs.com](https://genieacs.com).
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome. Fork this repo and open a pull request and wait for feedback. You can also contribute by enhancing the documentation in the [wiki section](https://github.com/zaidka/genieacs/wiki).
|
||||
|
||||
@@ -8,12 +8,20 @@
|
||||
"_deviceId._Manufacturer" : {"alias" : "summary.manufacturer"},
|
||||
"InternetGatewayDevice.DeviceInfo.HardwareVersion" : {"alias" : "summary.hardwareVersion"},
|
||||
"InternetGatewayDevice.DeviceInfo.SoftwareVersion" : {"alias" : "summary.softwareVersion"},
|
||||
"Device.DeviceInfo.HardwareVersion" : {"alias" : "summary.hardwareVersion"},
|
||||
"Device.DeviceInfo.SoftwareVersion" : {"alias" : "summary.softwareVersion"},
|
||||
|
||||
"InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac", "type" : "mac"},
|
||||
"InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.ExternalIPAddress" : {"alias" : "summary.ip"},
|
||||
"InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac", "type" : "mac"},
|
||||
"InternetGatewayDevice.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.ExternalIPAddress" : {"alias" : "summary.ip"},
|
||||
"Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac", "type" : "mac"},
|
||||
"Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANIPConnection./^\\d+$/.ExternalIPAddress" : {"alias" : "summary.ip"},
|
||||
"Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.MACAddress" : {"alias" : "summary.mac", "type" : "mac"},
|
||||
"Device.WANDevice./^\\d+$/.WANConnectionDevice./^\\d+$/.WANPPPConnection./^\\d+$/.ExternalIPAddress" : {"alias" : "summary.ip"},
|
||||
|
||||
"InternetGatewayDevice.LANDevice./^\\d+$/.WLANConfiguration./^\\d+$/.SSID" : {"alias" : "summary.wlanSsid"},
|
||||
"InternetGatewayDevice.LANDevice./^\\d+$/.WLANConfiguration./^\\d+$/.PreSharedKey.1.KeyPassphrase" : {"alias" : "summary.wlanPassphrase"}
|
||||
"InternetGatewayDevice.LANDevice./^\\d+$/.WLANConfiguration./^\\d+$/.PreSharedKey.1.KeyPassphrase" : {"alias" : "summary.wlanPassphrase"},
|
||||
"Device.LANDevice./^\\d+$/.WLANConfiguration./^\\d+$/.SSID" : {"alias" : "summary.wlanSsid"},
|
||||
"Device.LANDevice./^\\d+$/.WLANConfiguration./^\\d+$/.PreSharedKey.1.KeyPassphrase" : {"alias" : "summary.wlanPassphrase"}
|
||||
}
|
||||
@@ -117,6 +117,9 @@ connectionRequest = (deviceId, callback) ->
|
||||
authString = auth.digest(username, password, uri.path, 'GET', null, authHeader)
|
||||
|
||||
conReq(connectionRequestUrl, authString, (statusCode, authHeader) ->
|
||||
if statusCode == 0
|
||||
# Workaround for some devices unexpectedly closing the connection
|
||||
return conReq(connectionRequestUrl, authString, (statusCode) -> callback(statusToError(statusCode)))
|
||||
callback(statusToError(statusCode))
|
||||
)
|
||||
else
|
||||
|
||||
+13
-1
@@ -82,10 +82,22 @@ exports.parseDeviceId = (deviceId) ->
|
||||
|
||||
|
||||
exports.extend = (obj, mixin) ->
|
||||
obj[name] = method for name, method of mixin
|
||||
obj[name] = method for name, method of mixin
|
||||
obj
|
||||
|
||||
|
||||
exports.flattenObject = (object) ->
|
||||
newObj = {}
|
||||
f = (obj, prefix) ->
|
||||
for k, v of obj
|
||||
if typeof(v) is 'object'
|
||||
f(v, "#{prefix}#{k}.")
|
||||
else
|
||||
newObj["#{prefix}#{k}"] = v
|
||||
f(object, '')
|
||||
return newObj
|
||||
|
||||
|
||||
exports.getParamValueFromPath = (obj, path) ->
|
||||
pp = path.split('.')
|
||||
ref = obj
|
||||
|
||||
+16
-10
@@ -196,21 +196,21 @@ listener = (request, response) ->
|
||||
if urlParts.query.connection_request?
|
||||
apiFunctions.connectionRequest(deviceId, (err) ->
|
||||
if err
|
||||
response.writeHead(202)
|
||||
response.end()
|
||||
response.writeHead(202, {'Content-Type' : 'application/json'})
|
||||
response.end(JSON.stringify(task))
|
||||
else
|
||||
apiFunctions.watchTask(task._id, config.get('DEVICE_ONLINE_THRESHOLD', deviceId), (err) ->
|
||||
if err
|
||||
response.writeHead(202)
|
||||
response.end()
|
||||
response.writeHead(202, {'Content-Type' : 'application/json'})
|
||||
response.end(JSON.stringify(task))
|
||||
return
|
||||
response.writeHead(200)
|
||||
response.end()
|
||||
response.writeHead(200, {'Content-Type' : 'application/json'})
|
||||
response.end(JSON.stringify(task))
|
||||
)
|
||||
)
|
||||
else
|
||||
response.writeHead(202)
|
||||
response.end()
|
||||
response.writeHead(202, {'Content-Type' : 'application/json'})
|
||||
response.end(JSON.stringify(task))
|
||||
)
|
||||
)
|
||||
else if urlParts.query.connection_request?
|
||||
@@ -244,7 +244,7 @@ listener = (request, response) ->
|
||||
else if TASKS_REGEX.test(urlParts.pathname)
|
||||
r = TASKS_REGEX.exec(urlParts.pathname)
|
||||
taskId = mongodb.ObjectID(querystring.unescape(r[1]))
|
||||
action = try querystring.unescape(r[2])
|
||||
action = r[2]
|
||||
if not action? or action is '/'
|
||||
if request.method == 'DELETE'
|
||||
db.tasksCollection.remove({'_id' : taskId}, (err, removedCount) ->
|
||||
@@ -339,10 +339,16 @@ listener = (request, response) ->
|
||||
|
||||
func = (aliases) ->
|
||||
if urlParts.query.query?
|
||||
q = JSON.parse(urlParts.query.query)
|
||||
try
|
||||
q = JSON.parse(urlParts.query.query)
|
||||
catch err
|
||||
response.writeHead(400)
|
||||
response.end(err.toString())
|
||||
return
|
||||
else
|
||||
q = {}
|
||||
q = query.expand(q, aliases) if collectionName is 'devices'
|
||||
q = query.substituteObjectId(q) if collectionName is 'tasks'
|
||||
|
||||
if urlParts.query.projection?
|
||||
projection = {}
|
||||
|
||||
@@ -27,7 +27,7 @@ common = require './common'
|
||||
parameters = require './parameters'
|
||||
|
||||
|
||||
stringToRegexp = (input) ->
|
||||
stringToRegexp = (input, flags) ->
|
||||
if (input.indexOf('*') == -1)
|
||||
return false
|
||||
|
||||
@@ -44,7 +44,7 @@ stringToRegexp = (input) ->
|
||||
|
||||
output = output.replace(/[\*]/, '.*')
|
||||
|
||||
return new RegExp(output)
|
||||
return new RegExp(output, flags)
|
||||
|
||||
|
||||
normalizers = {}
|
||||
@@ -117,14 +117,14 @@ normalizers.mac = (input, normType) ->
|
||||
|
||||
if input.indexOf('*') != -1
|
||||
input = (colonizeMac(a) for a in input.split('*')).join('*')
|
||||
return stringToRegexp(input, false)
|
||||
return stringToRegexp(input, 'i')
|
||||
|
||||
input = colonizeMac(input)
|
||||
|
||||
if input.length == 17
|
||||
return input
|
||||
return [input, input.toLowerCase()]
|
||||
|
||||
return {'$regex' : new RegExp(input)}
|
||||
return {'$regex' : new RegExp(input, 'i')}
|
||||
|
||||
|
||||
exports.normalize = (path, value, normType) ->
|
||||
|
||||
+28
-31
@@ -54,12 +54,21 @@ exports.calculatePresetsHash = (presets, objects) ->
|
||||
|
||||
|
||||
matchObject = (object, param) ->
|
||||
return false if not object._keys? or object._keys.length == 0
|
||||
for k in object._keys
|
||||
return false if not param[k]?
|
||||
v = common.matchType(param[k]._value, object[k])
|
||||
if param[k]._value != v
|
||||
flatObject = common.flattenObject(object)
|
||||
if object._keys?.length
|
||||
keys = object._keys
|
||||
else
|
||||
# Consider all parameters as keys if none are defined
|
||||
keys = (k for k in Object.keys(flatObject) when k[0] != '_')
|
||||
|
||||
for k in keys
|
||||
p = common.getParamValueFromPath(param, k)
|
||||
return false if not p?
|
||||
v = common.matchType(p._value, flatObject[k])
|
||||
|
||||
if p._value != common.matchType(p._value, flatObject[k])
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
|
||||
@@ -146,15 +155,7 @@ exports.getDevicePreset = (deviceId, presets, objects, aliases, callback) ->
|
||||
devicePreset.objects[c.name][c.object].current ?= {}
|
||||
for k,p of param
|
||||
continue if k[0] == '_'
|
||||
if p._name?
|
||||
if p._name == c.object
|
||||
devicePreset.objects[c.name][c.object].current[k] = p
|
||||
else if matchObject(objects[c.object], p)
|
||||
u = {}
|
||||
u["#{c.name}.#{k}._name"] = c.object
|
||||
db.devicesCollection.update({'_id' : deviceId}, {'$set' : u}, {}, (err, count) ->
|
||||
throw err if err
|
||||
)
|
||||
if matchObject(objects[c.object], p)
|
||||
devicePreset.objects[c.name][c.object].current[k] = p
|
||||
|
||||
when 'delete_object'
|
||||
@@ -165,15 +166,7 @@ exports.getDevicePreset = (deviceId, presets, objects, aliases, callback) ->
|
||||
devicePreset.objects[c.name][c.object].current ?= {}
|
||||
for k,p of param
|
||||
continue if k[0] == '_'
|
||||
if p._name?
|
||||
if p._name == c.object
|
||||
devicePreset.objects[c.name][c.object].current[k] = p
|
||||
else if matchObject(objects[c.object], p)
|
||||
u = {}
|
||||
u["#{c.name}.#{k}._name"] = c.object
|
||||
db.devicesCollection.update({'_id' : deviceId}, {'$set' : u}, {}, (err, count) ->
|
||||
throw err if err
|
||||
)
|
||||
if matchObject(objects[c.object], p)
|
||||
devicePreset.objects[c.name][c.object].current[k] = p
|
||||
|
||||
when 'custom_command_value'
|
||||
@@ -250,20 +243,21 @@ exports.processDevicePreset = (deviceId, devicePreset, callback) ->
|
||||
for objectName, objectDetails of object
|
||||
continue if not objectDetails.current?
|
||||
if objectDetails.preset?
|
||||
flatObject = common.flattenObject(objectDetails.preset)
|
||||
if Object.keys(objectDetails.current).length > 0
|
||||
for i, obj of objectDetails.current
|
||||
for paramName, paramValue of objectDetails.preset
|
||||
for paramName, paramValue of flatObject
|
||||
continue if paramName[0] == '_'
|
||||
if obj[paramName]
|
||||
currentValue = obj[paramName]._value
|
||||
presetValue = common.matchType(currentValue, objectDetails.preset[paramName])
|
||||
if currentValue != presetValue
|
||||
setParameterValues.push(["#{parameterPath}.#{i}.#{paramName}", presetValue, obj[paramName]._type])
|
||||
currentValue = common.getParamValueFromPath(obj, paramName)
|
||||
if currentValue?
|
||||
presetValue = common.matchType(currentValue._value, flatObject[paramName])
|
||||
if currentValue._value != presetValue
|
||||
setParameterValues.push(["#{parameterPath}.#{i}.#{paramName}", presetValue, currentValue._type])
|
||||
else
|
||||
vals = []
|
||||
for k,v of objectDetails.preset
|
||||
for k,v of flatObject
|
||||
vals.push([k, v]) if k[0] != '_'
|
||||
taskList.push({device : deviceId, name : 'addObject', objectName : parameterPath, parameterValues : vals, instanceName : objectName})
|
||||
taskList.push({device : deviceId, name : 'addObject', objectName : parameterPath, parameterValues : vals})
|
||||
else if Object.keys(objectDetails.current).length > 0
|
||||
for i, obj of objectDetails.current
|
||||
taskList.push({device : deviceId, name : 'deleteObject', objectName : "#{parameterPath}.#{i}"})
|
||||
@@ -320,6 +314,9 @@ accumulateConfigurations = (presets, objects) ->
|
||||
"object_#{c.name}_#{objectHash}"
|
||||
when 'software_version'
|
||||
'software_version'
|
||||
when 'custom_command_age', 'custom_command_value'
|
||||
[filename, commandName] = c.command.split(' ', 2)
|
||||
"#{c.type}_#{filename}_#{commandName}"
|
||||
else
|
||||
"#{c.type}_#{c.name}"
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
common = require './common'
|
||||
normalize = require './normalize'
|
||||
mongodb = require 'mongodb'
|
||||
|
||||
|
||||
expandValue = (param, value) ->
|
||||
@@ -103,5 +104,30 @@ expand = (query, aliases) ->
|
||||
|
||||
return new_query
|
||||
|
||||
# Replace _id string values with ObjectID type
|
||||
substituteObjectId = (query) ->
|
||||
for k, v of query
|
||||
if k[0] == '$' # logical operator
|
||||
for i in [0...v.length]
|
||||
substituteObjectId(v[i])
|
||||
else if k == '_id'
|
||||
if common.typeOf(v) is common.STRING_TYPE
|
||||
query[k] = mongodb.ObjectID(v) if v.length == 24
|
||||
else if common.typeOf(v) is common.OBJECT_TYPE
|
||||
for kk, vv of v
|
||||
switch kk # operator
|
||||
when '$in', '$nin'
|
||||
for i in [0...vv.length]
|
||||
vv[i] = mongodb.ObjectID(vv[i]) if vv[i].length == 24
|
||||
when '$eq', '$gt', '$gte', '$lt', '$lte', '$ne'
|
||||
v[kk] = mongodb.ObjectID(vv) if vv.length == 24
|
||||
when '$exists', '$type' then
|
||||
# ignore
|
||||
else
|
||||
throw new Error('Operator not supported')
|
||||
|
||||
return query
|
||||
|
||||
|
||||
exports.expand = expand
|
||||
exports.substituteObjectId = substituteObjectId
|
||||
+11
-4
@@ -43,6 +43,7 @@ common = require './common'
|
||||
db = require './db'
|
||||
mongodb = require 'mongodb'
|
||||
customCommands = require './custom-commands'
|
||||
url = require 'url'
|
||||
|
||||
exports.STATUS_OK = STATUS_OK = 1
|
||||
exports.STATUS_FAULT = STATUS_FAULT = 2
|
||||
@@ -220,7 +221,6 @@ this.addObject = (task, methodResponse, callback) ->
|
||||
task.session.subtask = {device : task.device, name : 'getParameterNames', parameterPath : "#{task.objectName}.#{task.session.instanceNumber}.", nextLevel : false}
|
||||
task.session.appliedParameterValues = []
|
||||
task.session.parameterNames = []
|
||||
allDeviceUpdates.instanceName = [["#{task.objectName}.#{task.session.instanceNumber}", task.instanceName]] if task.instanceName?
|
||||
else
|
||||
callback(null, STATUS_OK, {type : 'AddObject', objectName : "#{task.objectName}."})
|
||||
return
|
||||
@@ -251,7 +251,7 @@ this.addObject = (task, methodResponse, callback) ->
|
||||
if deviceUpdates and deviceUpdates.parameterValues?
|
||||
for p1 in deviceUpdates.parameterValues
|
||||
for p2 in task.parameterValues
|
||||
if common.endsWith(p1[0], ".#{p2[0]}")
|
||||
if p1[0] == "#{task.objectName}.#{task.session.instanceNumber}.#{p2[0]}"
|
||||
t = if p2[2] then p2[2] else p1[2]
|
||||
v = common.matchType(p1[1], p2[1])
|
||||
# TODO only include if writable
|
||||
@@ -296,7 +296,7 @@ this.reboot = (task, methodResponse, callback) ->
|
||||
task.fault = methodResponse
|
||||
callback(null, STATUS_FAULT)
|
||||
return
|
||||
|
||||
|
||||
if methodResponse.type isnt 'RebootResponse'
|
||||
callback(null, STATUS_OK, {type : 'Reboot'})
|
||||
else
|
||||
@@ -330,11 +330,18 @@ this.download = (task, methodResponse, callback) ->
|
||||
callback(err)
|
||||
return
|
||||
|
||||
l = {
|
||||
protocol : if config.get('FS_SSL') then 'https' else 'http',
|
||||
hostname : config.get('FS_IP'),
|
||||
port : config.get('FS_PORT'),
|
||||
pathname : encodeURIComponent(file.filename)
|
||||
}
|
||||
|
||||
methodRequest = {
|
||||
type : 'Download',
|
||||
fileType : file.metadata.fileType,
|
||||
fileSize : file.length,
|
||||
url : "http://#{config.get('FS_IP')}:#{config.get('FS_PORT')}/#{encodeURIComponent(file.filename)}",
|
||||
url : url.format(l),
|
||||
successUrl : task.successUrl,
|
||||
failureUrl : task.failureUrl
|
||||
}
|
||||
|
||||
@@ -75,10 +75,6 @@ commitUpdates = (deviceId, deviceUpdates, commitQueue, callback) ->
|
||||
for p in updatesBatch.deletedObjects
|
||||
update['$unset'][p] = 1
|
||||
|
||||
if updatesBatch.instanceName?
|
||||
for i in updatesBatch.instanceName
|
||||
update['$set']["#{i[0]}._name"] = i[1]
|
||||
|
||||
if updatesBatch.parameterNames?
|
||||
presentPaths ?= {}
|
||||
projection ?= {}
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "genieacs",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.4",
|
||||
"description": "A blazing fast TR-069 auto configuration server (ACS) built with Node.js, Redis, and MongoDB",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -20,13 +20,13 @@
|
||||
"bin": "bin"
|
||||
},
|
||||
"dependencies": {
|
||||
"libxmljs": "~0.11.0",
|
||||
"redis": "~0.12.1",
|
||||
"hiredis": "~0.1.17",
|
||||
"mongodb": "~1.4.8"
|
||||
"libxmljs": "0.11.0 - 0.14.x",
|
||||
"redis": "^0.12.1",
|
||||
"hiredis": "0.1.17 - 0.4.x",
|
||||
"mongodb": "^1.4.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffee-script": "~1.7.1"
|
||||
"coffee-script": "^1.7.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0 <0.12"
|
||||
|
||||
Reference in new issue
Block a user