Commit f479bbd4 authored by nanahira's avatar nanahira

workaround

parent be090d56
......@@ -46,6 +46,9 @@ interface Gateway {
[key: string]: any;
pccWeight?: number;
pccRules?: string[];
noIn: boolean;
hidden: boolean;
redirectAllPorts: boolean;
}
class InventoryBuilder {
......@@ -133,7 +136,7 @@ class InventoryBuilder {
const gateways = await this.load('gateways2');
for (let gateway of gateways) {
gateway.isCN = this.hosts[gateway.router] && this.hosts[gateway.router].location.startsWith('CN');
for (const boolField of ['hidden', 'redirectAllPorts']) {
for (const boolField of ['hidden', 'redirectAllPorts', 'noIn']) {
gateway[boolField] = !!gateway[boolField]
}
if (gateway.mark) {
......@@ -625,8 +628,10 @@ class InventoryBuilder {
// 如果都不能做,抛异常
// 两个参数对调返回的结果必须相反
gatewayCompare(localGateway: any, remoteGateway: any): boolean {
// 两边至少一个有IPv4地址才能连
assert(localGateway.ipv4 !== '' || remoteGateway.ipv4 !== '');
// 两边至少一个有 IPv4 地址,或两边都有 IPv6 地址才能连
assert(localGateway.ipv4 !== '' || remoteGateway.ipv4 !== '' || (localGateway.ipv6 !== '' && remoteGateway.ipv6 !== ''));
// 两边不能都是只能入站的
assert(!localGateway.noIn || !remoteGateway.noIn);
const localScore = this.gatewayCompareScore(localGateway);
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