forked from TannerReynolds/ShareX-Upload-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
faa4893
commit bc515ac
Showing
59 changed files
with
138 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
server/uploads/* linguist-vendored | ||
src/server/uploads/* linguist-vendored | ||
.github/* linguist-vendored | ||
server/views/* linguist-vendored | ||
src/server/views/* linguist-vendored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/node_modules | ||
config.real.json | ||
package-lock.json | ||
src/node_modules | ||
src/config.real.json | ||
src/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Version": "12.4.0", | ||
"Name": "Images_and_Files", | ||
"DestinationType": "ImageUploader, FileUploader", | ||
"RequestMethod": "POST", | ||
"RequestURL": "http://[YOUR_DOMAIN]/api/files", | ||
"Body": "MultipartFormData", | ||
"Arguments": { | ||
"key": "YOUR_PASSWORD" | ||
}, | ||
"FileFormName": "fdata" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Version": "12.4.0", | ||
"Name": "Text", | ||
"DestinationType": "TextUploader", | ||
"RequestMethod": "POST", | ||
"RequestURL": "http://[YOUR_DOMAIN]/api/paste", | ||
"Body": "MultipartFormData", | ||
"Arguments": { | ||
"key": "YOUR_PASSWORD" | ||
}, | ||
"FileFormName": "fdata" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"Version": "12.4.0", | ||
"Name": "URL_Shortener", | ||
"DestinationType": "URLShortener", | ||
"RequestMethod": "POST", | ||
"RequestURL": "http://[YOUR_DOMAIN]/api/shortener", | ||
"Headers": { | ||
"url": "$input$" | ||
}, | ||
"Body": "MultipartFormData", | ||
"Arguments": { | ||
"key": "YOUR_PASSWORD" | ||
}, | ||
"FileFormName": "fdata" | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
{ | ||
"key": "", | ||
"public": false, | ||
"maxUploadSize": 50, | ||
"markdown": true, | ||
"port": 80, | ||
"secure": true, | ||
"securePort": 443, | ||
"ratelimit": 1000, | ||
"allowed":[ | ||
"png", "jpg", "gif", "mp4", "mp3", "jpeg", "tiff", "bmp", "ico", "psd", "eps", "raw", "cr2", "nef", "sr2", "orf", "svg", "wav", "webm", "aac", "flac", "ogg", "wma", "m4a", "gifv" | ||
], | ||
"admin":{ | ||
"key": "admin pass key goes here", | ||
"maxUploadSize": 1024, | ||
"allowed": [ | ||
"png", "jpg", "gif", "mp4", "mp3","jpeg", "tiff", "bmp", "ico", "psd", "eps", "raw", "cr2", "nef", "sr2", "orf", "svg", "wav", "webm", "aac", "flac", "ogg", "wma", "m4a", "gifv", "html" | ||
] | ||
}, | ||
"paste": { | ||
"maxUploadSize": 20, | ||
"allowed": [ | ||
"js", "php", "html", "txt", "lua", "json", "yml", "go", "cr", "bat", "css", "cs", "java", "py", "less", "c", "cpp", "ini", "pl", "sql", "rb", "md" | ||
] | ||
}, | ||
"discordToken": "Discord Token Here (required if you want API monitoring through Discord)", | ||
"discordAdminIDs": ["discord IDs of people who can run commands go here", "Like this"], | ||
"discordChannelID": "the channel you're trying to send api monitor updates to", | ||
"prefix": "enter prefix for bot commands here" | ||
{ | ||
"key": "", | ||
"public": false, | ||
"maxUploadSize": 50, | ||
"markdown": true, | ||
"port": 80, | ||
"secure": true, | ||
"securePort": 443, | ||
"ratelimit": 1000, | ||
"allowed":[ | ||
"png", "jpg", "gif", "mp4", "mp3", "jpeg", "tiff", "bmp", "ico", "psd", "eps", "raw", "cr2", "nef", "sr2", "orf", "svg", "wav", "webm", "aac", "flac", "ogg", "wma", "m4a", "gifv" | ||
], | ||
"admin":{ | ||
"key": "admin pass key goes here", | ||
"maxUploadSize": 1024, | ||
"allowed": [ | ||
"png", "jpg", "gif", "mp4", "mp3","jpeg", "tiff", "bmp", "ico", "psd", "eps", "raw", "cr2", "nef", "sr2", "orf", "svg", "wav", "webm", "aac", "flac", "ogg", "wma", "m4a", "gifv", "html" | ||
] | ||
}, | ||
"paste": { | ||
"maxUploadSize": 20 | ||
}, | ||
"discordToken": "Discord Token Here (required if you want API monitoring through Discord)", | ||
"discordAdminIDs": ["discord IDs of people who can run commands go here", "Like this"], | ||
"discordChannelID": "the channel you're trying to send api monitor updates to", | ||
"prefix": "enter prefix for bot commands here" | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
if which node > /dev/null | ||
then | ||
echo "\x1b[32mNode is already installed, skipping...\x1b[0m" | ||
else | ||
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash - | ||
sudo apt-get install -y nodejs | ||
fi | ||
npm i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const path = require("path") | ||
const formidable = require("formidable") | ||
const fs = require("fs-extra") | ||
const ejs = require("ejs") | ||
async function paste(req, res) { | ||
res.setHeader("Content-Type", "text/text") | ||
let fileName = this.randomToken(5) // 916,132,832 possible file names | ||
let form = new formidable.IncomingForm() | ||
form.parse(req, (err, fields, files) => { | ||
let userIP = req.headers["x-forwarded-for"] || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress | ||
if (!this.auth(this.c.key, fields.key, this.c)) { | ||
res.statusCode = 401 | ||
res.write("Unauthorized"); | ||
res.end(); | ||
return this.log.warning(`Unauthorized User | File Upload | ${userIP}`) | ||
} | ||
this.db.get("files") | ||
.push({ | ||
path: `/${fileName}`, | ||
ip: userIP, | ||
views: 0 | ||
}) | ||
.write(); | ||
let oldpath = files.fdata.path | ||
let newpath = `${__dirname}/../uploads/${fileName+files.fdata.name.toString().match(/(\.)+([a-zA-Z0-9]+)+/g, "").toString()}`; | ||
if (Math.round((files.fdata.size / 1024) / 1000) > this.c.paste.max_upload_size) { | ||
if (this.monitorChannel !== null) this.bot.createMessage(this.monitorChannel, `\`\`\`MARKDOWN\n[FAILED PASTE][USER]\n[FILE](${files.fdata.name})\n[SIZE](${Math.round(files.fdata.size/1024)}KB)\n[TYPE](${files.fdata.type})\n[IP](${userIP})\n\n[ERROR](ERR_FILE_TOO_BIG)\`\`\``) | ||
res.statusCode = 413 | ||
res.write(`http://${req.headers.host}/ERR_FILE_TOO_BIG`) | ||
return res.end() | ||
} else { | ||
fs.move(oldpath, newpath, err => { | ||
fs.readFile(newpath, "utf-8", function read(err, data) { | ||
let stream = fs.createWriteStream(`${__dirname}/../uploads/${fileName}.html`) | ||
stream.once("open", fd => { | ||
let cleaned = data.replace(/>/g, ">") | ||
cleaned = cleaned.replace(/</g, "<") | ||
ejs.renderFile(`${__dirname}/../views/paste.ejs`, { | ||
ogDesc: data.match(/.{1,297}/g)[0], | ||
pData: data | ||
}, {}, (err, str) => { | ||
stream.write(str) | ||
}) | ||
stream.end() | ||
fs.unlink(newpath, err => { | ||
if (err) return | ||
}); | ||
let insecure = `http://${req.headers.host}/${fileName}` | ||
let secure = `https://${req.headers.host}/${fileName}` | ||
res.write(req.secure ? secure : insecure) | ||
return res.end() | ||
}) | ||
}) | ||
}) | ||
} | ||
}) | ||
} | ||
module.exports = paste |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.