Merge branch 'master' of ssh://numinibsd/git/base/enigma-bbs
This commit is contained in:
commit
e4c0e04535
|
@ -47,10 +47,11 @@ function getFontNameFromSAUCE(sauce) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sliceAtEOF(data, eofMarker) {
|
function sliceAtEOF(data, eofMarker) {
|
||||||
var eof = data.length;
|
let eof = data.length;
|
||||||
// :TODO: max scan back or other beter way of doing this?!
|
const stopPos = Math.max(data.length - (256), 0); // 256 = 2 * sizeof(SAUCE)
|
||||||
for(var i = data.length - 1; i > 0; i--) {
|
|
||||||
if(data[i] === eofMarker) {
|
for(let i = eof - 1; i > stopPos; i--) {
|
||||||
|
if(eofMarker === data[i]) {
|
||||||
eof = i;
|
eof = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ function getDefaultConfig() {
|
||||||
users : {
|
users : {
|
||||||
usernameMin : 2,
|
usernameMin : 2,
|
||||||
usernameMax : 16, // Note that FidoNet wants 36 max
|
usernameMax : 16, // Note that FidoNet wants 36 max
|
||||||
usernamePattern : '^[A-Za-z0-9~!@#$%^&*()\\-\\_+]+$',
|
usernamePattern : '^[A-Za-z0-9~!@#$%^&*()\\-\\_+ ]+$',
|
||||||
|
|
||||||
passwordMin : 6,
|
passwordMin : 6,
|
||||||
passwordMax : 128,
|
passwordMax : 128,
|
||||||
|
|
|
@ -50,6 +50,15 @@ class StatLog {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get KeepType() {
|
||||||
|
return {
|
||||||
|
Forever : 'forever',
|
||||||
|
Days : 'days',
|
||||||
|
Max : 'max',
|
||||||
|
Count : 'max',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
get Order() {
|
get Order() {
|
||||||
return {
|
return {
|
||||||
Timestamp : 'timestamp_asc',
|
Timestamp : 'timestamp_asc',
|
||||||
|
@ -57,7 +66,7 @@ class StatLog {
|
||||||
TimestampDesc : 'timestamp_desc',
|
TimestampDesc : 'timestamp_desc',
|
||||||
Random : 'random',
|
Random : 'random',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setNonPeristentSystemStat(statName, statValue) {
|
setNonPeristentSystemStat(statName, statValue) {
|
||||||
this.systemStats[statName] = statValue;
|
this.systemStats[statName] = statValue;
|
||||||
|
@ -129,33 +138,64 @@ class StatLog {
|
||||||
// the time "now" in the ISO format we use and love :)
|
// the time "now" in the ISO format we use and love :)
|
||||||
get now() { return moment().format('YYYY-MM-DDTHH:mm:ss.SSSZ'); }
|
get now() { return moment().format('YYYY-MM-DDTHH:mm:ss.SSSZ'); }
|
||||||
|
|
||||||
appendSystemLogEntry(logName, logValue, keepDays, cb) {
|
appendSystemLogEntry(logName, logValue, keep, keepType, cb) {
|
||||||
sysDb.run(
|
sysDb.run(
|
||||||
`INSERT INTO system_event_log (timestamp, log_name, log_value)
|
`INSERT INTO system_event_log (timestamp, log_name, log_value)
|
||||||
VALUES (?, ?, ?);`,
|
VALUES (?, ?, ?);`,
|
||||||
[ this.now, logName, logValue ],
|
[ this.now, logName, logValue ],
|
||||||
() => {
|
() => {
|
||||||
//
|
//
|
||||||
// Handle keepDays
|
// Handle keep
|
||||||
//
|
//
|
||||||
if(-1 === keepDays) {
|
if(-1 === keep) {
|
||||||
if(cb) {
|
if(cb) {
|
||||||
return cb(null);
|
return cb(null);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sysDb.run(
|
switch(keepType) {
|
||||||
`DELETE FROM system_event_log
|
// keep # of days
|
||||||
WHERE log_name = ? AND timestamp <= DATETIME("now", "-${keepDays} day");`,
|
case 'days' :
|
||||||
[ logName ],
|
sysDb.run(
|
||||||
err => {
|
`DELETE FROM system_event_log
|
||||||
// cb optional - callers may fire & forget
|
WHERE log_name = ? AND timestamp <= DATETIME("now", "-${keep} day");`,
|
||||||
if(cb) {
|
[ logName ],
|
||||||
return cb(err);
|
err => {
|
||||||
}
|
// cb optional - callers may fire & forget
|
||||||
}
|
if(cb) {
|
||||||
);
|
return cb(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'count':
|
||||||
|
case 'max' :
|
||||||
|
// keep max of N/count
|
||||||
|
sysDb.run(
|
||||||
|
`DELETE FROM system_event_log
|
||||||
|
WHERE id IN(
|
||||||
|
SELECT id
|
||||||
|
FROM system_event_log
|
||||||
|
WHERE log_name = ?
|
||||||
|
ORDER BY id DESC
|
||||||
|
LIMIT -1 OFFSET ${keep}
|
||||||
|
);`,
|
||||||
|
[ logName ],
|
||||||
|
err => {
|
||||||
|
if(cb) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'forever' :
|
||||||
|
default :
|
||||||
|
// nop
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ function validateUserNameAvail(data, cb) {
|
||||||
} else {
|
} else {
|
||||||
user.getUserIdAndName(data, function userIdAndName(err) {
|
user.getUserIdAndName(data, function userIdAndName(err) {
|
||||||
if(!err) { // err is null if we succeeded -- meaning this user exists already
|
if(!err) { // err is null if we succeeded -- meaning this user exists already
|
||||||
return cb(new Error('Userame unavailable'));
|
return cb(new Error('Username unavailable'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return cb(null);
|
return cb(null);
|
||||||
|
|
|
@ -73,7 +73,8 @@ function userLogin(client, username, password, cb) {
|
||||||
StatLog.incrementUserStat(user, 'login_count', 1, callback);
|
StatLog.incrementUserStat(user, 'login_count', 1, callback);
|
||||||
},
|
},
|
||||||
function recordLoginHistory(callback) {
|
function recordLoginHistory(callback) {
|
||||||
StatLog.appendSystemLogEntry('user_login_history', user.userId, 30, callback);
|
const LOGIN_HISTORY_MAX = 200; // history of up to last 200 callers
|
||||||
|
StatLog.appendSystemLogEntry('user_login_history', user.userId, LOGIN_HISTORY_MAX, StatLog.KeepType.Max, callback);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
function complete(err) {
|
function complete(err) {
|
||||||
|
|
|
@ -48,6 +48,9 @@ enigma_install_init() {
|
||||||
|
|
||||||
log "Checking curl installation"
|
log "Checking curl installation"
|
||||||
enigma_install_needs curl
|
enigma_install_needs curl
|
||||||
|
|
||||||
|
log "Checking Python installation"
|
||||||
|
enigma_install_needs python
|
||||||
}
|
}
|
||||||
|
|
||||||
install_nvm() {
|
install_nvm() {
|
||||||
|
@ -90,6 +93,7 @@ install_node_packages() {
|
||||||
log "npm package installation complete"
|
log "npm package installation complete"
|
||||||
else
|
else
|
||||||
log_error "Failed to install ENiGMA½ npm packages. Please report this!"
|
log_error "Failed to install ENiGMA½ npm packages. Please report this!"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,15 +67,29 @@ LastCallersModule.prototype.mciReady = function(mciData, cb) {
|
||||||
function fetchHistory(callback) {
|
function fetchHistory(callback) {
|
||||||
callersView = vc.getView(MciCodeIds.CallerList);
|
callersView = vc.getView(MciCodeIds.CallerList);
|
||||||
|
|
||||||
StatLog.getSystemLogEntries('user_login_history', StatLog.Order.TimestampDesc, callersView.dimens.height, (err, lh) => {
|
// fetch up
|
||||||
|
StatLog.getSystemLogEntries('user_login_history', StatLog.Order.TimestampDesc, 200, (err, lh) => {
|
||||||
loginHistory = lh;
|
loginHistory = lh;
|
||||||
|
|
||||||
if(self.menuConfig.config.hideSysOpLogin) {
|
if(self.menuConfig.config.hideSysOpLogin) {
|
||||||
loginHistory = loginHistory.filter(lh => {
|
const noOpLoginHistory = loginHistory.filter(lh => {
|
||||||
return false === isRootUserId(parseInt(lh.log_value)); // log_value=userId
|
return false === isRootUserId(parseInt(lh.log_value)); // log_value=userId
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// If we have enough items to display, or hideSysOpLogin is set to 'always',
|
||||||
|
// then set loginHistory to our filtered list. Else, we'll leave it be.
|
||||||
|
//
|
||||||
|
if(noOpLoginHistory.length >= callersView.dimens.height || 'always' === self.menuConfig.config.hideSysOpLogin) {
|
||||||
|
loginHistory = noOpLoginHistory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Finally, we need to trim up the list to the needed size
|
||||||
|
//
|
||||||
|
loginHistory = loginHistory.slice(0, callersView.dimens.height);
|
||||||
|
|
||||||
return callback(err);
|
return callback(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -52,7 +52,7 @@ exports.getModule = class RumorzModule extends MenuModule {
|
||||||
if(_.isString(formData.value.rumor) && renderStringLength(formData.value.rumor) > 0) {
|
if(_.isString(formData.value.rumor) && renderStringLength(formData.value.rumor) > 0) {
|
||||||
const rumor = formData.value.rumor.trim(); // remove any trailing ws
|
const rumor = formData.value.rumor.trim(); // remove any trailing ws
|
||||||
|
|
||||||
StatLog.appendSystemLogEntry(STATLOG_KEY_RUMORZ, rumor, StatLog.KeepDays.Forever, () => {
|
StatLog.appendSystemLogEntry(STATLOG_KEY_RUMORZ, rumor, StatLog.KeepDays.Forever, StatLog.KeepType.Forever, () => {
|
||||||
this.clearAddForm();
|
this.clearAddForm();
|
||||||
return this.displayViewScreen(true, cb); // true=cls
|
return this.displayViewScreen(true, cb); // true=cls
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue