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
b4992960
Commit
b4992960
authored
Aug 13, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gost
parent
2280142f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
6 deletions
+53
-6
ansible/configure.yaml
ansible/configure.yaml
+13
-0
src/inventory.ts
src/inventory.ts
+40
-6
No files found.
ansible/configure.yaml
View file @
b4992960
...
@@ -144,6 +144,12 @@
...
@@ -144,6 +144,12 @@
dest
:
'
{{ansible_user_dir}}/nextgen-network/services/babeld.conf'
dest
:
'
{{ansible_user_dir}}/nextgen-network/services/babeld.conf'
#notify: restart_babeld
#notify: restart_babeld
when
:
not noBird and not systemBird
when
:
not noBird and not systemBird
-
name
:
gost.json
copy
:
src
:
'
{{gostConfig
|
to_nice_json}}'
dest
:
'
{{ansible_user_dir}}/nextgen-network/services/gost.json'
notify
:
restart_gost
when
:
installGost
-
name
:
monitor route plans
-
name
:
monitor route plans
template
:
template
:
src
:
route-plans.j2
src
:
route-plans.j2
...
@@ -231,6 +237,13 @@
...
@@ -231,6 +237,13 @@
services
:
services
:
-
ocserv
-
ocserv
when
:
not noBird
when
:
not noBird
-
name
:
restart_gost
docker_compose
:
project_src
:
'
{{ansible_user_dir}}/nextgen-network/services'
restarted
:
true
services
:
-
gost
when
:
installGost
-
name
:
restart_openconnect
-
name
:
restart_openconnect
docker_compose
:
docker_compose
:
project_src
:
'
{{ansible_user_dir}}/nextgen-network/services'
project_src
:
'
{{ansible_user_dir}}/nextgen-network/services'
...
...
src/inventory.ts
View file @
b4992960
...
@@ -27,6 +27,18 @@ interface GatewayGroup extends Record<string, any> {
...
@@ -27,6 +27,18 @@ interface GatewayGroup extends Record<string, any> {
destMark
:
number
;
destMark
:
number
;
}
}
interface
GostRoute
{
Retries
?:
string
;
ServeNodes
:
string
[];
ChainNodes
?:
string
[];
Mark
?:
number
}
interface
GostConfig
extends
Partial
<
GostRoute
>
{
Routes
:
GostRoute
[];
Debug
?:
boolean
;
}
type
CommonEntry
=
Record
<
string
,
any
>
;
type
CommonEntry
=
Record
<
string
,
any
>
;
class
InventoryBuilder
{
class
InventoryBuilder
{
...
@@ -47,7 +59,7 @@ class InventoryBuilder {
...
@@ -47,7 +59,7 @@ class InventoryBuilder {
this
.
resolver
.
setServers
(
process
.
env
.
DNS
?
[
process
.
env
.
DNS
]
:
[
'
114.114.114.114
'
,
'
223.5.5.5
'
]);
this
.
resolver
.
setServers
(
process
.
env
.
DNS
?
[
process
.
env
.
DNS
]
:
[
'
114.114.114.114
'
,
'
223.5.5.5
'
]);
}
}
getDockerImageTag
(
host
:
an
y
)
{
getDockerImageTag
(
host
:
CommonEntr
y
)
{
if
(
host
.
arch
&&
host
.
arch
.
length
)
{
if
(
host
.
arch
&&
host
.
arch
.
length
)
{
return
`:master-
${
host
.
arch
}
`
;
return
`:master-
${
host
.
arch
}
`
;
}
else
{
}
else
{
...
@@ -174,7 +186,7 @@ class InventoryBuilder {
...
@@ -174,7 +186,7 @@ class InventoryBuilder {
}
}
return
addresses
.
join
(
"
"
);
return
addresses
.
join
(
"
"
);
}
}
isGatewayGroupContains
(
gatewayGroup
:
GatewayGroup
,
host
:
an
y
)
{
isGatewayGroupContains
(
gatewayGroup
:
GatewayGroup
,
host
:
CommonEntr
y
)
{
const
locationPrefixes
=
gatewayGroup
.
locationPrefix
.
split
(
"
,
"
);
const
locationPrefixes
=
gatewayGroup
.
locationPrefix
.
split
(
"
,
"
);
const
excludeRouters
=
gatewayGroup
.
excludeRouters
.
split
(
"
,
"
);
const
excludeRouters
=
gatewayGroup
.
excludeRouters
.
split
(
"
,
"
);
const
includeRouters
=
gatewayGroup
.
includeRouters
.
split
(
"
,
"
);
const
includeRouters
=
gatewayGroup
.
includeRouters
.
split
(
"
,
"
);
...
@@ -196,11 +208,11 @@ class InventoryBuilder {
...
@@ -196,11 +208,11 @@ class InventoryBuilder {
}
}
return
false
;
return
false
;
}
}
getAddressesFromGatewayGroup
(
gatewayGroup
:
GatewayGroup
,
hosts
:
an
y
[])
{
getAddressesFromGatewayGroup
(
gatewayGroup
:
GatewayGroup
,
hosts
:
CommonEntr
y
[])
{
const
suitableHosts
=
hosts
.
filter
(
host
=>
this
.
isGatewayGroupContains
(
gatewayGroup
,
host
));
const
suitableHosts
=
hosts
.
filter
(
host
=>
this
.
isGatewayGroupContains
(
gatewayGroup
,
host
));
return
suitableHosts
.
map
(
host
=>
host
.
address
);
return
suitableHosts
.
map
(
host
=>
host
.
address
);
}
}
getRoutePlansFromGatewayGroups
(
host
:
an
y
)
{
getRoutePlansFromGatewayGroups
(
host
:
CommonEntr
y
)
{
const
allOtherHosts
=
Object
.
values
(
this
.
hosts
).
filter
(
h
=>
h
!==
host
.
name
)
const
allOtherHosts
=
Object
.
values
(
this
.
hosts
).
filter
(
h
=>
h
!==
host
.
name
)
const
routePlans
=
this
.
gatewayGroups
.
filter
(
group
=>
!
this
.
isGatewayGroupContains
(
group
,
host
)).
map
(
group
=>
{
const
routePlans
=
this
.
gatewayGroups
.
filter
(
group
=>
!
this
.
isGatewayGroupContains
(
group
,
host
)).
map
(
group
=>
{
const
addresses
=
this
.
getAddressesFromGatewayGroup
(
group
,
allOtherHosts
);
const
addresses
=
this
.
getAddressesFromGatewayGroup
(
group
,
allOtherHosts
);
...
@@ -214,7 +226,7 @@ class InventoryBuilder {
...
@@ -214,7 +226,7 @@ class InventoryBuilder {
return
routePlans
;
return
routePlans
;
}
}
getHostConnectionInfo
(
host
)
{
getHostConnectionInfo
(
host
:
CommonEntry
)
{
return
{
return
{
ansible_ssh_host
:
host
.
host
,
ansible_ssh_host
:
host
.
host
,
ansible_ssh_user
:
host
.
user
,
ansible_ssh_user
:
host
.
user
,
...
@@ -225,7 +237,7 @@ class InventoryBuilder {
...
@@ -225,7 +237,7 @@ class InventoryBuilder {
}
}
}
}
async
host_vars
(
host
)
{
async
host_vars
(
host
:
CommonEntry
)
{
const
connections
=
[];
const
connections
=
[];
host
.
dockerServices
=
{
host
.
dockerServices
=
{
version
:
'
2.4
'
,
version
:
'
2.4
'
,
...
@@ -250,6 +262,26 @@ class InventoryBuilder {
...
@@ -250,6 +262,26 @@ class InventoryBuilder {
volumes
:
[
'
./babeld.conf:/etc/babeld.conf:ro
'
]
volumes
:
[
'
./babeld.conf:/etc/babeld.conf:ro
'
]
};
};
}
}
const
gostConfig
:
GostConfig
=
{
Routes
:
Object
.
values
(
this
.
gateways
[
host
.
name
]).
filter
(
gateway
=>
!
gateway
.
hidden
).
map
(
gateway
=>
({
ServeNodes
:
[
`red://
${
host
.
address
}
:
${
gateway
.
redirectPort
}
`
],
Mark
:
gateway
.
selectionMark
as
number
,
}))
};
if
(
gostConfig
.
Routes
.
length
)
{
host
.
gostConfig
=
gostConfig
;
host
.
dockerServices
.
services
.
gost
=
{
restart
:
'
always
'
,
image
:
`git-registry.mycard.moe/nanahira/gost
${
this
.
getDockerImageTag
(
host
)}
`
,
network_mode
:
'
host
'
,
privileged
:
true
,
volumes
:
[
'
./gost.json:/etc/gost/gost.json:ro
'
],
command
:
'
-C /etc/gost/gost.json
'
};
}
host
.
frpcRestarts
=
[];
host
.
frpcRestarts
=
[];
host
.
ocRestarts
=
[];
host
.
ocRestarts
=
[];
host
.
frpsNeeded
=
false
;
host
.
frpsNeeded
=
false
;
...
@@ -321,6 +353,8 @@ class InventoryBuilder {
...
@@ -321,6 +353,8 @@ class InventoryBuilder {
dockerServices
:
host
.
dockerServices
,
dockerServices
:
host
.
dockerServices
,
routePlans
,
routePlans
,
iptables_type
:
host
.
iptables
||
'
auto
'
,
iptables_type
:
host
.
iptables
||
'
auto
'
,
gostConfig
,
installGost
:
!!
gostConfig
,
};
};
}
}
...
...
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