Updated uploadController.js

DuckDuckGo's proxy is no longer supported as it stops reporting Content-Length header, which is crucial so that the safe could predict the actual file size before downloading it.

If you have it enabled in your config file, it will now close the safe with error code 1. You can either disable url uploads completely or just disable duckduckgo's proxy (though I believe not many will choose the latter as to begin with it was implemented to hide origin IP).
This commit is contained in:
Bobby Wibowo 2018-12-09 00:55:04 +07:00
parent 9eb9ac288d
commit 53789a20c2
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
3 changed files with 9 additions and 3 deletions

View File

@ -228,12 +228,13 @@ uploadsController.actuallyUploadByUrl = async (req, res, user, albumid) => {
if (!config.uploads.urlMaxSize) { return erred('Upload by URLs is disabled at the moment.') }
let urls = req.body.urls
const urls = req.body.urls
if (!urls || !(urls instanceof Array)) { return erred('Missing "urls" property (Array).') }
// DuckDuckGo's proxy
if (config.uploads.urlDuckDuckGoProxy) {
urls = urls.map(url => `https://proxy.duckduckgo.com/iur/?f=1&image_host=${encodeURIComponent(url)}&u=${url}`)
return erred('URL uploads unavailable. Please contact the site owner.')
// urls = urls.map(url => `https://proxy.duckduckgo.com/iu/?u=${encodeURIComponent(url)}&f=1`)
}
let iteration = 0

View File

@ -101,6 +101,11 @@ safe.use((error, req, res, next) => {
})
const start = async () => {
if (config.uploads.urlDuckDuckGoProxy) {
console.warn('Warning: DuckDuckGo\'s proxy is no longer supported as it stops reporting Content-Length header.')
return process.exit(1)
}
if (config.showGitHash) {
const gitHash = await new Promise((resolve, reject) => {
require('child_process').exec('git rev-parse HEAD', (error, stdout) => {

View File

@ -353,7 +353,7 @@ page.uploadUrls = function (button) {
}).catch(function (error) {
return posted({
success: false,
description: error.toString()
description: error.response ? error.response.data.description : error.toString()
})
})
}