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
8d53be87
Commit
8d53be87
authored
Dec 13, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update nat score
parent
39c589b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
src/inventory.ts
src/inventory.ts
+13
-10
No files found.
src/inventory.ts
View file @
8d53be87
...
...
@@ -23,6 +23,7 @@ class InventoryBuilder {
async
loadGateways
()
{
const
gateways
=
await
this
.
load
(
'
gateways2
'
);
for
(
let
gateway
of
gateways
)
{
gateway
.
isCN
=
this
.
hosts
[
gateway
.
router
].
location
.
startsWith
(
"
CN
"
);
if
(
gateway
.
mark
)
{
gateway
.
selectionMark
=
gateway
.
mark
+
50
;
}
else
{
...
...
@@ -231,21 +232,23 @@ class InventoryBuilder {
// frps还是frpc的积分,NAT越有利分越高
gatewayCompareScore
(
gateway
:
any
):
number
{
let
score
:
number
=
0xff
-
gateway
.
id
;
const
ipv4Score
=
({
"
static
"
:
2
,
"
dynamic
"
:
1
})[
gateway
.
ipv4
]
||
0
;
score
|=
ipv4Score
<<
12
;
const
ipv4NatScore
=
({
let
score
:
number
=
0xff
-
gateway
.
id
;
// 8 bits
const
isCNScore
=
gateway
.
isCN
?
1
:
0
;
// 1 bit
score
|=
isCNScore
<<
8
;
const
ipv4NatScore
=
({
// 2 bits
"
ports
"
:
0
,
"
dmz
"
:
1
})[
gateway
.
ipv4Nat
]
||
2
;
score
|=
ipv4NatScore
<<
10
;
const
globalSSHScore
=
({
score
|=
ipv4NatScore
<<
9
;
const
ipv4Score
=
({
// 2 bits
"
static
"
:
2
,
"
dynamic
"
:
1
})[
gateway
.
ipv4
]
||
0
;
score
|=
ipv4Score
<<
11
;
const
globalSSHScore
=
({
// 1 bit
"
globalssh
"
:
1
})[
gateway
.
ssh
]
||
0
;
score
|=
globalSSHScore
<<
1
3
;
score
|=
globalSSHScore
<<
1
2
;
return
score
;
}
...
...
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