Commit c90f3e56 authored by nanahira's avatar nanahira

fix

parent f479bbd4
...@@ -46,7 +46,7 @@ interface Gateway { ...@@ -46,7 +46,7 @@ interface Gateway {
[key: string]: any; [key: string]: any;
pccWeight?: number; pccWeight?: number;
pccRules?: string[]; pccRules?: string[];
noIn: boolean; noOut: boolean;
hidden: boolean; hidden: boolean;
redirectAllPorts: boolean; redirectAllPorts: boolean;
} }
...@@ -136,7 +136,7 @@ class InventoryBuilder { ...@@ -136,7 +136,7 @@ class InventoryBuilder {
const gateways = await this.load('gateways2'); const gateways = await this.load('gateways2');
for (let gateway of gateways) { for (let gateway of gateways) {
gateway.isCN = this.hosts[gateway.router] && this.hosts[gateway.router].location.startsWith('CN'); gateway.isCN = this.hosts[gateway.router] && this.hosts[gateway.router].location.startsWith('CN');
for (const boolField of ['hidden', 'redirectAllPorts', 'noIn']) { for (const boolField of ['hidden', 'redirectAllPorts', 'noOut']) {
gateway[boolField] = !!gateway[boolField] gateway[boolField] = !!gateway[boolField]
} }
if (gateway.mark) { if (gateway.mark) {
...@@ -453,7 +453,7 @@ class InventoryBuilder { ...@@ -453,7 +453,7 @@ class InventoryBuilder {
//console.log(remoteGateway.name); //console.log(remoteGateway.name);
let remoteAddress = remoteGateway.address || null; let remoteAddress = remoteGateway.address || null;
const preferV6 = (!remoteGateway.ipv4 || params.ipv6 === 'on' || params.ipv6 === 'force') && remoteGateway.ipv6 && params.ipv6 !== 'off'; const preferV6 = (!remoteGateway.ipv4 || params.ipv6 === 'on' || params.ipv6 === 'force') && remoteGateway.ipv6 && params.ipv6 !== 'off';
if (!localGateway.ipv6 && preferV6 || localGateway.noIn) { if (!localGateway.ipv6 && preferV6 || localGateway.noOut) {
remoteAddress = null; remoteAddress = null;
} }
if (remoteAddress && params.ipv6 === 'force') { if (remoteAddress && params.ipv6 === 'force') {
...@@ -618,7 +618,7 @@ class InventoryBuilder { ...@@ -618,7 +618,7 @@ class InventoryBuilder {
})[gateway.ipv4] || 0; })[gateway.ipv4] || 0;
score |= ipv4Score << offset; score |= ipv4Score << offset;
offset += 2; offset += 2;
const noInScore = gateway.noIn ? 1 : 0; // 1 bit const noInScore = gateway.noOut ? 1 : 0; // 1 bit
score |= noInScore << offset; score |= noInScore << offset;
offset += 1; offset += 1;
return score; return score;
...@@ -631,7 +631,7 @@ class InventoryBuilder { ...@@ -631,7 +631,7 @@ class InventoryBuilder {
// 两边至少一个有 IPv4 地址,或两边都有 IPv6 地址才能连 // 两边至少一个有 IPv4 地址,或两边都有 IPv6 地址才能连
assert(localGateway.ipv4 !== '' || remoteGateway.ipv4 !== '' || (localGateway.ipv6 !== '' && remoteGateway.ipv6 !== '')); assert(localGateway.ipv4 !== '' || remoteGateway.ipv4 !== '' || (localGateway.ipv6 !== '' && remoteGateway.ipv6 !== ''));
// 两边不能都是只能入站的 // 两边不能都是只能入站的
assert(!localGateway.noIn || !remoteGateway.noIn); assert(!localGateway.noOut || !remoteGateway.noOut);
const localScore = this.gatewayCompareScore(localGateway); const localScore = this.gatewayCompareScore(localGateway);
const remoteScore = this.gatewayCompareScore(remoteGateway); const remoteScore = this.gatewayCompareScore(remoteGateway);
......
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