mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-09 20:26:40 +00:00
enforce unique port and ip targets
This commit is contained in:
@@ -130,6 +130,22 @@ export default function ReverseProxyTargets(props: {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function addTarget(data: AddTargetFormValues) {
|
async function addTarget(data: AddTargetFormValues) {
|
||||||
|
// Check if target with same IP, port and method already exists
|
||||||
|
const isDuplicate = targets.some(
|
||||||
|
target => target.ip === data.ip &&
|
||||||
|
target.port === data.port &&
|
||||||
|
target.method === data.method
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isDuplicate) {
|
||||||
|
toast({
|
||||||
|
variant: "destructive",
|
||||||
|
title: "Duplicate target",
|
||||||
|
description: "A target with these settings already exists",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const newTarget: LocalTarget = {
|
const newTarget: LocalTarget = {
|
||||||
...data,
|
...data,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
@@ -141,7 +157,7 @@ export default function ReverseProxyTargets(props: {
|
|||||||
setTargets([...targets, newTarget]);
|
setTargets([...targets, newTarget]);
|
||||||
addTargetForm.reset();
|
addTargetForm.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeTarget = (targetId: number) => {
|
const removeTarget = (targetId: number) => {
|
||||||
setTargets([
|
setTargets([
|
||||||
...targets.filter((target) => target.targetId !== targetId),
|
...targets.filter((target) => target.targetId !== targetId),
|
||||||
|
|||||||
Reference in New Issue
Block a user