Commit be090d56 authored by nanahira's avatar nanahira

add noIn

parent 00d33ac6
......@@ -450,7 +450,7 @@ class InventoryBuilder {
//console.log(remoteGateway.name);
let remoteAddress = remoteGateway.address || null;
const preferV6 = (!remoteGateway.ipv4 || params.ipv6 === 'on' || params.ipv6 === 'force') && remoteGateway.ipv6 && params.ipv6 !== 'off';
if (!localGateway.ipv6 && preferV6) {
if (!localGateway.ipv6 && preferV6 || localGateway.noIn) {
remoteAddress = null;
}
if (remoteAddress && params.ipv6 === 'force') {
......@@ -615,10 +615,8 @@ class InventoryBuilder {
})[gateway.ipv4] || 0;
score |= ipv4Score << offset;
offset += 2;
const globalSSHScore = ({ // 1 bit
'globalssh': 1
})[gateway.ssh] || 0;
score |= globalSSHScore << offset;
const noInScore = gateway.noIn ? 1 : 0; // 1 bit
score |= noInScore << offset;
offset += 1;
return score;
}
......@@ -629,13 +627,16 @@ class InventoryBuilder {
gatewayCompare(localGateway: any, remoteGateway: any): boolean {
// 两边至少一个有IPv4地址才能连
assert(localGateway.ipv4 !== '' || remoteGateway.ipv4 !== '');
const localScore = this.gatewayCompareScore(localGateway);
const remoteScore = this.gatewayCompareScore(remoteGateway);
// 两边必须相反
assert(this.gatewayCompareScore(localGateway) !== this.gatewayCompareScore(remoteGateway));
assert(localScore !== remoteScore);
// 两边只有一边是GlobalSSH的,GlobalSSH做s
// 只有一边有static的,就static做s
// 如果都static,那么没有NAT的或者dmz的做s
// 如果都还相同,就让列表中更靠前的做s
return this.gatewayCompareScore(localGateway) > this.gatewayCompareScore(remoteGateway);
return localScore > remoteScore;
}
gatewayCompareOcserv(local: any, remote: any, localGateway: any, remoteGateway: any): boolean {
......
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