Skip to content

Commit

Permalink
Add leech-handling feature-flag
Browse files Browse the repository at this point in the history
  • Loading branch information
cultpodcasts committed Mar 29, 2024
1 parent e0657ee commit 2413be3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface Env {

export default {
async fetch(request: Request, env: Env) {
const leechHandlingActive = false;
const { pathname, searchParams } = new URL(request.url);
const homeRoute = "/homepage";
const searchRoute = "/api";
Expand Down Expand Up @@ -69,15 +70,17 @@ export default {
}
let isLeech: boolean = false;

//const object = await env.Data.get("leeches");
if (leechHandlingActive) {
const object = await env.Data.get("leeches");

//if (object != null) {
// var leeches: string[] = await object.json();
// console.log(`ip-address: ${ipAddress} index: ${leeches.indexOf(ipAddress)} lookup: ${JSON.stringify(leeches)}`);
// if (leeches.indexOf(ipAddress) >= 0) {
// isLeech = true;
// }
//}
if (object != null) {
var leeches: string[] = await object.json();
console.log(`ip-address: ${ipAddress} index: ${leeches.indexOf(ipAddress)} lookup: ${JSON.stringify(leeches)}`);
if (leeches.indexOf(ipAddress) >= 0) {
isLeech = true;
}
}
}

if (!isLeech) {
return request
Expand Down

0 comments on commit 2413be3

Please sign in to comment.