forked from l4uy/waves
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathask.js
More file actions
26 lines (21 loc) · 647 Bytes
/
ask.js
File metadata and controls
26 lines (21 loc) · 647 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const BLACKLISTED = ['.nip.io', '.sslip.io'];
const PORT = 3001;
console.log(`ASK server listening on port ${PORT}`);
Bun.serve({
port: PORT,
fetch(req) {
const url = new URL(req.url, "http://localhost");
const domain = (url.searchParams.get('domain') || '').toLowerCase();
if (!domain) {
return new Response('No', { status: 400 });
}
for (const pattern of BLACKLISTED) {
if (domain.endsWith(pattern)) {
console.log(`[DENY] ${domain}`);
return new Response('No', { status: 403 });
}
}
console.log(`[ALLOW] ${domain}`);
return new Response('Yes', { status: 200 });
},
});