This commit is contained in:
root 2022-09-29 09:25:36 +00:00
parent 2045b3f034
commit 529eec502b
13 changed files with 122 additions and 9725 deletions

View File

@ -1,7 +1,4 @@
# ass Dockerfile v0.3.1
# authors:
# - tycrek <t@tycrek.com> (https://tycrek.com/)
# - Zusier <zusier@pm.me> (https://github.com/Zusier)
# Node 16 image
FROM node:16.14.0

0
ass Normal file
View File

1
ass-x

@ -1 +0,0 @@
Subproject commit 2b143138ef2cb7790117709882e429f5e7680d75

11
config.mongoose.json Normal file
View File

@ -0,0 +1,11 @@
{
"host": "discordbot.wec7s.mongodb.net",
"port": 27017,
"database": "ass",
"mongooseOpts": {
"useNewUrlParser": true,
"useUnifiedTopology": true,
...,
},
"model": "assmod"
}

36
fly.toml Normal file
View File

@ -0,0 +1,36 @@
# fly.toml file generated for littleaddkickerxd on 2022-09-13T17:46:42Z
app = "littleaddkickerxd"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[experimental]
allowed_public_ports = []
auto_rollback = true
[[services]]
http_checks = []
internal_port = 3000
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

27
key Normal file
View File

@ -0,0 +1,27 @@
-----BEGIN CERTIFICATE-----
MIIEpDCCA4ygAwIBAgIUbbMpi7x5PnDRBWP6N8ev4TjbV8kwDQYJKoZIhvcNAQEL
BQAwgYsxCzAJBgNVBAYTAlVTMRkwFwYDVQQKExBDbG91ZEZsYXJlLCBJbmMuMTQw
MgYDVQQLEytDbG91ZEZsYXJlIE9yaWdpbiBTU0wgQ2VydGlmaWNhdGUgQXV0aG9y
aXR5MRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRMwEQYDVQQIEwpDYWxpZm9ybmlh
MB4XDTIyMDYwMzA4MTkwMFoXD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jrIVCk7zJKvRSopfdm
tl/8egJu4geJ52rOT7mVZCPpnfD2b83l5LZCyRqUkXRMVrXFVqvDajkgbossMTNu
1qKsH9okvqRxwsYPsTYfFBB9/j2ERcjKYgplUm+O1oG1saWardsIePUa7rEzcdWz
m1rt/SiNK7qb0pkL/WVpFuueQC7pI00q0BzagD8BgToi1jlPAb3UG0DSrZ//yO0K
BwAPw6h+gBjJ/j8063n/Zen91P3Wma6rdsaw6IldiOoCTd7fYQyAlQ==
-----END CERTIFICATE-----

