router/templates/rules.rs.html

104 lines
3.6 KiB
HTML

@use crate::{
rules::Rule,
templates::{layout_html, return_home_html},
};
@(rules: &[(String, Rule)])
@:layout_html("Rules", {
<section>
<h1>Rules</h1>
</section>
<section>
<div class="table-wrapper">
<table>
<thead>
<th>Kind</th>
<th>Protocol</th>
<th class="port">Port</th>
<th>Destination IP</th>
<th class="port">Destination Port</th>
<th></th>
</thead>
</tbody>
@for (id, rule) in rules {
<tr>
@if let Some((dest_ip, dest_port)) = rule.as_forward() {
<td>Forward</td>
<td>@rule.proto</td>
<td class="port">@rule.port</td>
<td>@dest_ip</td>
<td class="port">@dest_port</td>
} else {
<td>Accept</td>
<td>@rule.proto</td>
<td class="port">@rule.port</td>
<td></td>
<td></td>
}
<td class="delete"><a href="/rules/@id">Delete</a></td>
</tr>
}
</tbody>
</table>
</div>
</section>
<section>
<h4>Forward Port</h4>
<form method="POST" action="/rules">
<div class="form-body">
<label for="proto">
<h4>Protocol</h4>
<div class="select-wrapper">
<select name="proto">
<option value="Tcp">TCP</option>
<option value="Udp">UDP</option>
</select>
</div>
</label>
<label for="port">
<h4>External Port</h4>
<input name="port" type="number" />
</label>
<input name="kind[type]" value="Forward" type="hidden" />
<label for="kind[dest_port]">
<h4>Internal Port</h4>
<input name="kind[dest_port]" type="number" />
</label>
<label for="kind[dest_ip]">
<h4>IP Address</h4>
<input name="kind[dest_ip]" type="text" />
</label>
</div>
<div class="submit">
<button type="submit">Forward!</button>
</div>
</form>
</section>
<section>
<h4>Accept Port</h4>
<form method="POST" action="/rules">
<div class="form-body">
<label for="proto">
<h4>Protocol</h4>
<div class="select-wrapper">
<select name="proto">
<option value="Tcp">TCP</option>
<option value="Udp">UDP</option>
</select>
</div>
</label>
<label for="port">
<h4>External Port</h4>
<input name="port" type="number" />
</label>
<input name="kind[type]" value="Accept" type="hidden" />
</div>
<div class="submit">
<button type="submit">Accept!</button>
</div>
</form>
</section>
@:return_home_html()
})