feat: Add IP ranges management API endpoints and integrate with frontend for viewing and updating IP ranges
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 6m20s

This commit is contained in:
2025-07-14 19:40:27 +07:00
parent a54c09ae15
commit 2bee891548
16 changed files with 804 additions and 0 deletions
+50
View File
@@ -176,6 +176,56 @@ app.post('/api/domains-new', async (req, res) => {
}
});
// --- IP Ranges Routes ---
// Get IP ranges from S3
app.get('/api/ip-ranges', async (req, res) => {
const params = {
Bucket: BUCKET_NAME,
Key: 'domains/ips.txt',
};
try {
const data = await s3.getObject(params).promise();
const fileContent = data.Body.toString('utf-8');
const ipRanges = fileContent.split('\n').filter(line => line).map(line => {
const parts = line.trim().split(/\s+/);
const ipRange = parts[0] || '';
const community = parts[1] || '';
return { ipRange, community };
});
res.json(ipRanges);
} catch (error) {
if (error.code === 'NoSuchKey') {
res.json([]); // Return empty array if file does not exist
} else {
console.error(error);
res.status(500).send('Error reading from S3');
}
}
});
// Update IP ranges in S3
app.post('/api/ip-ranges', async (req, res) => {
const { ipRanges } = req.body;
const fileContent = ipRanges.map(ip => `${ip.ipRange} ${ip.community}`).join('\n');
const params = {
Bucket: BUCKET_NAME,
Key: 'domains/ips.txt',
Body: fileContent,
ContentType: 'text/plain',
};
try {
await s3.putObject(params).promise();
res.send('File updated successfully');
} catch (error) {
console.error(error);
res.status(500).send('Error writing to S3');
}
});
// --- Servers Routes (JSON format) ---
// Get servers from S3