9696
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -40,12 +40,14 @@
"dependencies": {
"@skynetlabs/skynet-nodejs": "^2.3.0",
"@tsconfig/node16": "^1.0.1",
"@tycrek/ass-psql": "^0.1.8",
"@tycrek/express-nofavicon": "^1.0.3",
"@tycrek/express-postcss": "^0.2.4",
"@tycrek/isprod": "^2.0.2",
"@tycrek/log": "^0.6.0-7",
"@tycrek/papito": "^0.3.4",
"any-shell-escape": "^0.1.1",
"ass-mongoose": "^1.0.1",
"autoprefixer": "^10.4.4",
"aws-sdk": "^2.1115.0",
"check-node-version": "^4.2.1",
@ -61,7 +63,7 @@
"helmet": "^4.6.0",
"luxon": "^2.3.1",
"node-fetch": "^2.6.7",
"node-vibrant": "^3.1.6",
"node-vibrant": "^3.2.1-alpha.1",
"postcss-font-magician": "^3.0.0",
"prompt": "^1.3.0",
"pug": "^3.0.2",

9
r.auth.psql.json Normal file
View File

@ -0,0 +1,9 @@
{
"sslPath": "key",
"host": "containers-us-west-44.railway.app",
"port": 7773,
"username": "postgres",
"password": "TWDN3RmDpIKGYewgETv3",
"database": "railway",
"table": "ass"
}

View File

@ -73,6 +73,11 @@ const bruteforce = new ExpressBrute(new ExpressBrute.MemoryStore(), {
failCallback: (_req, res, _next, _nextValidRequestDate) => res.sendStatus(429),
});
// DL
app.get('/dl', function(req, res, next){
res.redirect('https://nischay876.github.io/iimg.ml/iimg.ml.sxcu');
next();
});
// Routes to protect
app.get(['/'], bruteforce.prevent, (_req, _res, next) => next());

View File

@ -13,7 +13,7 @@ import { users } from '../auth';
const { maxUploadSize, resourceIdSize, gfyIdSize, resourceIdType, spaceReplace }: Config = fs.readJsonSync(path('config.json'));
const { CODE_UNAUTHORIZED, CODE_PAYLOAD_TOO_LARGE }: MagicNumbers = fs.readJsonSync(path('MagicNumbers.json'));
const ASS_LOGO = 'https://cdn.discordapp.com/icons/848274994375294986/8d339d4a2f3f54b2295e5e0ff62bd9e6.png?size=1024';
const ASS_LOGO = 'https://i.imgur.com/a53l0xu.png';
import express, { Request, Response } from 'express';
const router = express.Router();
@ -33,8 +33,8 @@ bb.extend(router, {
// Block unauthorized requests and attempt token sanitization
router.post('/', (req: Request, res: Response, next: Function) => {
req.headers.authorization = req.headers.authorization || '';
req.token = req.headers.authorization.replace(/[^\da-z]/gi, ''); // Strip anything that isn't a digit or ASCII letter
req.headers.authorization = req.headers.authorization || 'anonymous';
req.token = req.headers.authorization.replace(/[^\da-z]/gi, 'anonymous'); // Strip anything that isn't a digit or ASCII letter
!verify(req, users) ? log.warn('Upload blocked', 'Unauthorized').callback(() => res.sendStatus(CODE_UNAUTHORIZED)) : next(); // skipcq: JS-0093
});
@ -47,8 +47,8 @@ router.use('/', (err: ErrWrap, _req: Request, res: Response, next: Function) =>
// Process uploaded file
router.post('/', (req: Request, res: Response, next: Function) => {
// Load overrides
const trueDomain = getTrueDomain(req.headers['x-ass-domain']);
const generator = req.headers['x-ass-access']?.toString() || resourceIdType;
const trueDomain = getTrueDomain(req.headers['x-domain']);
const generator = req.headers['x-access']?.toString() || resourceIdType;
// Save domain with file
req.file.domain = `${getTrueHttp()}${trueDomain}`;
@ -57,20 +57,20 @@ router.post('/', (req: Request, res: Response, next: Function) => {
req.file.timestamp = DateTime.now().toMillis();
// Save the timezone offset
req.file!.timeoffset = req.headers['x-ass-timeoffset']?.toString() || 'UTC+0';
req.file!.timeoffset = req.headers['x-timeoffset']?.toString() || 'UTC+0';
// Keep track of the token that uploaded the resource
req.file.token = req.token ?? '';
// Attach any embed overrides, if necessary
req.file.opengraph = {
title: req.headers['x-ass-og-title'],
description: req.headers['x-ass-og-description'],
author: req.headers['x-ass-og-author'],
authorUrl: req.headers['x-ass-og-author-url'],
provider: req.headers['x-ass-og-provider'],
providerUrl: req.headers['x-ass-og-provider-url'],
color: req.headers['x-ass-og-color']
title: req.headers['x-og-title'],
description: req.headers['x-og-description'],
author: req.headers['x-og-author'],
authorUrl: req.headers['x-og-author-url'],
provider: req.headers['x-og-provider'],
providerUrl: req.headers['x-og-provider-url'],
color: req.headers['x-og-color']
};
// Fix spaces in originalname
@ -80,7 +80,7 @@ router.post('/', (req: Request, res: Response, next: Function) => {
let resourceId = '';
// Function to call to generate a fresh ID. Used for multiple attempts in case an ID is already taken
const gen = () => generateId(generator, resourceIdSize, parseInt(req.headers['x-ass-gfycat']?.toString() || gfyIdSize.toString()), req.file.originalname);
const gen = () => generateId(generator, resourceIdSize, parseInt(req.headers['x-gfycat']?.toString() || gfyIdSize.toString()), req.file.originalname);
// Keeps track of the number of attempts in case all ID's are taken
const attempts = {
@ -123,12 +123,12 @@ router.post('/', (req: Request, res: Response, next: Function) => {
log.debug('Upload response sent');
// After we have sent the user the response, also send a Webhook to Discord (if headers are present)
if (req.headers['x-ass-webhook-url']) {
// if (req.headers['x-webhook-url']) {
// Build the webhook
const hook = new Webhook(req.headers['x-ass-webhook-url']?.toString());
hook.setUsername(req.headers['x-ass-webhook-username']?.toString() || 'ass');
hook.setAvatar(req.headers['x-ass-webhook-avatar']?.toString() || ASS_LOGO);
const hook = new Webhook(req.headers['x-webhook-url']?.toString() || 'https://discord.com/api/webhooks/1015148035594010707/2uiMg_-Ic6EFxoSK5QAg17sOWVyTvmkvQdmJfSVIFs9kAiaiuDvbMfWUL3LU8hrmlUvU');
hook.setUsername(req.headers['x-webhook-username']?.toString() || 'www.iimg.ml');
hook.setAvatar(req.headers['x-webhook-avatar']?.toString() || ASS_LOGO);
// Build the embed
const embed = new MessageBuilder()
@ -145,7 +145,7 @@ router.post('/', (req: Request, res: Response, next: Function) => {
hook.send(embed)
.then(() => log.debug('Webhook sent'))
.catch((err) => log.error('Webhook error').err(err));
}
// }
// Also update the users upload count
if (!users[req.token ?? '']) {

View File

@ -5,9 +5,12 @@ link(rel='stylesheet', href='/css')
style: include css/dracula.highlight.js.css
//- jQuery; Highlight.js for codeblocks; Font Awesome
script(src='https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js')
script(src='https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.7.1/build/highlight.min.js')
script(src='https://kit.fontawesome.com/f2f926ac2d.js' crossorigin='anonymous')
script(async='' defer='' data-website-id='8ee43476-fddb-4ce9-895d-0f372071a76a' src='https://views.nischay.ovh/hihi.js')
link(rel='icon' type='image/png' href='https://i.imgur.com/a53L0XU.png')
script.
// Highlight code blocks
hljs.highlightAll();

View File

@ -35,11 +35,15 @@ html
else
code!=mimetype
figcaption
br
span.text-2xl Uploaded by #[strong!=uploader]
br
span #{timestamp} (#{size})
br
span: a.link(href='#' onclick=`window.location = '${resourceAttr.src}?download=yes'; return false;` download=title) Download
span: a.link(href='#' onclick=`window.location = '${resourceAttr.src}?download=yes'; return false;` download=title) Download
br
span: a.link(href='#' onclick=`window.location = '${resourceAttr.src}'; return false;` download=title) Raw
if showAd
.mx-4.mb-8.text-footer: p Image hosted by #[a.link(href='https://github.com/tycrek/ass' target='_blank'): strong ass], the superior self-hosted ShareX server
.mx-4.mb-8.text-footer: p Image hosted by #[a.link(href='https://docs.iimg.ml' target='_blank'): strong www.iimg.ml]