-
Notifications
You must be signed in to change notification settings - Fork 0
/
conf.js
133 lines (108 loc) · 4.95 KB
/
conf.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*jslint node: true */
"use strict";
require('./enforce_singleton.js');
require('./constants.js'); // in order to force loading .env before app-root's conf.js
function mergeExports(anotherModule){
for (var key in anotherModule)
exports[key] = anotherModule[key];
}
// start node explicitly by `require('ocore/network').start()`
//exports.explicitStart = true
// port we are listening on. Set to null to disable accepting connections
// recommended port for livenet: 6611
// recommended port for testnet: 16611
exports.port = null;
//exports.port = 6611;
// enable this will make websocket server doesn't spawn on new port
// this is usefull if you already have SocketServer running and want to reuse the port
//exports.portReuse = true;
// how peers connect to me
//exports.myUrl = 'wss://example.org/bb';
// if we are serving as hub. Default is false
//exports.bServeAsHub = true;
// if we are a light client. Default is full client
//exports.bLight = true;
// where to send bug reports to. Usually, it is wallet vendor's server.
// By default, it is hub url
//exports.bug_sink_url = "wss://example.org/bb";
// this is used by wallet vendor only, to redirect bug reports to developers' email
//exports.bug_sink_email = '[email protected]';
//exports.bugs_from_email = '[email protected]';
// Connects through socks v5 proxy without auth, WS_PROTOCOL has to be 'wss'
// exports.socksHost = 'localhost';
// exports.socksPort = 9050;
// exports.socksUsername = 'dummy';
// exports.socksPassword = 'dummy';
// For better security you should not use local DNS with socks proxy
// exports.socksLocalDNS = false;
// Connects through an http proxy server
// exports.httpsProxy = 'http://proxy:3128'
// WebSocket protocol prefixed to all hosts. Must be wss:// on livenet, ws:// is allowed on testnet
exports.WS_PROTOCOL = process.env.devnet ? "ws://" : "wss://";
exports.MAX_INBOUND_CONNECTIONS = 100;
exports.MAX_OUTBOUND_CONNECTIONS = 100;
exports.MAX_TOLERATED_INVALID_RATIO = 0.1; // max tolerated ratio of invalid to good joints
exports.MIN_COUNT_GOOD_PEERS = 10; // if we have less than this number of good peers, we'll ask peers for their lists of peers
exports.bWantNewPeers = true;
// true, when removed_paired_device commands received from peers are to be ignored. Default is false.
exports.bIgnoreUnpairRequests = false;
var bCordova = (typeof window === 'object' && window && window.cordova);
// storage engine: mysql or sqlite
exports.storage = 'sqlite';
if (bCordova) {
exports.storage = 'sqlite';
exports.bLight = true;
}
exports.database = {};
exports.updatableAssetRegistries = ['O6H6ZIFI57X3PLTYHOCVYPP5A553CYFQ'];
/*
There are 3 ways to customize conf in modules that use ocore lib:
1. drop a custom conf.js into the project root. The code below will find it and merge. Will not work under browserify.
2. drop a custom conf.json into the app's data dir inside the user's home dir. The code below will find it and merge. Will not work under browserify.
3. require() this conf and modify it:
var conf = require('ocore/conf.js');
conf.custom_property = 'custom value';
You should do it as early as possible during your app's startup.
The later require()s of this conf will see the modified version.
This way is not recommended as the code becomes loading order dependent.
*/
if (typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node !== 'undefined') { // desktop
var desktopApp = require('./desktop_app.js');
// merge conf from other modules that include us as lib. The other module must place its custom conf.js into its root directory
var appRootDir = desktopApp.getAppRootDir();
var appPackageJson = require(appRootDir + '/package.json');
exports.program = appPackageJson.name;
exports.program_version = appPackageJson.version;
if (appRootDir !== __dirname){
try{
mergeExports(require(appRootDir + '/conf.js'));
console.log('merged app root conf from ' + appRootDir + '/conf.js');
}
catch(e){
console.log("not using app root conf: "+e);
}
}
else
console.log("I'm already at the root");
// merge conf from user home directory, if any.
// Note that it is json rather than js to avoid code injection
var appDataDir = desktopApp.getAppDataDir();
try{
mergeExports(require(appDataDir + '/conf.json'));
console.log('merged user conf from ' + appDataDir + '/conf.json');
}
catch(e){
console.log('not using user conf: '+e);
}
}
// after merging the custom confs, set defaults if they are still not set
if (exports.storage === 'mysql'){
exports.database.max_connections = exports.database.max_connections || 1;
exports.database.host = exports.database.host || 'localhost';
exports.database.name = exports.database.name || 'rechain';
exports.database.user = exports.database.user || 'rechain';
}
else if (exports.storage === 'sqlite'){
exports.database.max_connections = exports.database.max_connections || 1;
exports.database.filename = exports.database.filename || (exports.bLight ? 'rechain-light.sqlite' : 'rechain.sqlite');
}