mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-08 03:36:37 +00:00
remove target unique check
This commit is contained in:
@@ -163,12 +163,8 @@ export async function createTarget(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (existingTarget) {
|
if (existingTarget) {
|
||||||
return next(
|
// log a warning
|
||||||
createHttpError(
|
logger.warn(`Target with IP ${targetData.ip}, port ${targetData.port}, method ${targetData.method} already exists for resource ID ${resourceId}`);
|
||||||
HttpCode.BAD_REQUEST,
|
|
||||||
`Target with IP ${targetData.ip}, port ${targetData.port}, method ${targetData.method} already exists for resource ID ${resourceId}`
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let newTarget: Target[] = [];
|
let newTarget: Target[] = [];
|
||||||
|
|||||||
@@ -170,12 +170,8 @@ export async function updateTarget(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (foundTarget) {
|
if (foundTarget) {
|
||||||
return next(
|
// log a warning
|
||||||
createHttpError(
|
logger.warn(`Target with IP ${targetData.ip}, port ${targetData.port}, method ${targetData.method} already exists for resource ID ${target.resourceId}`);
|
||||||
HttpCode.BAD_REQUEST,
|
|
||||||
`Target with IP ${targetData.ip}, port ${targetData.port}, and method ${targetData.method} already exists on the same site.`
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { internalPort, targetIps } = await pickPort(site.siteId!, db);
|
const { internalPort, targetIps } = await pickPort(site.siteId!, db);
|
||||||
|
|||||||
@@ -501,25 +501,6 @@ export default function ReverseProxyTargets(props: {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if target with same IP, port and method already exists
|
|
||||||
const isDuplicate = targets.some(
|
|
||||||
(t) =>
|
|
||||||
t.targetId !== target.targetId &&
|
|
||||||
t.ip === target.ip &&
|
|
||||||
t.port === target.port &&
|
|
||||||
t.method === target.method &&
|
|
||||||
t.siteId === target.siteId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isDuplicate) {
|
|
||||||
toast({
|
|
||||||
variant: "destructive",
|
|
||||||
title: t("targetErrorDuplicate"),
|
|
||||||
description: t("targetErrorDuplicateDescription")
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setTargetsLoading(true);
|
setTargetsLoading(true);
|
||||||
|
|
||||||
@@ -585,24 +566,6 @@ export default function ReverseProxyTargets(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function addTarget(data: z.infer<typeof addTargetSchema>) {
|
async function addTarget(data: z.infer<typeof addTargetSchema>) {
|
||||||
// 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 &&
|
|
||||||
target.siteId === data.siteId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isDuplicate) {
|
|
||||||
toast({
|
|
||||||
variant: "destructive",
|
|
||||||
title: t("targetErrorDuplicate"),
|
|
||||||
description: t("targetErrorDuplicateDescription")
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (site && site.type == "wireguard" && site.subnet) {
|
// if (site && site.type == "wireguard" && site.subnet) {
|
||||||
// // make sure that the target IP is within the site subnet
|
// // make sure that the target IP is within the site subnet
|
||||||
// const targetIp = data.ip;
|
// const targetIp = data.ip;
|
||||||
@@ -899,7 +862,7 @@ export default function ReverseProxyTargets(props: {
|
|||||||
|
|
||||||
const healthCheckColumn: ColumnDef<LocalTarget> = {
|
const healthCheckColumn: ColumnDef<LocalTarget> = {
|
||||||
accessorKey: "healthCheck",
|
accessorKey: "healthCheck",
|
||||||
header: t("healthCheck"),
|
header: () => (<span className="p-3">{t("healthCheck")}</span>),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const status = row.original.hcHealth || "unknown";
|
const status = row.original.hcHealth || "unknown";
|
||||||
const isEnabled = row.original.hcEnabled;
|
const isEnabled = row.original.hcEnabled;
|
||||||
@@ -971,7 +934,7 @@ export default function ReverseProxyTargets(props: {
|
|||||||
|
|
||||||
const matchPathColumn: ColumnDef<LocalTarget> = {
|
const matchPathColumn: ColumnDef<LocalTarget> = {
|
||||||
accessorKey: "path",
|
accessorKey: "path",
|
||||||
header: t("matchPath"),
|
header: () => (<span className="p-3">{t("matchPath")}</span>),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const hasPathMatch = !!(
|
const hasPathMatch = !!(
|
||||||
row.original.path || row.original.pathMatchType
|
row.original.path || row.original.pathMatchType
|
||||||
@@ -1033,7 +996,7 @@ export default function ReverseProxyTargets(props: {
|
|||||||
|
|
||||||
const addressColumn: ColumnDef<LocalTarget> = {
|
const addressColumn: ColumnDef<LocalTarget> = {
|
||||||
accessorKey: "address",
|
accessorKey: "address",
|
||||||
header: t("address"),
|
header: () => (<span className="p-3">{t("address")}</span>),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const selectedSite = sites.find(
|
const selectedSite = sites.find(
|
||||||
(site) => site.siteId === row.original.siteId
|
(site) => site.siteId === row.original.siteId
|
||||||
@@ -1052,7 +1015,7 @@ export default function ReverseProxyTargets(props: {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center w-full">
|
<div className="flex items-center w-full">
|
||||||
<div className="flex items-center w-full justify-start py-0 space-x-2 px-0 cursor-default border border-input shadow-2xs rounded-md">
|
<div className="flex items-center w-full justify-start py-0 space-x-2 px-0 cursor-default border border-input rounded-md">
|
||||||
{selectedSite &&
|
{selectedSite &&
|
||||||
selectedSite.type === "newt" &&
|
selectedSite.type === "newt" &&
|
||||||
(() => {
|
(() => {
|
||||||
@@ -1247,7 +1210,7 @@ export default function ReverseProxyTargets(props: {
|
|||||||
|
|
||||||
const rewritePathColumn: ColumnDef<LocalTarget> = {
|
const rewritePathColumn: ColumnDef<LocalTarget> = {
|
||||||
accessorKey: "rewritePath",
|
accessorKey: "rewritePath",
|
||||||
header: t("rewritePath"),
|
header: () => (<span className="p-3">{t("rewritePath")}</span>),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const hasRewritePath = !!(
|
const hasRewritePath = !!(
|
||||||
row.original.rewritePath || row.original.rewritePathType
|
row.original.rewritePath || row.original.rewritePathType
|
||||||
@@ -1317,7 +1280,7 @@ export default function ReverseProxyTargets(props: {
|
|||||||
|
|
||||||
const enabledColumn: ColumnDef<LocalTarget> = {
|
const enabledColumn: ColumnDef<LocalTarget> = {
|
||||||
accessorKey: "enabled",
|
accessorKey: "enabled",
|
||||||
header: t("enabled"),
|
header: () => (<span className="p-3">{t("enabled")}</span>),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center justify-center w-full">
|
<div className="flex items-center justify-center w-full">
|
||||||
<Switch
|
<Switch
|
||||||
@@ -1338,8 +1301,9 @@ export default function ReverseProxyTargets(props: {
|
|||||||
|
|
||||||
const actionsColumn: ColumnDef<LocalTarget> = {
|
const actionsColumn: ColumnDef<LocalTarget> = {
|
||||||
id: "actions",
|
id: "actions",
|
||||||
|
header: () => (<span className="p-3">{t("actions")}</span>),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center justify-end w-full">
|
<div className="flex items-center w-full">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() => removeTarget(row.original.targetId)}
|
onClick={() => removeTarget(row.original.targetId)}
|
||||||
|
|||||||
@@ -425,24 +425,6 @@ export default function Page() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function addTarget(data: z.infer<typeof addTargetSchema>) {
|
async function addTarget(data: z.infer<typeof addTargetSchema>) {
|
||||||
// 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 &&
|
|
||||||
target.siteId === data.siteId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isDuplicate) {
|
|
||||||
toast({
|
|
||||||
variant: "destructive",
|
|
||||||
title: t("targetErrorDuplicate"),
|
|
||||||
description: t("targetErrorDuplicateDescription")
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const site = sites.find((site) => site.siteId === data.siteId);
|
const site = sites.find((site) => site.siteId === data.siteId);
|
||||||
|
|
||||||
const isHttp = baseForm.watch("http");
|
const isHttp = baseForm.watch("http");
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ export function DNSRecordsDataTable<TData, TValue>({
|
|||||||
{table.getHeaderGroups().map((headerGroup) => (
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
<TableRow
|
<TableRow
|
||||||
key={headerGroup.id}
|
key={headerGroup.id}
|
||||||
className="bg-secondary dark:bg-transparent"
|
|
||||||
>
|
>
|
||||||
{headerGroup.headers.map((header) => (
|
{headerGroup.headers.map((header) => (
|
||||||
<TableHead key={header.id}>
|
<TableHead key={header.id}>
|
||||||
|
|||||||
Reference in New Issue
Block a user