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
f479bbd4
Commit
f479bbd4
authored
Apr 03, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
workaround
parent
be090d56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
src/inventory.ts
src/inventory.ts
+8
-3
No files found.
src/inventory.ts
View file @
f479bbd4
...
...
@@ -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
);
...
...
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