summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--api/LICENSE14
-rw-r--r--api/crowdin.yml3
-rw-r--r--api/package.json2
-rw-r--r--api/src/middlewares/RateLimit.ts13
-rw-r--r--cdn/CONTRIBUTE.md18
-rw-r--r--cdn/package.json4
-rw-r--r--dashboard/LICENSE14
-rw-r--r--dashboard/package.json4
-rw-r--r--gateway/LICENSE14
-rw-r--r--gateway/client.js51
-rw-r--r--gateway/package.json2
-rw-r--r--package.json17
-rw-r--r--rtc/LICENSE14
-rw-r--r--util/LICENSE14
-rw-r--r--util/package.json2
-rw-r--r--util/src/entities/Channel.ts2
-rw-r--r--util/src/entities/Message.ts4
-rw-r--r--util/src/util/Constants.ts1
-rw-r--r--util/src/util/Token.ts7
-rw-r--r--webrtc/LICENSE14
-rw-r--r--webrtc/package.json4
21 files changed, 47 insertions, 171 deletions
diff --git a/api/LICENSE b/api/LICENSE
deleted file mode 100644

index f19bf520..00000000 --- a/api/LICENSE +++ /dev/null
@@ -1,14 +0,0 @@ -Copyright (C) 2021 Fosscord and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. \ No newline at end of file diff --git a/api/crowdin.yml b/api/crowdin.yml deleted file mode 100644
index 7228117f..00000000 --- a/api/crowdin.yml +++ /dev/null
@@ -1,3 +0,0 @@ -files: - - source: /locales/en/*.json - translation: /locales/%two_letters_code%/%original_file_name% diff --git a/api/package.json b/api/package.json
index c586c9fe..65472522 100644 --- a/api/package.json +++ b/api/package.json
@@ -30,7 +30,7 @@ "discord-open-source" ], "author": "Fosscord", - "license": "GPLV3", + "license": "AGPLV3", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/api/src/middlewares/RateLimit.ts b/api/src/middlewares/RateLimit.ts
index 1a38cfcf..81668034 100644 --- a/api/src/middlewares/RateLimit.ts +++ b/api/src/middlewares/RateLimit.ts
@@ -53,12 +53,12 @@ export default function rateLimit(opts: { if (opts.GET && ["GET", "OPTIONS", "HEAD"].includes(req.method)) max_hits = opts.GET; else if (opts.MODIFY && ["POST", "DELETE", "PATCH", "PUT"].includes(req.method)) max_hits = opts.MODIFY; - const offender = Cache.get(executor_id + bucket_id); + let offender = Cache.get(executor_id + bucket_id); if (offender) { - const reset = offender.expires_at.getTime(); - const resetAfterMs = reset - Date.now(); - const resetAfterSec = resetAfterMs / 1000; + let reset = offender.expires_at.getTime(); + let resetAfterMs = reset - Date.now(); + let resetAfterSec = Math.ceil(resetAfterMs / 1000); if (resetAfterMs <= 0) { offender.hits = 0; @@ -70,6 +70,11 @@ export default function rateLimit(opts: { if (offender.blocked) { const global = bucket_id === "global"; + // each block violation pushes the expiry one full window further + reset += opts.window * 1000; + offender.expires_at = new Date(offender.expires_at.getTime() + opts.window * 1000); + resetAfterMs = reset - Date.now(); + resetAfterSec = Math.ceil(resetAfterMs / 1000); console.log("blocked bucket: " + bucket_id, { resetAfterMs }); return ( diff --git a/cdn/CONTRIBUTE.md b/cdn/CONTRIBUTE.md deleted file mode 100644
index 7cc673d9..00000000 --- a/cdn/CONTRIBUTE.md +++ /dev/null
@@ -1,18 +0,0 @@ -# CONTRIBUTE - -### Setup: - -``` -npm i -npm start -``` - -### Run tests: - -``` -npm test -``` - -#### common errors: - -- db not connecting --> start mongod in a seperate terminal window diff --git a/cdn/package.json b/cdn/package.json
index 7a1f43c9..f1d12ba5 100644 --- a/cdn/package.json +++ b/cdn/package.json
@@ -14,8 +14,8 @@ "url": "git+https://github.com/fosscord/fosscord-server.git" }, "keywords": [], - "author": "", - "license": "GPLV3", + "author": "Fosscord", + "license": "AGPLV3", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/dashboard/LICENSE b/dashboard/LICENSE deleted file mode 100644
index f19bf520..00000000 --- a/dashboard/LICENSE +++ /dev/null
@@ -1,14 +0,0 @@ -Copyright (C) 2021 Fosscord and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. \ No newline at end of file diff --git a/dashboard/package.json b/dashboard/package.json
index 1009d658..e71de793 100644 --- a/dashboard/package.json +++ b/dashboard/package.json
@@ -14,8 +14,8 @@ "url": "git+https://github.com/fosscord/fosscord-server.git" }, "keywords": [], - "author": "", - "license": "GPLV3", + "author": "Fosscord", + "license": "AGPLV3", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/gateway/LICENSE b/gateway/LICENSE deleted file mode 100644
index f19bf520..00000000 --- a/gateway/LICENSE +++ /dev/null
@@ -1,14 +0,0 @@ -Copyright (C) 2021 Fosscord and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. \ No newline at end of file diff --git a/gateway/client.js b/gateway/client.js deleted file mode 100644
index c841c6a0..00000000 --- a/gateway/client.js +++ /dev/null
@@ -1,51 +0,0 @@ -require("missing-native-js-functions"); -const WebSocket = require("ws"); -const Constants = require("./dist/util/Constants"); - -// const ws = new WebSocket("ws://127.0.0.1:8080"); -const ws = new WebSocket("wss://dev.fosscord.com"); - -ws.on("open", () => { - // ws.send(JSON.stringify({ req_type: "new_auth" })); - // ws.send(JSON.stringify({ req_type: "check_auth", token: "" })); - // op: 0, - // d: {}, - // s: 42, - // t: "GATEWAY_EVENT_NAME", -}); - -function send(data) { - ws.send(JSON.stringify(data)); -} - -ws.on("message", (buffer) => { - let data = JSON.parse(buffer.toString()); - console.log(data); - - switch (data.op) { - case 10: - setIntervalNow(() => { - send({ op: 1 }); - }, data.d.heartbeat_interval); - - // send({ - // op: 2, - // d: { - // token: - // "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgxMTY0MjkxNzQzMjA2NjA0OCIsImlhdCI6MTYxMzU4MTE1MX0.7Qj_z2lYIgJ0rc7NfGtpW5DKGqecQfv1mLpoBUQHKDc", - // intents: 0n, - // properties: {}, - // }, - // }); - - send({ - op: 6, - }); - - break; - } -}); - -ws.on("close", (code, reason) => { - console.log(code, reason, Constants.CLOSECODES[code]); -}); diff --git a/gateway/package.json b/gateway/package.json
index 6d0d2d1c..92d812b4 100644 --- a/gateway/package.json +++ b/gateway/package.json
@@ -13,7 +13,7 @@ }, "keywords": [], "author": "Fosscord", - "license": "GPLV3", + "license": "AGPLV3", "devDependencies": { "@types/amqplib": "^0.8.1", "@types/jsonwebtoken": "^8.5.0", diff --git a/package.json b/package.json new file mode 100644
index 00000000..3395122e --- /dev/null +++ b/package.json
@@ -0,0 +1,17 @@ +{ + "name": "fosscord-server", + "version": "1.0.0", + "description": "A Fosscord server written in Node.js", + "workspaces": ["api", "cdn", "gateway"], + "scripts": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/fosscord/fosscord-server.git" + }, + "author": "Fosscord", + "license": "AGPLV3", + "bugs": { + "url": "https://github.com/fosscord/fosscord-server/issues" + }, + "homepage": "https://fosscord.com" +} diff --git a/rtc/LICENSE b/rtc/LICENSE deleted file mode 100644
index f19bf520..00000000 --- a/rtc/LICENSE +++ /dev/null
@@ -1,14 +0,0 @@ -Copyright (C) 2021 Fosscord and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. \ No newline at end of file diff --git a/util/LICENSE b/util/LICENSE deleted file mode 100644
index f19bf520..00000000 --- a/util/LICENSE +++ /dev/null
@@ -1,14 +0,0 @@ -Copyright (C) 2021 Fosscord and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. \ No newline at end of file diff --git a/util/package.json b/util/package.json
index d7baed9a..7251d3e4 100644 --- a/util/package.json +++ b/util/package.json
@@ -23,7 +23,7 @@ "discord-open-source" ], "author": "Fosscord", - "license": "GPLV3", + "license": "AGPLV3", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts
index 98766a9d..69c08be7 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts
@@ -28,6 +28,8 @@ export enum ChannelType { GUILD_PUBLIC_THREAD = 11, // a temporary sub-channel within a GUILD_TEXT channel GUILD_PRIVATE_THREAD = 12, // a temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission GUILD_STAGE_VOICE = 13, // a voice channel for hosting events with an audience + DIRECTORY = 14, // guild directory listing channel + GUILD_FORUM = 15, // forum composed of IM threads TICKET_TRACKER = 33, // ticket tracker, individual ticket items shall have type 12 KANBAN = 34, // confluence like kanban board VOICELESS_WHITEBOARD = 35, // whiteboard but without voice (whiteboard + voice is the same as stage) diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts
index b32bbd94..e18cf691 100644 --- a/util/src/entities/Message.ts +++ b/util/src/entities/Message.ts
@@ -39,13 +39,15 @@ export enum MessageType { USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10, USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11, CHANNEL_FOLLOW_ADD = 12, + ACTION = 13, // /me messages GUILD_DISCOVERY_DISQUALIFIED = 14, GUILD_DISCOVERY_REQUALIFIED = 15, ENCRYPTED = 16, REPLY = 19, - APPLICATION_COMMAND = 20, + APPLICATION_COMMAND = 20, // application command or self command invocation ROUTE_ADDED = 41, // custom message routing: new route affecting that channel ROUTE_DISABLED = 42, // custom message routing: given route no longer affecting that channel + SELF_COMMAND_SCRIPT = 43, // self command scripts ENCRYPTION = 50, CUSTOM_START = 63, UNHANDLED = 255 diff --git a/util/src/util/Constants.ts b/util/src/util/Constants.ts
index 54287af6..a5d3fcd2 100644 --- a/util/src/util/Constants.ts +++ b/util/src/util/Constants.ts
@@ -789,3 +789,4 @@ function keyMirror(arr: string[]) { for (const value of arr) tmp[value] = value; return tmp; } + diff --git a/util/src/util/Token.ts b/util/src/util/Token.ts
index 7c4cc61d..500ace45 100644 --- a/util/src/util/Token.ts +++ b/util/src/util/Token.ts
@@ -6,7 +6,12 @@ export const JWTOptions: VerifyOptions = { algorithms: ["HS256"] }; export function checkToken(token: string, jwtSecret: string): Promise<any> { return new Promise((res, rej) => { - token = token.replace("Bot ", ""); // TODO: proper bot support + token = token.replace("Bot ", ""); + /** + in fosscord, even with instances that have bot distinction; we won't enforce "Bot" prefix, + as we don't really have separate pathways for bots + **/ + jwt.verify(token, jwtSecret, JWTOptions, async (err, decoded: any) => { if (err || !decoded) return rej("Invalid Token"); diff --git a/webrtc/LICENSE b/webrtc/LICENSE deleted file mode 100644
index f19bf520..00000000 --- a/webrtc/LICENSE +++ /dev/null
@@ -1,14 +0,0 @@ -Copyright (C) 2021 Fosscord and contributors - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. \ No newline at end of file diff --git a/webrtc/package.json b/webrtc/package.json
index 0f700728..ab9e7486 100644 --- a/webrtc/package.json +++ b/webrtc/package.json
@@ -9,8 +9,8 @@ "start": "npm run build && node dist/start.js" }, "keywords": [], - "author": "", - "license": "ISC", + "author": "Fosscord", + "license": "AGPLV3", "devDependencies": { "@types/node": "^15.6.1", "@types/ws": "^7.4.4",