Update plugins/alldownloader.js
Browse files- plugins/alldownloader.js +16 -9
plugins/alldownloader.js
CHANGED
@@ -708,25 +708,30 @@ AllDlRoutes.get('/api/v1/dl/tiktok', authenticateApiKey, apiLimiter, async (req,
|
|
708 |
AllDlRoutes.get('/api/v1/dl/tiktok-v2', authenticateApiKey, apiLimiter, async (req, res) => {
|
709 |
const dbClient = new Database("AkenoXJs");
|
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 |
-
|
722 |
} else if (xRealIP) {
|
723 |
-
|
724 |
} else if (cfConnectingIP) {
|
725 |
-
|
726 |
}
|
|
|
727 |
req.realIP = realIP;
|
728 |
|
729 |
-
|
|
|
|
|
730 |
|
731 |
if (!keyDoc) {
|
732 |
return res.status(403).json({ error: "Invalid API Key." });
|
@@ -738,19 +743,21 @@ AllDlRoutes.get('/api/v1/dl/tiktok-v2', authenticateApiKey, apiLimiter, async (r
|
|
738 |
}
|
739 |
|
740 |
await TelegramUseLog(
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
);
|
745 |
|
746 |
const results = await tiktokdl(url);
|
747 |
res.json({ results });
|
|
|
748 |
} catch (error) {
|
749 |
console.error("TikTok Downloader Error:", error.message);
|
750 |
res.status(500).json({ error: error.message });
|
751 |
}
|
752 |
});
|
753 |
|
|
|
754 |
/**
|
755 |
* @swagger
|
756 |
* /api/v1/dl/fb:
|
|
|
708 |
AllDlRoutes.get('/api/v1/dl/tiktok-v2', authenticateApiKey, apiLimiter, async (req, res) => {
|
709 |
const dbClient = new Database("AkenoXJs");
|
710 |
const db = dbClient.collection("api_keys");
|
711 |
+
|
712 |
try {
|
713 |
const apiKey = req.headers['x-api-key'];
|
714 |
const userAgent = req.headers['user-agent'];
|
715 |
+
|
716 |
const xForwardedFor = req.headers['x-forwarded-for'];
|
717 |
const xRealIP = req.headers['x-real-ip'];
|
718 |
const cfConnectingIP = req.headers['cf-connecting-ip'];
|
719 |
+
|
720 |
let realIP = req.ip;
|
721 |
+
|
722 |
if (xForwardedFor) {
|
723 |
+
realIP = xForwardedFor.split(',')[0].trim();
|
724 |
} else if (xRealIP) {
|
725 |
+
realIP = xRealIP;
|
726 |
} else if (cfConnectingIP) {
|
727 |
+
realIP = cfConnectingIP;
|
728 |
}
|
729 |
+
|
730 |
req.realIP = realIP;
|
731 |
|
732 |
+
console.log(`🔍 Captured IPs:`, { xForwardedFor, xRealIP, cfConnectingIP, realIP });
|
733 |
+
|
734 |
+
const keyDoc = await db.findOne({ key: apiKey });
|
735 |
|
736 |
if (!keyDoc) {
|
737 |
return res.status(403).json({ error: "Invalid API Key." });
|
|
|
743 |
}
|
744 |
|
745 |
await TelegramUseLog(
|
746 |
+
keyDoc.owner,
|
747 |
+
keyDoc.key,
|
748 |
+
`Accessed: ${req.path}\nRealIP: ${realIP}\nUser-Agent: ${userAgent}`
|
749 |
);
|
750 |
|
751 |
const results = await tiktokdl(url);
|
752 |
res.json({ results });
|
753 |
+
|
754 |
} catch (error) {
|
755 |
console.error("TikTok Downloader Error:", error.message);
|
756 |
res.status(500).json({ error: error.message });
|
757 |
}
|
758 |
});
|
759 |
|
760 |
+
|
761 |
/**
|
762 |
* @swagger
|
763 |
* /api/v1/dl/fb:
|