Commit a50a26b6 authored by nanahira's avatar nanahira

add outer oc redirect

parent c98bb995
......@@ -81,6 +81,9 @@ interface_switch_redirect() {
REDIR_TARGET_PORTS=$4
$IPTABLES_EXEC -t nat "$OPTION" NEXTGEN_SWITCH -m mark --mark $MARK -i mc+ -m set --match-set mycard src -m set ! --match-set mycard dst -p tcp -m multiport --dports $REDIR_TARGET_PORTS -m multiport ! --dports {{allRedirectServerPorts}} -j DNAT --to-destination {{address}}:$REDIR_SERVER_PORT
$IPTABLES_EXEC -t nat "$OPTION" NEXTGEN_SWITCH -m mark --mark $MARK -i ocs+ -m set --match-set mycard src -m set ! --match-set mycard dst -p tcp -m multiport --dports $REDIR_TARGET_PORTS -m multiport ! --dports {{allRedirectServerPorts}} -j DNAT --to-destination {{address}}:$REDIR_SERVER_PORT
{% for entry in relatedOcServers %}
$IPTABLES_EXEC -t nat "$OPTION" NEXTGEN_SWITCH -m mark --mark $MARK -s {{entry.source}} -m mac --mac-source {{entry.mac}} -m set ! --match-set mycard dst -p tcp -m multiport --dports $REDIR_TARGET_PORTS -m multiport ! --dports {{allRedirectServerPorts}} -j DNAT --to-destination {{address}}:$REDIR_SERVER_PORT
{% endfor %}
}
_search_and_remove() {
......
......@@ -110,7 +110,7 @@ class InventoryBuilder {
if (!domain || domain.match(/(\d{1,3}\.){3}\d{1,3}/)) {
return domain;
}
return new Promise<string>(async(resolve) => {
return new Promise<string>(async (resolve) => {
const cacheKey = `${domain}-${ipv6 ? ':v6' : ':v4'}`;
if (this.resolveCache.has(cacheKey)) {
resolve(this.resolveCache.get(cacheKey));
......@@ -160,11 +160,13 @@ class InventoryBuilder {
this.hosts = _.keyBy(await this.load('nextgen2'), 'name');
const subnets = await this.load('subnets');
for (const [name, router] of Object.entries(this.hosts)) {
router.lanInterfaces = subnets
.filter((subnet) => subnet.router === name)
const relatedSubnets = subnets
.filter((subnet) => subnet.router === name);
router.lanInterfaces = relatedSubnets
.map((subnet) => subnet.interface)
.filter((i) => i);
router.subnets = subnets.filter((subnet) => subnet.router === name).map((subnet) => subnet.subnet);
router.relatedOcServers = relatedSubnets.filter(subnet => subnet.ocServer).map(subnet => ({ mac: subnet.ocServer, source: subnet.subnet }));
router.subnets = relatedSubnets.map((subnet) => subnet.subnet);
}
this.vars = await this.loadUtilities();
// @ts-ignore
......@@ -437,6 +439,7 @@ class InventoryBuilder {
gostConfig,
installGost: !!gostConfig,
allRedirectServerPorts,
relatedOcServers: host.relatedOcServers
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment