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
43df9b4e
Commit
43df9b4e
authored
Mar 24, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move some vars to utility
parent
eac2fca1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
6 deletions
+17
-6
lists/gfwiplist-patch.yaml
lists/gfwiplist-patch.yaml
+0
-0
lists/special.txt
lists/special.txt
+1
-1
src/inventory.ts
src/inventory.ts
+16
-5
No files found.
gfwiplist-patch.yaml
→
lists/
gfwiplist-patch.yaml
View file @
43df9b4e
File moved
lists/special.txt
View file @
43df9b4e
0.0.0.0/8
0.0.0.0/8
10.0.0.0/
8
10.0.0.0/
7
100.64.0.0/10
100.64.0.0/10
127.0.0.0/8
127.0.0.0/8
169.254.0.0/16
169.254.0.0/16
...
...
src/inventory.ts
View file @
43df9b4e
...
@@ -40,10 +40,22 @@ class InventoryBuilder {
...
@@ -40,10 +40,22 @@ class InventoryBuilder {
// console.log(Object.values(this.hosts));
// console.log(Object.values(this.hosts));
const
hosts
=
Object
.
fromEntries
(
Object
.
values
(
this
.
hosts
).
map
(
h
=>
[
h
.
host
,
this
.
host_vars
(
h
)]));
const
hosts
=
Object
.
fromEntries
(
Object
.
values
(
this
.
hosts
).
map
(
h
=>
[
h
.
host
,
this
.
host_vars
(
h
)]));
// console.log(hosts);
// console.log(hosts);
const
result
=
YAML
.
stringify
({
wg
:
{
hosts
}
});
const
vars
=
await
this
.
loadUtilities
();
const
result
=
YAML
.
stringify
({
wg
:
{
hosts
,
vars
}
});
return
fs
.
promises
.
writeFile
(
'
result/inventory.yaml
'
,
result
);
return
fs
.
promises
.
writeFile
(
'
result/inventory.yaml
'
,
result
);
}
}
async
loadUtilities
()
{
const
raw_data
=
_
.
keyBy
(
await
this
.
load
(
'
configurations
'
),
'
key
'
);
const
vars
=
{
all_subnets
:
JSON
.
parse
(
JSON
.
stringify
(
this
.
all_subnets
))
};
for
(
let
col
in
raw_data
)
{
vars
[
col
]
=
raw_data
[
col
].
value
;
}
return
vars
;
}
host_vars
(
host
)
{
host_vars
(
host
)
{
const
connections
=
[];
const
connections
=
[];
const
null_connection
=
"
10000,null
"
;
const
null_connection
=
"
10000,null
"
;
...
@@ -71,15 +83,14 @@ class InventoryBuilder {
...
@@ -71,15 +83,14 @@ class InventoryBuilder {
return
{
return
{
ansible_ssh_user
:
host
.
user
,
ansible_ssh_user
:
host
.
user
,
address
:
host
.
address
,
address
:
host
.
address
,
isCN
:
host
.
location
.
startsWith
(
"
CN
"
)
isCN
:
host
.
location
.
startsWith
(
"
CN
"
)
,
key
:
host
.
wgPrivateKey
,
key
:
host
.
wgPrivateKey
,
frpsPort
:
host
.
frpsPort
,
frpsPort
:
host
.
frpsPort
,
frpToken
:
host
.
frpToken
,
//
frpToken: host.frpToken,
//gateways: _.mapValues(this.gateways[host.name], gw => _.pick(gw, ['mark_gateway'])),
//gateways: _.mapValues(this.gateways[host.name], gw => _.pick(gw, ['mark_gateway'])),
gateways
:
_
.
values
(
this
.
gateways
[
host
.
name
]),
gateways
:
_
.
values
(
this
.
gateways
[
host
.
name
]),
connections
,
connections
,
lan_interfaces
,
lan_interfaces
all_subnets
:
JSON
.
parse
(
JSON
.
stringify
(
this
.
all_subnets
))
};
};
}
}
...
...
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