fix tor not flagging on channel saves

This commit is contained in:
localhost 2026-04-05 20:33:38 +02:00
parent 096fd9c0fa
commit fce3f4ff96
2 changed files with 18 additions and 13 deletions

View File

@ -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.')
const ranges = await checkIpRanges(headers['cf-connecting-ip'] || headers['x-forwarded-for'] || '')

View File

@ -103,7 +103,7 @@ app.ws('/save', {
if (range.list != 'cloudflare') return sendError(ws, 'There\'s something wrong with your connection.')
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)}`)
@ -214,7 +214,7 @@ app.ws('/savechannel', {
if (range.list != 'cloudflare') return sendError(ws, 'There\'s something wrong with your connection.')
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)}`)