fix tor not flagging on channel saves
This commit is contained in:
parent
096fd9c0fa
commit
fce3f4ff96
|
|
@ -55,7 +55,12 @@ app.get('/save', async ({ query: { url }, set, headers, error, request, redirect
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/savechannel', async ({ query: { url }, set, headers, error }) => {
|
app.get('/savechannel', async ({ query: { url }, set, headers, error, request, redirect }) => {
|
||||||
|
if (headers.host?.split(':')[0] !== 'preservetube.com') {
|
||||||
|
const parsedUrl = new URL(request.url)
|
||||||
|
return redirect(`https://preservetube.com${parsedUrl.pathname}${parsedUrl.search}`)
|
||||||
|
}
|
||||||
|
|
||||||
if (!url) return error(400, 'No url provided.')
|
if (!url) return error(400, 'No url provided.')
|
||||||
|
|
||||||
const ranges = await checkIpRanges(headers['cf-connecting-ip'] || headers['x-forwarded-for'] || '')
|
const ranges = await checkIpRanges(headers['cf-connecting-ip'] || headers['x-forwarded-for'] || '')
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ app.ws('/save', {
|
||||||
if (range.list != 'cloudflare') return sendError(ws, 'There\'s something wrong with your connection.')
|
if (range.list != 'cloudflare') return sendError(ws, 'There\'s something wrong with your connection.')
|
||||||
|
|
||||||
const blacklistCheck = await checkIpRanges(ws.data.headers['cf-connecting-ip']!)
|
const blacklistCheck = await checkIpRanges(ws.data.headers['cf-connecting-ip']!)
|
||||||
if (blacklistCheck.blocked) return sendError(ws, `Your network is flagged as malicious.`)
|
if (blacklistCheck.blocked || ws.data.headers['cf-ipcountry'] == 'T1') return sendError(ws, `Your network is flagged as malicious.`)
|
||||||
|
|
||||||
console.log(`${ws.id} - ${ws.data.path} - ${JSON.stringify(ws.data.query)}`)
|
console.log(`${ws.id} - ${ws.data.path} - ${JSON.stringify(ws.data.query)}`)
|
||||||
|
|
||||||
|
|
@ -214,7 +214,7 @@ app.ws('/savechannel', {
|
||||||
if (range.list != 'cloudflare') return sendError(ws, 'There\'s something wrong with your connection.')
|
if (range.list != 'cloudflare') return sendError(ws, 'There\'s something wrong with your connection.')
|
||||||
|
|
||||||
const blacklistCheck = await checkIpRanges(ws.data.headers['cf-connecting-ip']!)
|
const blacklistCheck = await checkIpRanges(ws.data.headers['cf-connecting-ip']!)
|
||||||
if (blacklistCheck.blocked) return sendError(ws, `Your network is flagged as malicious.`)
|
if (blacklistCheck.blocked || ws.data.headers['cf-ipcountry'] == 'T1') return sendError(ws, `Your network is flagged as malicious.`)
|
||||||
|
|
||||||
console.log(`${ws.id} - ${ws.data.path} - ${JSON.stringify(ws.data.query)}`)
|
console.log(`${ws.id} - ${ws.data.path} - ${JSON.stringify(ws.data.query)}`)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue