export view=2: таблица без точек, октеты в своих ячейках

This commit is contained in:
2026-06-22 20:47:02 +04:00
parent ac7009f1e0
commit cf97a8c9bf
2 changed files with 13 additions and 10 deletions
+12 -9
View File
@@ -60,20 +60,23 @@ function createExportRouter() {
return router;
}
function padIP(cidr) {
const [ip, mask] = cidr.split('/');
const octets = ip.split('.').map(o => o.padStart(3, ' '));
return octets.join('.') + ' / ' + mask;
}
function renderTable(cidrs) {
const rows = cidrs.map(c => '<tr><td><code>' + padIP(c) + '</code></td></tr>').join('\n');
const rows = cidrs.map(c => {
const [ip, mask] = c.split('/');
const [a, b, c2, d] = ip.split('.');
return '<tr>'
+ '<td>' + a.padStart(3, ' ') + '</td>'
+ '<td>' + b.padStart(3, ' ') + '</td>'
+ '<td>' + c2.padStart(3, ' ') + '</td>'
+ '<td>' + d.padStart(3, ' ') + '</td>'
+ '<td> / ' + mask + '</td>'
+ '</tr>';
}).join('\n');
return '<!DOCTYPE html><html><head><meta charset="utf-8"><title>WhiteList Export</title>'
+ '<style>body{font-family:monospace;background:#fff;color:#111;padding:1rem}'
+ 'h2{font-size:1rem;color:#666;margin-bottom:.5rem}'
+ 'table{border-collapse:collapse}'
+ 'td{padding:.15rem 1rem .15rem 0}'
+ 'code{font-size:.9rem;white-space:pre}'
+ 'td{padding:.15rem .5rem .15rem 0;white-space:pre;font-size:.9rem}'
+ '</style></head><body>'
+ '<h2>WhiteList — ' + cidrs.length + ' записей</h2>'
+ '<table>' + rows + '</table>'