This repository has been archived by the owner on Oct 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
115 lines (99 loc) · 4.44 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"use strict";
/*
Virtualization Layer | Glogal configuration file
> Do not edit "config.js" but create instead a "config.local.js" file with only the properties you would like to change;
> an example is available in "config.local.example.js"
by Alexandre Alapetite http://alexandre.alapetite.fr
from Alexandra Institute http://www.alexandra.dk
for the ALMANAC European project http://www.almanac-project.eu
*/
var fs = require('fs');
var hosts = {
instanceName: process.env.INSTANCE_NAME || '', //Name of the instance in the federation
virtualizationLayer: {
scheme: process.env.VL_SCHEME || 'http',
host: process.env.VL_HOST || 'localhost',
port: +(process.env.VL_PORT) || 80,
},
virtualizationLayerPublicUrl: process.env.VL_PUBLIC_URL || '', //Public URL of this Virtualization Layer, if any
mqttBrokerUrl: process.env.MQTT_BROKER_URL || 'mqtt://localhost/',
networkManagerUrl: process.env.NETWORK_MANAGER_URL || 'http://localhost:8181/',
recourceCatalogueUrn: process.env.RESOURCE_CATALOGUE_URN || 'urn:schemas-upnp-org:IoTdevice:OGCapplicationIoTresourcemanager:1', //Set to blank to disable UPnP
recourceCatalogueUrl: process.env.RESOURCE_CATALOGUE_URL || 'http://localhost:44441/', //Set to blank to use only UPnP discovery
scralUrl: process.env.SCRAL_URL || 'http://localhost:8080/connectors.rest/',
scralUiUrl: process.env.SCRAL_UI_URL || 'http://localhost:8080/gui/',
storageManagerUrl: process.env.STORAGE_MANAGER_URL || 'http://cnet006.cloudapp.net/Dmf/SensorThings/',
dfmUrl: process.env.DFM_URL || 'http://localhost:8319/',
santanderUrl: process.env.SANTANDER_URL || 'http://data.smartsantander.eu/ISMB/',
noderedUrl: process.env.NODERED_URL || 'http://localhost:1880/',
virtualizationLayerPeers: [ //Manual peering (sends the local MQTT events to other VirtualizationLayers
//'http://almanac.alexandra.dk/', //Alexandra Institute (Ubuntu)
//'http://p2.alapetite.dk/', //Alexandra Institute (Raspberry Pi)
//'http://130.192.86.227:8088/', //ISMB
],
};
var openIdPublicKey = process.env.OPENID_PUBLIC_KEY;
if (!openIdPublicKey) {
try {
openIdPublicKey = fs.readFileSync('./certificates/openIdPublicKey.pem').toString();
} catch (ex) {
openIdPublicKey = '';
console.error('Error while loading OpenID public key: ' + ex);
}
}
var tlsClientCa = [];
for (var i = 1; i <= 4; i++) {
var tlsClientCaI = process.env['TLS_CLIENT_CA_' + i];
if (!tlsClientCaI) {
try {
tlsClientCaI = fs.readFileSync('./certificates/tlsClientCa' + i + '.pem').toString();
console.log('TLS client CA loaded: ./certificates/tlsClientCa' + i + '.pem');
} catch (ex) {
}
}
if (tlsClientCaI) {
tlsClientCa.push(tlsClientCaI);
}
}
var tlsClientCert = process.env.TLS_CLIENT_CERT;
if (!tlsClientCert) {
try {
tlsClientCert = fs.readFileSync('./certificates/tlsClientCert.pem').toString();
} catch (ex) {
tlsClientCert = '';
console.error('Error while loading TLS client certificate: ' + ex);
}
}
var tlsClientKey = process.env.TLS_CLIENT_KEY;
if (!tlsClientKey) {
try {
tlsClientKey = fs.readFileSync('./certificates/tlsClientKey.pem').toString();
} catch (ex) {
tlsClientKey = '';
console.error('Error while loading TLS client key: ' + ex);
}
}
exports.config = {
hosts: hosts,
//Time-out in milliseconds when proxying to ALMANAC components
proxyTimeoutMs: process.env.PROXY_TIMEOUT_MS || 60000,
//Max size in bytes for POST / PUT / PATCH requests
maxPostBodyLength: process.env.MAX_POST_BODY_LENGTH || 10485760,
//{silent, error, warn, http, info, verbose, silly}
logLevel: process.env.LOG_LEVEL || 'info',
//Enables or disables the page showing internal variables and status
exposeInternalStatus: (process.env.EXPOSE_INTERNAL_STATUS || 'yes') === 'yes',
//For compatibility with old MQTT brokers, e.g. Mosquitto < 1.3
mqttUseOldVersion3: (process.env.MQTT_USE_OLD_VERSION_3 || 'no') === 'yes',
//Public key of the OpenID Connect server, to validate the signature of the authorization token
openIdPublicKey: openIdPublicKey || '',
//Information for TLS client security
tlsClientCa: tlsClientCa || '',
tlsClientCert: tlsClientCert || '',
tlsClientKey: tlsClientKey || '',
tlsClientPassphrase: process.env.TLS_CLIENT_PASSPHRASE || '',
//Enforces that requests must have a valid authorization token
requireAuthorization: (process.env.REQUIRE_AUTHORIZATION || 'yes') === 'yes',
//Enforces that authorization tokens must refer to a valid policy
requirePolicy: (process.env.REQUIRE_POLICY || 'yes') === 'yes',
};