work: добавли отображение доменов в два столбца

This commit is contained in:
2026-10-18 22:22:48 +03:00
parent d2c809c216
commit b2cb189d25
+114 -21
View File
@@ -690,10 +690,27 @@ def index():
state = load_state()
except Exception as exc:
state = ([], [], False, f"Cannot read Caddy config: {exc}", False, f"Cannot read dnsmasq config: {exc}")
dns_records = state[1]
xray_records = sorted(
(r for r in dns_records if r.service_key == "xray"),
key=lambda r: r.domain.lower(),
)
byedpi_records = sorted(
(r for r in dns_records if r.service_key == "byedpi"),
key=lambda r: r.domain.lower(),
)
other_dns_records = sorted(
(r for r in dns_records if r.service_key not in {"xray", "byedpi"}),
key=lambda r: r.domain.lower(),
)
return render_template_string(
TEMPLATE,
caddy_records=state[0],
dns_records=state[1],
xray_records=xray_records,
byedpi_records=byedpi_records,
other_dns_records=other_dns_records,
caddy_ok=state[2],
caddy_status=state[3],
dns_ok=state[4],
@@ -985,6 +1002,12 @@ TEMPLATE = r"""
details { margin-top:10px; color:var(--muted); }
pre { white-space:pre-wrap; word-break:break-word; font-size:12px; }
.tag { display:inline-block; padding:2px 7px; border:1px solid #3a4657; border-radius:999px; color:#b8c6d9; font-size:11px; }
.dns-group { margin-top:18px; border:1px solid var(--line); border-radius:11px; overflow:hidden; background:#12161c; }
.dns-group-head { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:11px 13px; border-bottom:1px solid var(--line); }
.dns-group-title { display:flex; align-items:baseline; gap:8px; font-weight:700; }
.dns-group table { margin:0; }
.dns-group td:last-child, .dns-group th:last-child { width:1%; white-space:nowrap; }
.dns-warning { margin-top:18px; border-color:#735b2e; background:rgba(255,190,70,.04); }
@media (max-width:900px) { .grid { grid-template-columns:1fr; } }
@media (max-width:560px) { form.add { grid-template-columns:1fr; } .wide { grid-column:auto; } table { display:block; overflow-x:auto; } }
</style>
@@ -1063,26 +1086,96 @@ TEMPLATE = r"""
</form>
<p><a class="button-link" href="{{ url_for('dns_export') }}">Экспортировать список доменов</a></p>
<table>
<thead><tr><th>Domain</th><th>Сервис</th><th>IPv4</th><th>IPv6</th><th></th></tr></thead>
<tbody>
{% for r in dns_records %}
<tr>
<td><strong>{{ r.domain }}</strong></td>
<td><span class="tag">{{ r.service_name }}</span></td>
<td><code>{{ r.ip }}</code></td>
<td>{% if r.ipv6_blocked %}<span class="tag">заблокирован</span>{% else %}<span class="muted">нет local=</span>{% endif %}</td>
<td>
<form method="post" action="{{ url_for('dns_delete') }}" onsubmit="return confirm('Удалить {{ r.domain }}?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="record_id" value="{{ r.record_id }}">
<button class="delete" type="submit">Удалить</button>
</form>
</td>
</tr>
{% else %}<tr><td colspan="5" class="muted">Записей не найдено.</td></tr>{% endfor %}
</tbody>
</table>
<div class="dns-group">
<div class="dns-group-head">
<div class="dns-group-title">
<span>XRAY</span>
<span class="tag">{{ xray_records|length }} доменов</span>
</div>
<code>{{ dns_services['xray']['ip'] }}</code>
</div>
<table>
<thead><tr><th>Domain</th><th>IPv6</th><th></th></tr></thead>
<tbody>
{% for r in xray_records %}
<tr>
<td><strong>{{ r.domain }}</strong></td>
<td>{% if r.ipv6_blocked %}<span class="tag">заблокирован</span>{% else %}<span class="muted">нет local=</span>{% endif %}</td>
<td>
<form method="post" action="{{ url_for('dns_delete') }}" onsubmit="return confirm('Удалить {{ r.domain }} из XRAY?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="record_id" value="{{ r.record_id }}">
<button class="delete" type="submit">Удалить</button>
</form>
</td>
</tr>
{% else %}
<tr><td colspan="3" class="muted">Нет доменов, направленных через XRAY.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="dns-group">
<div class="dns-group-head">
<div class="dns-group-title">
<span>ByeDPI</span>
<span class="tag">{{ byedpi_records|length }} доменов</span>
</div>
<code>{{ dns_services['byedpi']['ip'] }}</code>
</div>
<table>
<thead><tr><th>Domain</th><th>IPv6</th><th></th></tr></thead>
<tbody>
{% for r in byedpi_records %}
<tr>
<td><strong>{{ r.domain }}</strong></td>
<td>{% if r.ipv6_blocked %}<span class="tag">заблокирован</span>{% else %}<span class="muted">нет local=</span>{% endif %}</td>
<td>
<form method="post" action="{{ url_for('dns_delete') }}" onsubmit="return confirm('Удалить {{ r.domain }} из ByeDPI?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="record_id" value="{{ r.record_id }}">
<button class="delete" type="submit">Удалить</button>
</form>
</td>
</tr>
{% else %}
<tr><td colspan="3" class="muted">Нет доменов, направленных через ByeDPI.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% if other_dns_records %}
<div class="dns-group dns-warning">
<div class="dns-group-head">
<div class="dns-group-title">
<span>Другие маршруты</span>
<span class="tag">{{ other_dns_records|length }}</span>
</div>
<span class="muted">IP не соответствует XRAY/ByeDPI</span>
</div>
<table>
<thead><tr><th>Domain</th><th>IPv4</th><th>IPv6</th><th></th></tr></thead>
<tbody>
{% for r in other_dns_records %}
<tr>
<td><strong>{{ r.domain }}</strong></td>
<td><code>{{ r.ip }}</code></td>
<td>{% if r.ipv6_blocked %}<span class="tag">заблокирован</span>{% else %}<span class="muted">нет local=</span>{% endif %}</td>
<td>
<form method="post" action="{{ url_for('dns_delete') }}" onsubmit="return confirm('Удалить {{ r.domain }}?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="record_id" value="{{ r.record_id }}">
<button class="delete" type="submit">Удалить</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
<details><summary>Результат dnsmasq --test</summary><pre>{{ dns_status }}</pre></details>
</section>
</div>