swarm-ui: the egress card on the swarm page lists and edits the swarm-wide denied domains, and says which hives have not applied them
This commit is contained in:
parent
0bc350a8a1
commit
0421f28d49
1 changed files with 210 additions and 103 deletions
|
|
@ -32,6 +32,7 @@ import { Panel } from "../../ui/panel/Panel.js";
|
|||
import { TextField } from "../../ui/text-field/TextField.js";
|
||||
import {
|
||||
ALLOWED_DOMAINS_URL,
|
||||
DENIED_DOMAINS_URL,
|
||||
entriesFor,
|
||||
entryBody,
|
||||
entryGroups,
|
||||
|
|
@ -150,17 +151,20 @@ export function AllowedDomains({ agent }: { agent: string }) {
|
|||
);
|
||||
}
|
||||
|
||||
// The add form of one allowed domain: for `agent`, or for every agent. With no
|
||||
// `agent` (the swarm page) it can only add a swarm-wide entry.
|
||||
// The add form of one allowed or denied domain: for `agent`, or for every
|
||||
// agent. With no `agent` (the swarm page) it can only add a swarm-wide entry.
|
||||
export function AddForm({
|
||||
agent,
|
||||
kind = "allow",
|
||||
onClose,
|
||||
onAdded,
|
||||
}: {
|
||||
agent?: string;
|
||||
kind?: "allow" | "deny";
|
||||
onClose: () => void;
|
||||
onAdded: () => void;
|
||||
}) {
|
||||
const deny = kind === "deny";
|
||||
const [domain, setDomain] = useState("");
|
||||
const [forSwarm, setForSwarm] = useState(agent === undefined);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
|
@ -171,7 +175,7 @@ export function AddForm({
|
|||
setBusy(true);
|
||||
setProblem(null);
|
||||
try {
|
||||
const r = await fetch(ALLOWED_DOMAINS_URL, {
|
||||
const r = await fetch(deny ? DENIED_DOMAINS_URL : ALLOWED_DOMAINS_URL, {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify(entryBody(domain, forSwarm, agent ?? "")),
|
||||
|
|
@ -191,28 +195,30 @@ export function AddForm({
|
|||
|
||||
return (
|
||||
<Panel
|
||||
title={
|
||||
agent === undefined
|
||||
? "allowed domain — swarm-wide"
|
||||
: `allowed domain — ${agent}`
|
||||
}
|
||||
title={`${deny ? "denied" : "allowed"} domain — ${agent ?? "swarm-wide"}`}
|
||||
icon="🌐"
|
||||
onClose={onClose}
|
||||
>
|
||||
<p>
|
||||
{agent === undefined
|
||||
? "Lets every agent reach one more name through its hive's proxy."
|
||||
: `Lets ${agent} reach one more name through its hive's proxy, or every agent when the box below is ticked.`}{" "}
|
||||
{deny
|
||||
? agent === undefined
|
||||
? "Stops every agent reaching one name through its hive's proxy."
|
||||
: `Stops ${agent} reaching one name through its hive's proxy, or every agent when the box below is ticked.`
|
||||
: agent === undefined
|
||||
? "Lets every agent reach one more name through its hive's proxy."
|
||||
: `Lets ${agent} reach one more name through its hive's proxy, or every agent when the box below is ticked.`}{" "}
|
||||
A name needs at least two labels, such as <code>github.com</code>; a
|
||||
leading dot, as in <code>.githubusercontent.com</code>, also allows
|
||||
every subdomain. IP addresses and wildcards are refused. A name that
|
||||
resolves to a private address stays blocked. The entry adds to the names
|
||||
each hive's own configuration allows. The hive reads a change within
|
||||
about 30 seconds.
|
||||
leading dot, as in <code>.githubusercontent.com</code>, also{" "}
|
||||
{deny ? "refuses" : "allows"} every subdomain. IP addresses and
|
||||
wildcards are refused.{" "}
|
||||
{deny
|
||||
? "A denied name is refused in every egress mode, even when a swarm entry or a hive's own configuration allows it."
|
||||
: "A name that resolves to a private address stays blocked. The entry adds to the names each hive's own configuration allows."}{" "}
|
||||
The hive reads a change within about 30 seconds.
|
||||
</p>
|
||||
<form class="ui-agent-limits-form" onSubmit={(e) => void save(e)}>
|
||||
<TextField
|
||||
id="allowed-domain"
|
||||
id={deny ? "denied-domain" : "allowed-domain"}
|
||||
label="domain"
|
||||
value={domain}
|
||||
placeholder="e.g. github.com"
|
||||
|
|
@ -220,7 +226,7 @@ export function AddForm({
|
|||
/>
|
||||
{agent === undefined ? null : (
|
||||
<CheckboxField
|
||||
id="allowed-domain-swarm"
|
||||
id={deny ? "denied-domain-swarm" : "allowed-domain-swarm"}
|
||||
label="for every agent in the swarm"
|
||||
checked={forSwarm}
|
||||
onChange={setForSwarm}
|
||||
|
|
|
|||
Loading…
Reference in a new issue