Improved daily check with configuration parameters

This commit is contained in:
Ludovic Dubost 2020-11-29 20:55:20 +01:00
parent 83b98a2a30
commit 825820f6bf
5 changed files with 92 additions and 18 deletions

View File

@ -141,6 +141,8 @@ module.exports = {
/* CryptPad will display a point of contact for your instance on its contact page
* (/contact.html) if you provide it below.
* This email will also be sent to the CryptPad Team as part of the daily check unless you
* set the blockAdminEmail parameter.
*/
adminEmail: 'i.did.not.read.my.config@cryptpad.fr',
@ -148,11 +150,64 @@ module.exports = {
* By default, CryptPad contacts one of our servers once a day.
* This check-in will also send some very basic information about your instance including its
* version and the adminEmail so we can reach you if we are aware of a serious problem.
* We will never sell it or send you marketing mail.
*
*
* If you want to block this check-in and remain set 'blockDailyCheck' to true.
* If you want to send the daily check but without the administrator email set 'blockAdminEmail' to true
* If you want to send the daily check but without instance statistical information set 'blockStats' to true
*
* These information allows the CryptPad Team to count how many instances are running including by country
* It also allows to estimate the number of users of CryptPad instances around the world.
* We will use the aggregated information in order to promote CryptPad and encourage more use of it.
*
* We will never sell it or send you marketing mail.
*
* In case you would like your data to be deleted, you can contact the CryptPad Team at privacy@cryptpad.fr
*/
//blockDailyCheck: false,
//blockAdminEmail: false,
//blockStats: false,
/*
* By default the information sent with the daily check will NOT be published
* and is kept only by the CryptPad development team
* If you would like to publish this information and be listed in the directory
* at https://cryptpad.fr/servers/ please set the following value to "true"
* and update the information below that are being sent
*/
//serverPublish: false,
/*
*
* By default the statistical information sent with the daily check will NOT be published
* and is kept only by the CryptPad development team
* If you would like to publish this information in the directory
* at https://cryptpad.fr/servers/ please set the following value to "true"
* and update the information below that are being sent
*/
//serverStatsPublish: false,
/*
* In case you would like you instance to be published in the directory of CryptPad instances
* You should provide a name of your instance.
*
* For this update the information below
*/
//serverName: "noname",
/*
* In case you would like you instance to be published in the directory of CryptPad instances
* You should provide a description of your instance.
*
* For this update the information below
*/
//serverDesc: "no description provided",
/*
* Wether the Server is open for registration or private
* It should be one of: open, private, unknown
*/
//serverType: "unknown",
/*
* By default users get 50MB of storage by registering on an instance.

View File

@ -66,20 +66,31 @@ var queryAccountServer = function (Env, cb) {
console.log("DEBUG: query account server");
var done = Util.once(Util.mkAsync(cb));
var body = JSON.stringify({
domain: Env.myDomain,
subdomain: Env.mySubdomain,
adminEmail: Env.adminEmail,
var data = {
protocol: "2.0",
uuid: Env.Stats.stats.uuid,
url: Env.serverUrl,
adminEmail: "",
version: Package.version,
name: Env.serverName,
desc: Env.serverDesc,
type: Env.serverType,
publish: Env.serverPublish,
registeredUsers: Env.Stats.stats.registeredUsers,
maxOpenUniqueWebSockets: Env.Stats.stats.maxOpenUniqueWebSockets,
maxOpenWebSockets: Env.Stats.stats.maxOpenWebSockets,
openPadsSinceLastPing: Env.Stats.stats.openPadsSinceLastPing,
newPadsSinceLastPing: Env.Stats.stats.newPadsSinceLastPing
});
publishStats: Env.serverStatsPublish
}
if (!Env.blockAdminEmail) {
data.adminEmail = Env.adminEmail;
}
// We should not send statistics if the config says not to
if (!Env.blockStats) {
data.registeredUsers = Env.Stats.stats.registeredUsers;
data.maxOpenUniqueWebSockets = Env.Stats.stats.maxOpenUniqueWebSockets;
data.maxOpenWebSockets = Env.Stats.stats.maxOpenWebSockets;
data.openPadsSinceLastPing = Env.Stats.stats.openPadsSinceLastPing;
data.newPadsSinceLastPing = Env.Stats.stats.newPadsSinceLastPing;
}
var body = JSON.stringify(data);
var options = {
host: 'devaccounts.cryptpad.fr',
port: 5001,

View File

@ -39,9 +39,13 @@ module.exports.create = function (config) {
// TODO implement mutability
adminEmail: config.adminEmail,
supportMailbox: config.supportMailboxPublicKey,
serverDesc: config.serverDesc,
serverType: config.serverType,
serverPublish: config.serverPublish,
serverUrl: config.httpUnsafeOrigin,
serverName: config.serverName || "noname",
serverDesc: config.serverDesc || "no description provided",
serverType: config.serverType || "unknown",
serverPublish: config.serverPublish || false,
serverStatsPublish: config.serverPublish || false,
metadata_cache: {},
channel_cache: {},
@ -84,6 +88,8 @@ module.exports.create = function (config) {
allowSubscriptions: config.allowSubscriptions === true,
blockDailyCheck: config.blockDailyCheck === true,
blockAdminEmail: config.blockAdminEmail === true,
blockStats: config.blockDailyCheck === true,
myDomain: config.myDomain,
mySubdomain: config.mySubdomain, // only exists for the accounts integration

View File

@ -2,12 +2,12 @@
const Fs = require('fs');
const nThen = require("nthen");
const Admin = require("./commands/admin-rpc");
const uuid = require("uuid");
module.exports.create = function (Env) {
Env.Stats = {
stats : { registeredUsers : 0, maxOpenWebSockets : 0, maxOpenUniqueWebSockets: 0,
openPadsSinceLastPing : 0, newPadsSinceLastPing : 0 },
stats : {},
getStats: function() {
return stats;
@ -89,7 +89,8 @@ module.exports.create = function (Env) {
} catch (e) {
this.stats = { registeredUsers : 0, maxOpenWebSockets : 0, maxOpenUniqueWebSockets: 0,
openPadsSinceLastPing : 0, newPadsSinceLastPing : 0 }
this.saveStats();
this.stats.uuid = uuid.v4();
this.saveStats(Env);
}
this.getRegisteredUsers(Env, function(nbRegs) {
@ -100,7 +101,7 @@ module.exports.create = function (Env) {
},
updateStats: function(Env) {
if (Env.Server) {
if (Env && Env.Server) {
var sessionStats = Env.Server.getSessionStats();
console.log("DEBUG: Current connections: ", sessionStats.total);
console.log("DEBUG: Current unique connections: ", sessionStats.unique);

View File

@ -26,6 +26,7 @@
"stream-to-pull-stream": "^1.7.2",
"tweetnacl": "~0.12.2",
"ulimit": "0.0.2",
"uuid": "^8.3.1",
"ws": "^3.3.1"
},
"devDependencies": {