-
Notifications
You must be signed in to change notification settings - Fork 0
/
conf.js
115 lines (96 loc) · 4.23 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
/*jslint node: true */
"use strict";
require('./enforce_singleton.js');
function mergeExports(anotherModule){
for (var key in anotherModule)
exports[key] = anotherModule[key];
}
// port we are listening on. Set to null to disable accepting connections
// recommended port for livenet: 6655
// recommended port for testnet: 16655
exports.port = null;
//exports.port = 6655;
// 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;
// For better security you should not use local DNS with socks proxy
// exports.socksLocalDNS = false;
// WebSocket protocol prefixed to all hosts. Must be wss:// on livenet, ws:// is allowed on testnet
exports.WS_PROTOCOL = "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;
// storage engine: mysql or sqlite
exports.storage = 'sqlite';
if (process.browser){
exports.storage = 'sqlite';
exports.bLight = true;
}
exports.database = {};
/*
There are 3 ways to customize conf in modules that use trustnote-common 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('trustnote-common/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 window === 'undefined' || !window.cordova){ // 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 || 30;
exports.database.host = exports.database.host || 'localhost';
exports.database.name = exports.database.name || 'trustnote';
exports.database.user = exports.database.user || 'trustnote';
}
else if (exports.storage === 'sqlite'){
exports.database.max_connections = exports.database.max_connections || 1;
exports.database.filename = exports.database.filename || (exports.bLight ? 'trustnote-light.sqlite' : 'trustnote.sqlite');
}