1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00

hackchat-server 2.3 update

This commit is contained in:
marzavec 2023-12-27 00:26:49 -08:00
parent fe6685468c
commit 61c0be77d5
52 changed files with 73 additions and 73 deletions

View File

@ -24,7 +24,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// add new trip to config

View File

@ -23,7 +23,7 @@ import {
export async function run({ server, socket }) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// find all users currently in a channel

View File

@ -22,7 +22,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// do command reload and store results

View File

@ -24,7 +24,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// remove trip from config

View File

@ -20,7 +20,7 @@ import {
export async function run({ core, server, socket }) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// attempt save, notify of failure

View File

@ -19,7 +19,7 @@ import {
export async function run({ server, socket, payload }) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// send text to all channels

View File

@ -30,7 +30,7 @@ export async function run({
}) {
const { channel } = socket;
if (server.police.frisk(socket.address, 1)) {
if (server.police.frisk(socket, 1)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are changing colors too fast. Wait a moment before trying again.',

View File

@ -24,7 +24,7 @@ export async function run({
}) {
const { channel } = socket;
if (server.police.frisk(socket.address, 6)) {
if (server.police.frisk(socket, 6)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are changing nicknames too fast. Wait a moment before trying again.',

View File

@ -88,12 +88,12 @@ export async function run({
if (!text) {
// lets not send objects or empty text, yea?
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
// check for spam
const score = text.length / 83 / 4;
if (server.police.frisk(socket.address, score)) {
if (server.police.frisk(socket, score)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
@ -105,7 +105,7 @@ export async function run({
if (typeof (customId) === 'string' && customId.length > MAX_MESSAGE_ID_LENGTH) {
// There's a limit on the custom id length.
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
// build chat payload

View File

@ -41,12 +41,12 @@ export async function run({ server, socket, payload }) {
if (!text) {
// lets not send objects or empty text, yea?
return server.police.frisk(socket.address, 8);
return server.police.frisk(socket, 8);
}
// check for spam
const score = text.length / 83 / 4;
if (server.police.frisk(socket.address, score)) {
if (server.police.frisk(socket, score)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',

View File

@ -16,7 +16,7 @@ export async function run({
core, server, socket, payload,
}) {
// check for spam
if (server.police.frisk(socket.address, 2)) {
if (server.police.frisk(socket, 2)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',

View File

@ -40,7 +40,7 @@ export async function run({
core, server, socket, payload,
}) {
// check for spam
if (server.police.frisk(socket.address, 2)) {
if (server.police.frisk(socket, 2)) {
return server.reply({
cmd: 'warn',
text: 'You are sending invites too fast. Wait a moment before trying again.',

View File

@ -39,7 +39,7 @@ export async function run({
core, server, socket, payload,
}) {
// check for spam
if (server.police.frisk(socket.address, 3)) {
if (server.police.frisk(socket, 3)) {
return server.reply({
cmd: 'warn',
text: 'You are joining channels too fast. Wait a moment and try again.',

View File

@ -36,15 +36,15 @@ export async function run({
}
if (mode !== 'overwrite' && mode !== 'append' && mode !== 'prepend' && mode !== 'complete') {
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
if (!customId || typeof customId !== 'string' || customId.length > MAX_MESSAGE_ID_LENGTH) {
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
if (typeof (text) !== 'string') {
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
if (mode === 'overwrite') {
@ -56,7 +56,7 @@ export async function run({
}
if (!text) {
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
// TODO: What score should we use for this? It isn't as space filling as chat messages.
@ -77,7 +77,7 @@ export async function run({
}
if (!message) {
return server.police.frisk(socket.address, 6);
return server.police.frisk(socket, 6);
}
const outgoingPayload = {

View File

@ -59,12 +59,12 @@ export async function run({ server, socket, payload }) {
if (!text) {
// lets not send objects or empty text, yea?
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
// check for spam
const score = text.length / 83 / 4;
if (server.police.frisk(socket.address, score)) {
if (server.police.frisk(socket, score)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',

View File

@ -19,7 +19,7 @@ import {
export async function run({ server, socket, payload }) {
if (payload.cmdKey !== server.cmdKey) {
// internal command attempt by client, increase rate limit chance and ignore
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// send leave notice to client peers

View File

@ -16,7 +16,7 @@
export async function run({ server, socket, payload }) {
if (payload.cmdKey !== server.cmdKey) {
// internal command attempt by client, increase rate limit chance and ignore
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// send warning to target socket

View File

@ -29,7 +29,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input

View File

@ -34,7 +34,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
let targetChannel;

View File

@ -82,7 +82,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input
@ -205,7 +205,7 @@ export function chatCheck({
* May expose the ratelimiting lines from `chat` and use that
* @todo one day #lazydev
*/
server.police.frisk(socket.address, 9);
server.police.frisk(socket, 9);
return false;
}
@ -227,7 +227,7 @@ export function inviteCheck({
}) {
if (core.muzzledHashes[socket.hash]) {
// check for spam
if (server.police.frisk(socket.address, 2)) {
if (server.police.frisk(socket, 2)) {
return server.reply({
cmd: 'warn',
text: 'You are sending invites too fast. Wait a moment before trying again.',
@ -308,12 +308,12 @@ export function whisperCheck({
if (!text) {
// lets not send objects or empty text, yea?
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
// check for spam
const score = text.length / 83 / 4;
if (server.police.frisk(socket.address, score)) {
if (server.police.frisk(socket, score)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',

View File

@ -51,7 +51,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
let targetChannel;
@ -141,7 +141,7 @@ export function chatCheck({
return false;
}
server.police.frisk(socket.address, 7);
server.police.frisk(socket, 7);
socket.terminate();
return false;

View File

@ -37,7 +37,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
const { channel } = socket;

View File

@ -29,7 +29,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input

View File

@ -72,7 +72,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
let targetChannel;

View File

@ -35,7 +35,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input

View File

@ -21,7 +21,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input

View File

@ -19,7 +19,7 @@ import {
export async function run({ core, server, socket }) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// remove arrest records

View File

@ -35,7 +35,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
let targetChannel;

View File

@ -52,7 +52,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// add new trip to config

View File

@ -51,7 +51,7 @@ import {
export async function run({ server, socket }) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// find all users currently in a channel

View File

@ -50,7 +50,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// do command reload and store results

View File

@ -52,7 +52,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// remove trip from config

View File

@ -48,7 +48,7 @@ import {
export async function run({ core, server, socket }) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// attempt save, notify of failure

View File

@ -47,7 +47,7 @@ import {
export async function run({ server, socket, payload }) {
// increase rate limit chance and ignore if not admin
if (!isAdmin(socket.level)) {
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// send text to all channels

View File

@ -58,7 +58,7 @@ export async function run({
}) {
const { channel } = socket;
if (server.police.frisk(socket.address, 1)) {
if (server.police.frisk(socket, 1)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are changing colors too fast. Wait a moment before trying again.',

View File

@ -52,7 +52,7 @@ export async function run({
}) {
const { channel } = socket;
if (server.police.frisk(socket.address, 6)) {
if (server.police.frisk(socket, 6)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are changing nicknames too fast. Wait a moment before trying again.',
@ -80,7 +80,7 @@ export async function run({
// prevent admin impersonation
// @todo prevent mod impersonation
if (newNick.toLowerCase() === core.config.adminName.toLowerCase()) {
server.police.frisk(socket.address, 4);
server.police.frisk(socket, 4);
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`

View File

@ -76,12 +76,12 @@ export async function run({
if (!text) {
// lets not send objects or empty text, yea?
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
// check for spam
const score = text.length / 83 / 4;
if (server.police.frisk(socket.address, score)) {
if (server.police.frisk(socket, score)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',

View File

@ -69,12 +69,12 @@ export async function run({ server, socket, payload }) {
if (!text) {
// lets not send objects or empty text, yea?
return server.police.frisk(socket.address, 8);
return server.police.frisk(socket, 8);
}
// check for spam
const score = text.length / 83 / 4;
if (server.police.frisk(socket.address, score)) {
if (server.police.frisk(socket, score)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',

View File

@ -44,7 +44,7 @@ export async function run({
core, server, socket, payload,
}) {
// check for spam
if (server.police.frisk(socket.address, 2)) {
if (server.police.frisk(socket, 2)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',

View File

@ -68,7 +68,7 @@ export async function run({
core, server, socket, payload,
}) {
// check for spam
if (server.police.frisk(socket.address, 2)) {
if (server.police.frisk(socket, 2)) {
return server.reply({
cmd: 'warn',
text: 'You are sending invites too fast. Wait a moment before trying again.',

View File

@ -63,7 +63,7 @@ export async function run({
core, server, socket, payload,
}) {
// check for spam
if (server.police.frisk(socket.address, 3)) {
if (server.police.frisk(socket, 3)) {
return server.reply({
cmd: 'warn',
text: 'You are joining channels too fast. Wait a moment and try again.',

View File

@ -87,12 +87,12 @@ export async function run({ server, socket, payload }) {
if (!text) {
// lets not send objects or empty text, yea?
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
// check for spam
const score = text.length / 83 / 4;
if (server.police.frisk(socket.address, score)) {
if (server.police.frisk(socket, score)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',

View File

@ -43,7 +43,7 @@
export async function run({ server, socket, payload }) {
if (payload.cmdKey !== server.cmdKey) {
// internal command attempt by client, increase rate limit chance and ignore
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// send leave notice to client peers

View File

@ -44,7 +44,7 @@
export async function run({ server, socket, payload }) {
if (payload.cmdKey !== server.cmdKey) {
// internal command attempt by client, increase rate limit chance and ignore
return server.police.frisk(socket.address, 20);
return server.police.frisk(socket, 20);
}
// send warning to target socket

View File

@ -57,7 +57,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input

View File

@ -110,7 +110,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input
@ -233,7 +233,7 @@ export function chatCheck({
* May expose the ratelimiting lines from `chat` and use that
* @todo one day #lazydev
*/
server.police.frisk(socket.address, 9);
server.police.frisk(socket, 9);
return false;
}
@ -255,7 +255,7 @@ export function inviteCheck({
}) {
if (core.muzzledHashes[socket.hash]) {
// check for spam
if (server.police.frisk(socket.address, 2)) {
if (server.police.frisk(socket, 2)) {
return server.reply({
cmd: 'warn',
text: 'You are sending invites too fast. Wait a moment before trying again.',
@ -336,12 +336,12 @@ export function whisperCheck({
if (!text) {
// lets not send objects or empty text, yea?
return server.police.frisk(socket.address, 13);
return server.police.frisk(socket, 13);
}
// check for spam
const score = text.length / 83 / 4;
if (server.police.frisk(socket.address, score)) {
if (server.police.frisk(socket, score)) {
return server.reply({
cmd: 'warn', // @todo Add numeric error code as `id`
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',

View File

@ -65,7 +65,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
const { channel } = socket;

View File

@ -57,7 +57,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input

View File

@ -63,7 +63,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input

View File

@ -49,7 +49,7 @@ export async function run({
}) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// check user input

View File

@ -47,7 +47,7 @@ import {
export async function run({ core, server, socket }) {
// increase rate limit chance and ignore if not admin or mod
if (!isModerator(socket.level)) {
return server.police.frisk(socket.address, 10);
return server.police.frisk(socket, 10);
}
// remove arrest records

View File

@ -32,7 +32,7 @@
"dependencies": {
"ascii-captcha": "^0.0.3",
"enquirer": "^2.3.6",
"hackchat-server": "^2.2.27",
"hackchat-server": "^2.3.0",
"http-server": "^14.1.0",
"jsonwebtoken": "^9.0.2",
"lowdb": "^3.0.0",