Add Layer4 rules support

This commit is contained in:
2024-01-04 15:30:25 +01:00
parent c40ee037da
commit 975b4ab395
2 changed files with 187 additions and 13 deletions

View File

@ -0,0 +1,28 @@
import { TextInput } from "./TextInput";
export function PortInput(p: {
editable: boolean;
label: string;
value?: number;
onChange: (value: number | undefined) => void;
}): React.ReactElement {
return (
<TextInput
{...p}
value={p.value?.toString() ?? ""}
type="number"
onValueChange={(v) => {
p.onChange?.(sanitizePort(v));
}}
/>
);
}
function sanitizePort(port?: string): number | undefined {
if (port === undefined) return undefined;
const val = Number(port);
if (val < 0) return 0;
if (val > 65535) return 65535;
return val;
}