Revert to previous version
This commit is contained in:
@@ -27,16 +27,6 @@ function joinArgs(parts: (string | undefined)[]) {
|
|||||||
return parts.filter(Boolean).join(" ");
|
return parts.filter(Boolean).join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
function deriveGatewayIp(cidr?: string): string | undefined {
|
|
||||||
if (!cidr) return undefined;
|
|
||||||
const ip = cidr.split("/")[0];
|
|
||||||
if (!ip) return undefined;
|
|
||||||
const parts = ip.split(".");
|
|
||||||
if (parts.length !== 4) return undefined;
|
|
||||||
// Assume host/gateway is .1 on the subnet
|
|
||||||
return `${parts[0]}.${parts[1]}.${parts[2]}.1`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function protocolsForRule({
|
function protocolsForRule({
|
||||||
protocol,
|
protocol,
|
||||||
has_ports,
|
has_ports,
|
||||||
@@ -175,7 +165,6 @@ export default function buildHostIptablesScripts({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const scoped_subnet = host_subnet?.trim();
|
const scoped_subnet = host_subnet?.trim();
|
||||||
const host_wg_ip = deriveGatewayIp(scoped_subnet);
|
|
||||||
|
|
||||||
if (scoped_subnet && !validateIpv4Cidr({ value: scoped_subnet })) {
|
if (scoped_subnet && !validateIpv4Cidr({ value: scoped_subnet })) {
|
||||||
return {
|
return {
|
||||||
@@ -186,7 +175,7 @@ export default function buildHostIptablesScripts({
|
|||||||
|
|
||||||
const { forward, input } = deriveIptablesChainNames({ host_id });
|
const { forward, input } = deriveIptablesChainNames({ host_id });
|
||||||
|
|
||||||
const masquerade_match = scoped_subnet ? `-s ${scoped_subnet}` : ``;
|
const masquerade_match = scoped_subnet ? `-s ${scoped_subnet} ` : ``;
|
||||||
const accept_lines: string[] = [
|
const accept_lines: string[] = [
|
||||||
`iptables -A ${forward} -o ${interface_name} -j DROP`,
|
`iptables -A ${forward} -o ${interface_name} -j DROP`,
|
||||||
];
|
];
|
||||||
@@ -237,18 +226,14 @@ export default function buildHostIptablesScripts({
|
|||||||
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`,
|
||||||
host_wg_ip
|
scoped_subnet
|
||||||
? `iptables -A ${input} -s ${source} -d ${host_wg_ip} -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`,
|
||||||
);
|
);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const destination = normalizeIptablesDestination({
|
|
||||||
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) {
|
||||||
@@ -265,7 +250,7 @@ export default function buildHostIptablesScripts({
|
|||||||
source,
|
source,
|
||||||
protocol: rule.protocol || "any",
|
protocol: rule.protocol || "any",
|
||||||
ports: parsed_ports.ports,
|
ports: parsed_ports.ports,
|
||||||
host_wg_ip,
|
host_wg_ip: scoped_subnet,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user