|
@@ -20,7 +20,8 @@ const MapHandler = require('./lib/map-handler')
|
20
|
20
|
const defaultConfig = (options = {}) => ({
|
21
|
21
|
options,
|
22
|
22
|
groups: { byKey: {}, byName: {} },
|
23
|
|
- replicators: { byKey: {}, byName: {} }
|
|
23
|
+ replicators: { byKey: {}, byName: {} },
|
|
24
|
+ devices: { byKey: {}, byName: {} }
|
24
|
25
|
})
|
25
|
26
|
|
26
|
27
|
// filename-safe date (probably there is a better way to do this)
|
|
@@ -40,6 +41,7 @@ class CoBoxConfig {
|
40
|
41
|
fs.writeFileSync(this.storage, yaml.safeDump(defaultConfig(), { sortKeys: true }))
|
41
|
42
|
this._groups = config.groups
|
42
|
43
|
this._replicators = config.replicators
|
|
44
|
+ this._devices = config.devices
|
43
|
45
|
this._options = config.options
|
44
|
46
|
} else {
|
45
|
47
|
this.load()
|
|
@@ -50,11 +52,12 @@ class CoBoxConfig {
|
50
|
52
|
|
51
|
53
|
this.deriveKeyPair = crypto.keyPair.bind(null, parentKey)
|
52
|
54
|
this.identity = crypto.keyPair(parentKey, IDENTITY_SUBKEY_ID)
|
53
|
|
-
|
54
|
55
|
this.logger = logger(path.join(this.root, 'logs', logfile))
|
55
|
56
|
this.log = this.logger('cobox-config')
|
|
57
|
+
|
56
|
58
|
this.groups = KeyHandler(this._groups)
|
57
|
59
|
this.replicators = KeyHandler(this._replicators)
|
|
60
|
+ this.devices = KeyHandler(this._devices)
|
58
|
61
|
this.options = MapHandler(this._options)
|
59
|
62
|
}
|
60
|
63
|
|
|
@@ -63,6 +66,7 @@ class CoBoxConfig {
|
63
|
66
|
var config = defaultConfig()
|
64
|
67
|
config.groups = this._groups
|
65
|
68
|
config.replicators = this._replicators
|
|
69
|
+ config.devices = this._devices
|
66
|
70
|
config.options = this._options
|
67
|
71
|
|
68
|
72
|
fs.writeFileSync(this.storage, yaml.safeDump(config, { sortKeys: true }))
|
|
@@ -78,6 +82,7 @@ class CoBoxConfig {
|
78
|
82
|
const config = yaml.safeLoad(fs.readFileSync(this.storage, 'utf8'))
|
79
|
83
|
this._groups = config.groups
|
80
|
84
|
this._replicators = config.replicators
|
|
85
|
+ this._devices = config.devices
|
81
|
86
|
this._options = config.options
|
82
|
87
|
return true
|
83
|
88
|
} catch (err) {
|