Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tun
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
tun
Commits
be090d56
Commit
be090d56
authored
Apr 03, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add noIn
parent
00d33ac6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
src/inventory.ts
src/inventory.ts
+8
-7
No files found.
src/inventory.ts
View file @
be090d56
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment