Update plugins/alldownloader.js
Browse files- plugins/alldownloader.js +15 -1
plugins/alldownloader.js
CHANGED
@@ -710,8 +710,22 @@ AllDlRoutes.get('/api/v1/dl/tiktok-v2', authenticateApiKey, apiLimiter, async (r
|
|
710 |
const db = dbClient.collection("api_keys");
|
711 |
try {
|
712 |
const apiKey = req.headers['x-api-key'];
|
713 |
-
const xRealIP = req.headers['x-real-ip'];
|
714 |
const userAgent = req.headers['user-agent'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
715 |
const keyDoc = await db.findOne({key: apiKey});
|
716 |
|
717 |
if (!keyDoc) {
|
|
|
710 |
const db = dbClient.collection("api_keys");
|
711 |
try {
|
712 |
const apiKey = req.headers['x-api-key'];
|
|
|
713 |
const userAgent = req.headers['user-agent'];
|
714 |
+
|
715 |
+
const xForwardedFor = req.headers['x-forwarded-for'];
|
716 |
+
const xRealIP = req.headers['x-real-ip'];
|
717 |
+
const cfConnectingIP = req.headers['cf-connecting-ip'];
|
718 |
+
let realIP = req.ip;
|
719 |
+
|
720 |
+
if (xForwardedFor) {
|
721 |
+
realIP = xForwardedFor.split(',')[0].trim();
|
722 |
+
} else if (xRealIP) {
|
723 |
+
realIP = xRealIP;
|
724 |
+
} else if (cfConnectingIP) {
|
725 |
+
realIP = cfConnectingIP;
|
726 |
+
}
|
727 |
+
req.realIP = realIP;
|
728 |
+
|
729 |
const keyDoc = await db.findOne({key: apiKey});
|
730 |
|
731 |
if (!keyDoc) {
|