Remove comments
This commit is contained in:
@@ -79,48 +79,6 @@ function chunkPorts({ ports }: { ports: string[] }) {
|
|||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function acceptLines({
|
|
||||||
// chain,
|
|
||||||
// source,
|
|
||||||
// destination,
|
|
||||||
// protocol,
|
|
||||||
// ports,
|
|
||||||
// }: {
|
|
||||||
// chain: string;
|
|
||||||
// source: string;
|
|
||||||
// destination?: string;
|
|
||||||
// protocol?: string;
|
|
||||||
// ports: string[];
|
|
||||||
// }) {
|
|
||||||
// const lines: string[] = [];
|
|
||||||
// const protocols = protocolsForRule({
|
|
||||||
// protocol,
|
|
||||||
// has_ports: Boolean(ports[0]),
|
|
||||||
// });
|
|
||||||
// const port_chunks = ports[0] ? chunkPorts({ ports }) : [[]];
|
|
||||||
|
|
||||||
// for (let p = 0; p < protocols.length; p++) {
|
|
||||||
// const proto = protocols[p];
|
|
||||||
|
|
||||||
// for (let c = 0; c < port_chunks.length; c++) {
|
|
||||||
// const chunk = port_chunks[c] || [];
|
|
||||||
|
|
||||||
// lines.push(
|
|
||||||
// joinArgs([
|
|
||||||
// `iptables -A ${chain}`,
|
|
||||||
// `-s ${source}`,
|
|
||||||
// destination ? `-d ${destination}` : undefined,
|
|
||||||
// proto ? `-p ${proto}` : undefined,
|
|
||||||
// proto ? portMatch({ ports: chunk }) : undefined,
|
|
||||||
// `-j ACCEPT`,
|
|
||||||
// ]),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return lines;
|
|
||||||
// }
|
|
||||||
|
|
||||||
function acceptLines({
|
function acceptLines({
|
||||||
forward_chain,
|
forward_chain,
|
||||||
input_chain,
|
input_chain,
|
||||||
@@ -152,7 +110,6 @@ function acceptLines({
|
|||||||
? portMatch({ ports: chunk })
|
? portMatch({ ports: chunk })
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
// FORWARD: Forwarded ports / Docker containers / WAN
|
|
||||||
lines.push(
|
lines.push(
|
||||||
joinArgs([
|
joinArgs([
|
||||||
`iptables -A ${forward_chain}`,
|
`iptables -A ${forward_chain}`,
|
||||||
@@ -163,7 +120,6 @@ function acceptLines({
|
|||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
// INPUT: Only allow matching requests bound for THIS interface's host IP
|
|
||||||
lines.push(
|
lines.push(
|
||||||
joinArgs([
|
joinArgs([
|
||||||
`iptables -A ${input_chain}`,
|
`iptables -A ${input_chain}`,
|
||||||
@@ -174,28 +130,6 @@ function acceptLines({
|
|||||||
`-j ACCEPT`,
|
`-j ACCEPT`,
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
// // 1. FORWARD chain: Allows routed traffic (including Docker bridges/DNAT)
|
|
||||||
// lines.push(
|
|
||||||
// joinArgs([
|
|
||||||
// `iptables -A ${forward_chain}`,
|
|
||||||
// `-s ${source}`,
|
|
||||||
// proto ? `-p ${proto}` : undefined,
|
|
||||||
// port_match_str,
|
|
||||||
// `-j ACCEPT`,
|
|
||||||
// ]),
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // 2. INPUT chain: Allows traffic bound directly for host OS services
|
|
||||||
// lines.push(
|
|
||||||
// joinArgs([
|
|
||||||
// `iptables -A ${input_chain}`,
|
|
||||||
// `-s ${source}`,
|
|
||||||
// proto ? `-p ${proto}` : undefined,
|
|
||||||
// port_match_str,
|
|
||||||
// `-j ACCEPT`,
|
|
||||||
// ]),
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,27 +221,9 @@ export default function buildHostIptablesScripts({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (rule.rule_type == "all") {
|
|
||||||
// if (scoped_subnet) {
|
|
||||||
// accept_lines.push(
|
|
||||||
// `iptables -A ${forward} -s ${source} -d ${scoped_subnet} -j ACCEPT`,
|
|
||||||
// `iptables -A ${forward} -s ${source} -o ${target_interface} -j ACCEPT`,
|
|
||||||
// `iptables -A ${input} -s ${source} -j ACCEPT`,
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// accept_lines.push(
|
|
||||||
// `iptables -A ${forward} -s ${source} -j ACCEPT`,
|
|
||||||
// `iptables -A ${input} -s ${source} -j ACCEPT`,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (rule.rule_type == "all") {
|
if (rule.rule_type == "all") {
|
||||||
accept_lines.push(
|
accept_lines.push(
|
||||||
`iptables -A ${forward} -s ${source} -j ACCEPT`,
|
`iptables -A ${forward} -s ${source} -j ACCEPT`,
|
||||||
// `iptables -A ${input} -s ${source} -j ACCEPT`,
|
|
||||||
scoped_subnet
|
scoped_subnet
|
||||||
? `iptables -A ${input} -s ${source} -d ${scoped_subnet} -j ACCEPT`
|
? `iptables -A ${input} -s ${source} -d ${scoped_subnet} -j ACCEPT`
|
||||||
: `iptables -A ${input} -s ${source} -j ACCEPT`,
|
: `iptables -A ${input} -s ${source} -j ACCEPT`,
|
||||||
@@ -319,6 +235,7 @@ export default function buildHostIptablesScripts({
|
|||||||
const destination = normalizeIptablesDestination({
|
const destination = normalizeIptablesDestination({
|
||||||
destination: rule.destination,
|
destination: rule.destination,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed_ports = parsePortList({ ports: rule.ports });
|
const parsed_ports = parsePortList({ ports: rule.ports });
|
||||||
|
|
||||||
if (!parsed_ports.success) {
|
if (!parsed_ports.success) {
|
||||||
@@ -328,16 +245,6 @@ export default function buildHostIptablesScripts({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// accept_lines.push(
|
|
||||||
// ...acceptLines({
|
|
||||||
// chain: forward,
|
|
||||||
// source,
|
|
||||||
// destination,
|
|
||||||
// protocol: rule.protocol || "any",
|
|
||||||
// ports: parsed_ports.ports,
|
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
|
|
||||||
accept_lines.push(
|
accept_lines.push(
|
||||||
...acceptLines({
|
...acceptLines({
|
||||||
forward_chain: forward,
|
forward_chain: forward,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import type { BUN_SQLITE_WGUI_HOSTS } from "@/db/types/db";
|
import type { BUN_SQLITE_WGUI_HOSTS } from "@/db/types/db";
|
||||||
import fetchApi from "@/src/components/twui/utils/fetch/fetchApi";
|
import fetchApi from "@/src/components/twui/utils/fetch/fetchApi";
|
||||||
import type useFormInit from "@/src/hooks/use-form-init";
|
|
||||||
import type { ApiReqParams } from "@/src/types";
|
import type { ApiReqParams } from "@/src/types";
|
||||||
import type { APIResponseObject } from "@moduletrace/bunext/types";
|
import type { APIResponseObject } from "@moduletrace/bunext/types";
|
||||||
import type { Dispatch, SetStateAction } from "react";
|
import type { Dispatch, SetStateAction } from "react";
|
||||||
|
|||||||
@@ -3,13 +3,9 @@ import Input from "@/src/components/twui/form/Input";
|
|||||||
import Stack from "@/src/components/twui/layout/Stack";
|
import Stack from "@/src/components/twui/layout/Stack";
|
||||||
import useFormInit from "@/src/hooks/use-form-init";
|
import useFormInit from "@/src/hooks/use-form-init";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import fetchApi from "@/src/components/twui/utils/fetch/fetchApi";
|
|
||||||
import type { ApiReqParams } from "@/src/types";
|
|
||||||
import type { APIResponseObject } from "@moduletrace/bunext/types";
|
|
||||||
import Checkbox from "@/src/components/twui/form/Checkbox";
|
import Checkbox from "@/src/components/twui/form/Checkbox";
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from "tailwind-merge";
|
||||||
import useStatus from "@/src/components/twui/hooks/useStatus";
|
import useStatus from "@/src/components/twui/hooks/useStatus";
|
||||||
import LoadingOverlay from "@/src/components/twui/elements/LoadingOverlay";
|
|
||||||
import LoadingRectangleBlock from "@/src/components/twui/layout/LoadingRectangleBlock";
|
import LoadingRectangleBlock from "@/src/components/twui/layout/LoadingRectangleBlock";
|
||||||
import clientFetchIP from "../../(functions)/fetch-ip";
|
import clientFetchIP from "../../(functions)/fetch-ip";
|
||||||
import isLocalIPAddress from "../../../../../../utils/is-local-ip-address";
|
import isLocalIPAddress from "../../../../../../utils/is-local-ip-address";
|
||||||
@@ -50,17 +46,6 @@ export default function AddHostFormPublicIP({
|
|||||||
});
|
});
|
||||||
}, [form.interface, useLocalIP]);
|
}, [form.interface, useLocalIP]);
|
||||||
|
|
||||||
// if (existing_full?.public_ip_address) {
|
|
||||||
// return (
|
|
||||||
// <Input
|
|
||||||
// defaultValue={existing_full.public_ip_address || "N/A"}
|
|
||||||
// title="IP Address"
|
|
||||||
// readOnly
|
|
||||||
// showLabel
|
|
||||||
// />
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className={twMerge("w-full gap-2 relative")}>
|
<Stack className={twMerge("w-full gap-2 relative")}>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user