-
Notifications
You must be signed in to change notification settings - Fork 0
/
main
executable file
·58 lines (49 loc) · 1.93 KB
/
main
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
#!/usr/bin/env node
/*
* You may redistribute this program and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
var Peers = require("./peers/index.js");
var fs = require('fs');
const getPeers = function () {
return Peers.map(function (creds, path) {
if (typeof creds.location !== 'undefined')
delete creds.location;
for (const peer in creds) {
if (creds.hasOwnProperty(peer)) {
// skip IPv6 peers, travis does not support this
if (peer.indexOf('[') === -1) {
// clear optional fields (see hyperboria/peers#126 or hyperboria/peers#/128)
optfields = ['contact', 'gpg', 'ipv6', 'location'];
for (const i in optfields) {
if (typeof(creds[peer][optfields[i]]) !== 'undefined')
delete creds[peer][optfields[i]];
}
return {
[peer]: creds[peer]
};
}
}
}
});
}
const arrayToObject = function (array) {
return array.reduce(function (result, item) {
var key = Object.keys(item)[0];
result[key] = item[key];
return result;
}, {});
}
peers = arrayToObject(getPeers());
var CONFIG = require("./cjdroute.conf");
CONFIG.interfaces.UDPInterface[0].connectTo = peers;
console.log(JSON.stringify(CONFIG));