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:
parent
fe6685468c
commit
61c0be77d5
|
@ -24,7 +24,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add new trip to config
|
// add new trip to config
|
||||||
|
|
|
@ -23,7 +23,7 @@ import {
|
||||||
export async function run({ server, socket }) {
|
export async function run({ server, socket }) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// find all users currently in a channel
|
// find all users currently in a channel
|
||||||
|
|
|
@ -22,7 +22,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do command reload and store results
|
// do command reload and store results
|
||||||
|
|
|
@ -24,7 +24,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trip from config
|
// remove trip from config
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {
|
||||||
export async function run({ core, server, socket }) {
|
export async function run({ core, server, socket }) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt save, notify of failure
|
// attempt save, notify of failure
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {
|
||||||
export async function run({ server, socket, payload }) {
|
export async function run({ server, socket, payload }) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send text to all channels
|
// send text to all channels
|
||||||
|
|
|
@ -30,7 +30,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
const { channel } = socket;
|
const { channel } = socket;
|
||||||
|
|
||||||
if (server.police.frisk(socket.address, 1)) {
|
if (server.police.frisk(socket, 1)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
cmd: 'warn', // @todo Add numeric error code as `id`
|
||||||
text: 'You are changing colors too fast. Wait a moment before trying again.',
|
text: 'You are changing colors too fast. Wait a moment before trying again.',
|
||||||
|
|
|
@ -24,7 +24,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
const { channel } = socket;
|
const { channel } = socket;
|
||||||
|
|
||||||
if (server.police.frisk(socket.address, 6)) {
|
if (server.police.frisk(socket, 6)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
cmd: 'warn', // @todo Add numeric error code as `id`
|
||||||
text: 'You are changing nicknames too fast. Wait a moment before trying again.',
|
text: 'You are changing nicknames too fast. Wait a moment before trying again.',
|
||||||
|
|
|
@ -88,12 +88,12 @@ export async function run({
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
// lets not send objects or empty text, yea?
|
// lets not send objects or empty text, yea?
|
||||||
return server.police.frisk(socket.address, 13);
|
return server.police.frisk(socket, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for spam
|
// check for spam
|
||||||
const score = text.length / 83 / 4;
|
const score = text.length / 83 / 4;
|
||||||
if (server.police.frisk(socket.address, score)) {
|
if (server.police.frisk(socket, score)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
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) {
|
if (typeof (customId) === 'string' && customId.length > MAX_MESSAGE_ID_LENGTH) {
|
||||||
// There's a limit on the custom 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
|
// build chat payload
|
||||||
|
|
|
@ -41,12 +41,12 @@ export async function run({ server, socket, payload }) {
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
// lets not send objects or empty text, yea?
|
// lets not send objects or empty text, yea?
|
||||||
return server.police.frisk(socket.address, 8);
|
return server.police.frisk(socket, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for spam
|
// check for spam
|
||||||
const score = text.length / 83 / 4;
|
const score = text.length / 83 / 4;
|
||||||
if (server.police.frisk(socket.address, score)) {
|
if (server.police.frisk(socket, score)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
|
||||||
|
|
|
@ -16,7 +16,7 @@ export async function run({
|
||||||
core, server, socket, payload,
|
core, server, socket, payload,
|
||||||
}) {
|
}) {
|
||||||
// check for spam
|
// check for spam
|
||||||
if (server.police.frisk(socket.address, 2)) {
|
if (server.police.frisk(socket, 2)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
|
||||||
|
|
|
@ -40,7 +40,7 @@ export async function run({
|
||||||
core, server, socket, payload,
|
core, server, socket, payload,
|
||||||
}) {
|
}) {
|
||||||
// check for spam
|
// check for spam
|
||||||
if (server.police.frisk(socket.address, 2)) {
|
if (server.police.frisk(socket, 2)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'You are sending invites too fast. Wait a moment before trying again.',
|
text: 'You are sending invites too fast. Wait a moment before trying again.',
|
||||||
|
|
|
@ -39,7 +39,7 @@ export async function run({
|
||||||
core, server, socket, payload,
|
core, server, socket, payload,
|
||||||
}) {
|
}) {
|
||||||
// check for spam
|
// check for spam
|
||||||
if (server.police.frisk(socket.address, 3)) {
|
if (server.police.frisk(socket, 3)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'You are joining channels too fast. Wait a moment and try again.',
|
text: 'You are joining channels too fast. Wait a moment and try again.',
|
||||||
|
|
|
@ -36,15 +36,15 @@ export async function run({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode !== 'overwrite' && mode !== 'append' && mode !== 'prepend' && mode !== 'complete') {
|
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) {
|
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') {
|
if (typeof (text) !== 'string') {
|
||||||
return server.police.frisk(socket.address, 13);
|
return server.police.frisk(socket, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === 'overwrite') {
|
if (mode === 'overwrite') {
|
||||||
|
@ -56,7 +56,7 @@ export async function run({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!text) {
|
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.
|
// 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) {
|
if (!message) {
|
||||||
return server.police.frisk(socket.address, 6);
|
return server.police.frisk(socket, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
const outgoingPayload = {
|
const outgoingPayload = {
|
||||||
|
|
|
@ -59,12 +59,12 @@ export async function run({ server, socket, payload }) {
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
// lets not send objects or empty text, yea?
|
// lets not send objects or empty text, yea?
|
||||||
return server.police.frisk(socket.address, 13);
|
return server.police.frisk(socket, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for spam
|
// check for spam
|
||||||
const score = text.length / 83 / 4;
|
const score = text.length / 83 / 4;
|
||||||
if (server.police.frisk(socket.address, score)) {
|
if (server.police.frisk(socket, score)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {
|
||||||
export async function run({ server, socket, payload }) {
|
export async function run({ server, socket, payload }) {
|
||||||
if (payload.cmdKey !== server.cmdKey) {
|
if (payload.cmdKey !== server.cmdKey) {
|
||||||
// internal command attempt by client, increase rate limit chance and ignore
|
// 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
|
// send leave notice to client peers
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
export async function run({ server, socket, payload }) {
|
export async function run({ server, socket, payload }) {
|
||||||
if (payload.cmdKey !== server.cmdKey) {
|
if (payload.cmdKey !== server.cmdKey) {
|
||||||
// internal command attempt by client, increase rate limit chance and ignore
|
// 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
|
// send warning to target socket
|
||||||
|
|
|
@ -29,7 +29,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
|
|
@ -34,7 +34,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
let targetChannel;
|
let targetChannel;
|
||||||
|
|
|
@ -82,7 +82,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
@ -205,7 +205,7 @@ export function chatCheck({
|
||||||
* May expose the ratelimiting lines from `chat` and use that
|
* May expose the ratelimiting lines from `chat` and use that
|
||||||
* @todo one day #lazydev
|
* @todo one day #lazydev
|
||||||
*/
|
*/
|
||||||
server.police.frisk(socket.address, 9);
|
server.police.frisk(socket, 9);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ export function inviteCheck({
|
||||||
}) {
|
}) {
|
||||||
if (core.muzzledHashes[socket.hash]) {
|
if (core.muzzledHashes[socket.hash]) {
|
||||||
// check for spam
|
// check for spam
|
||||||
if (server.police.frisk(socket.address, 2)) {
|
if (server.police.frisk(socket, 2)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'You are sending invites too fast. Wait a moment before trying again.',
|
text: 'You are sending invites too fast. Wait a moment before trying again.',
|
||||||
|
@ -308,12 +308,12 @@ export function whisperCheck({
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
// lets not send objects or empty text, yea?
|
// lets not send objects or empty text, yea?
|
||||||
return server.police.frisk(socket.address, 13);
|
return server.police.frisk(socket, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for spam
|
// check for spam
|
||||||
const score = text.length / 83 / 4;
|
const score = text.length / 83 / 4;
|
||||||
if (server.police.frisk(socket.address, score)) {
|
if (server.police.frisk(socket, score)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
|
||||||
|
|
|
@ -51,7 +51,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
let targetChannel;
|
let targetChannel;
|
||||||
|
@ -141,7 +141,7 @@ export function chatCheck({
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
server.police.frisk(socket.address, 7);
|
server.police.frisk(socket, 7);
|
||||||
socket.terminate();
|
socket.terminate();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -37,7 +37,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { channel } = socket;
|
const { channel } = socket;
|
||||||
|
|
|
@ -29,7 +29,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
|
|
@ -72,7 +72,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
let targetChannel;
|
let targetChannel;
|
||||||
|
|
|
@ -35,7 +35,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
|
|
@ -21,7 +21,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {
|
||||||
export async function run({ core, server, socket }) {
|
export async function run({ core, server, socket }) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove arrest records
|
// remove arrest records
|
||||||
|
|
|
@ -35,7 +35,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
let targetChannel;
|
let targetChannel;
|
||||||
|
|
|
@ -52,7 +52,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add new trip to config
|
// add new trip to config
|
||||||
|
|
|
@ -51,7 +51,7 @@ import {
|
||||||
export async function run({ server, socket }) {
|
export async function run({ server, socket }) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// find all users currently in a channel
|
// find all users currently in a channel
|
||||||
|
|
|
@ -50,7 +50,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do command reload and store results
|
// do command reload and store results
|
||||||
|
|
|
@ -52,7 +52,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trip from config
|
// remove trip from config
|
||||||
|
|
|
@ -48,7 +48,7 @@ import {
|
||||||
export async function run({ core, server, socket }) {
|
export async function run({ core, server, socket }) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt save, notify of failure
|
// attempt save, notify of failure
|
||||||
|
|
|
@ -47,7 +47,7 @@ import {
|
||||||
export async function run({ server, socket, payload }) {
|
export async function run({ server, socket, payload }) {
|
||||||
// increase rate limit chance and ignore if not admin
|
// increase rate limit chance and ignore if not admin
|
||||||
if (!isAdmin(socket.level)) {
|
if (!isAdmin(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 20);
|
return server.police.frisk(socket, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send text to all channels
|
// send text to all channels
|
||||||
|
|
|
@ -58,7 +58,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
const { channel } = socket;
|
const { channel } = socket;
|
||||||
|
|
||||||
if (server.police.frisk(socket.address, 1)) {
|
if (server.police.frisk(socket, 1)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
cmd: 'warn', // @todo Add numeric error code as `id`
|
||||||
text: 'You are changing colors too fast. Wait a moment before trying again.',
|
text: 'You are changing colors too fast. Wait a moment before trying again.',
|
||||||
|
|
|
@ -52,7 +52,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
const { channel } = socket;
|
const { channel } = socket;
|
||||||
|
|
||||||
if (server.police.frisk(socket.address, 6)) {
|
if (server.police.frisk(socket, 6)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
cmd: 'warn', // @todo Add numeric error code as `id`
|
||||||
text: 'You are changing nicknames too fast. Wait a moment before trying again.',
|
text: 'You are changing nicknames too fast. Wait a moment before trying again.',
|
||||||
|
@ -80,7 +80,7 @@ export async function run({
|
||||||
// prevent admin impersonation
|
// prevent admin impersonation
|
||||||
// @todo prevent mod impersonation
|
// @todo prevent mod impersonation
|
||||||
if (newNick.toLowerCase() === core.config.adminName.toLowerCase()) {
|
if (newNick.toLowerCase() === core.config.adminName.toLowerCase()) {
|
||||||
server.police.frisk(socket.address, 4);
|
server.police.frisk(socket, 4);
|
||||||
|
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
cmd: 'warn', // @todo Add numeric error code as `id`
|
||||||
|
|
|
@ -76,12 +76,12 @@ export async function run({
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
// lets not send objects or empty text, yea?
|
// lets not send objects or empty text, yea?
|
||||||
return server.police.frisk(socket.address, 13);
|
return server.police.frisk(socket, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for spam
|
// check for spam
|
||||||
const score = text.length / 83 / 4;
|
const score = text.length / 83 / 4;
|
||||||
if (server.police.frisk(socket.address, score)) {
|
if (server.police.frisk(socket, score)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
|
||||||
|
|
|
@ -69,12 +69,12 @@ export async function run({ server, socket, payload }) {
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
// lets not send objects or empty text, yea?
|
// lets not send objects or empty text, yea?
|
||||||
return server.police.frisk(socket.address, 8);
|
return server.police.frisk(socket, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for spam
|
// check for spam
|
||||||
const score = text.length / 83 / 4;
|
const score = text.length / 83 / 4;
|
||||||
if (server.police.frisk(socket.address, score)) {
|
if (server.police.frisk(socket, score)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
|
||||||
|
|
|
@ -44,7 +44,7 @@ export async function run({
|
||||||
core, server, socket, payload,
|
core, server, socket, payload,
|
||||||
}) {
|
}) {
|
||||||
// check for spam
|
// check for spam
|
||||||
if (server.police.frisk(socket.address, 2)) {
|
if (server.police.frisk(socket, 2)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
|
||||||
|
|
|
@ -68,7 +68,7 @@ export async function run({
|
||||||
core, server, socket, payload,
|
core, server, socket, payload,
|
||||||
}) {
|
}) {
|
||||||
// check for spam
|
// check for spam
|
||||||
if (server.police.frisk(socket.address, 2)) {
|
if (server.police.frisk(socket, 2)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'You are sending invites too fast. Wait a moment before trying again.',
|
text: 'You are sending invites too fast. Wait a moment before trying again.',
|
||||||
|
|
|
@ -63,7 +63,7 @@ export async function run({
|
||||||
core, server, socket, payload,
|
core, server, socket, payload,
|
||||||
}) {
|
}) {
|
||||||
// check for spam
|
// check for spam
|
||||||
if (server.police.frisk(socket.address, 3)) {
|
if (server.police.frisk(socket, 3)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'You are joining channels too fast. Wait a moment and try again.',
|
text: 'You are joining channels too fast. Wait a moment and try again.',
|
||||||
|
|
|
@ -87,12 +87,12 @@ export async function run({ server, socket, payload }) {
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
// lets not send objects or empty text, yea?
|
// lets not send objects or empty text, yea?
|
||||||
return server.police.frisk(socket.address, 13);
|
return server.police.frisk(socket, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for spam
|
// check for spam
|
||||||
const score = text.length / 83 / 4;
|
const score = text.length / 83 / 4;
|
||||||
if (server.police.frisk(socket.address, score)) {
|
if (server.police.frisk(socket, score)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
export async function run({ server, socket, payload }) {
|
export async function run({ server, socket, payload }) {
|
||||||
if (payload.cmdKey !== server.cmdKey) {
|
if (payload.cmdKey !== server.cmdKey) {
|
||||||
// internal command attempt by client, increase rate limit chance and ignore
|
// 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
|
// send leave notice to client peers
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
export async function run({ server, socket, payload }) {
|
export async function run({ server, socket, payload }) {
|
||||||
if (payload.cmdKey !== server.cmdKey) {
|
if (payload.cmdKey !== server.cmdKey) {
|
||||||
// internal command attempt by client, increase rate limit chance and ignore
|
// 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
|
// send warning to target socket
|
||||||
|
|
|
@ -57,7 +57,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
|
|
@ -110,7 +110,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
@ -233,7 +233,7 @@ export function chatCheck({
|
||||||
* May expose the ratelimiting lines from `chat` and use that
|
* May expose the ratelimiting lines from `chat` and use that
|
||||||
* @todo one day #lazydev
|
* @todo one day #lazydev
|
||||||
*/
|
*/
|
||||||
server.police.frisk(socket.address, 9);
|
server.police.frisk(socket, 9);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ export function inviteCheck({
|
||||||
}) {
|
}) {
|
||||||
if (core.muzzledHashes[socket.hash]) {
|
if (core.muzzledHashes[socket.hash]) {
|
||||||
// check for spam
|
// check for spam
|
||||||
if (server.police.frisk(socket.address, 2)) {
|
if (server.police.frisk(socket, 2)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn',
|
cmd: 'warn',
|
||||||
text: 'You are sending invites too fast. Wait a moment before trying again.',
|
text: 'You are sending invites too fast. Wait a moment before trying again.',
|
||||||
|
@ -336,12 +336,12 @@ export function whisperCheck({
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
// lets not send objects or empty text, yea?
|
// lets not send objects or empty text, yea?
|
||||||
return server.police.frisk(socket.address, 13);
|
return server.police.frisk(socket, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for spam
|
// check for spam
|
||||||
const score = text.length / 83 / 4;
|
const score = text.length / 83 / 4;
|
||||||
if (server.police.frisk(socket.address, score)) {
|
if (server.police.frisk(socket, score)) {
|
||||||
return server.reply({
|
return server.reply({
|
||||||
cmd: 'warn', // @todo Add numeric error code as `id`
|
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.',
|
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.',
|
||||||
|
|
|
@ -65,7 +65,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { channel } = socket;
|
const { channel } = socket;
|
||||||
|
|
|
@ -57,7 +57,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
|
|
@ -63,7 +63,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
|
|
@ -49,7 +49,7 @@ export async function run({
|
||||||
}) {
|
}) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
|
|
|
@ -47,7 +47,7 @@ import {
|
||||||
export async function run({ core, server, socket }) {
|
export async function run({ core, server, socket }) {
|
||||||
// increase rate limit chance and ignore if not admin or mod
|
// increase rate limit chance and ignore if not admin or mod
|
||||||
if (!isModerator(socket.level)) {
|
if (!isModerator(socket.level)) {
|
||||||
return server.police.frisk(socket.address, 10);
|
return server.police.frisk(socket, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove arrest records
|
// remove arrest records
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ascii-captcha": "^0.0.3",
|
"ascii-captcha": "^0.0.3",
|
||||||
"enquirer": "^2.3.6",
|
"enquirer": "^2.3.6",
|
||||||
"hackchat-server": "^2.2.27",
|
"hackchat-server": "^2.3.0",
|
||||||
"http-server": "^14.1.0",
|
"http-server": "^14.1.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"lowdb": "^3.0.0",
|
"lowdb": "^3.0.0",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user