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
f50f981d
Commit
f50f981d
authored
Dec 23, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'babeld'
parents
e60b51e4
17665be2
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
95 additions
and
40 deletions
+95
-40
ansible/configure.yaml
ansible/configure.yaml
+23
-22
ansible/install.yaml
ansible/install.yaml
+5
-1
ansible/protocols/oc/ocserv-user-env.j2
ansible/protocols/oc/ocserv-user-env.j2
+2
-1
ansible/protocols/oc/openconnect-post-scripts/disconnect.sh.j2
...le/protocols/oc/openconnect-post-scripts/disconnect.sh.j2
+1
-1
ansible/protocols/oc/openconnect-post-scripts/post-connect.sh.j2
.../protocols/oc/openconnect-post-scripts/post-connect.sh.j2
+4
-2
ansible/protocols/wg/wg.conf.j2
ansible/protocols/wg/wg.conf.j2
+3
-3
ansible/protocols/wgfrp/wgfrp.conf.j2
ansible/protocols/wgfrp/wgfrp.conf.j2
+2
-2
ansible/restart-babeld.yaml
ansible/restart-babeld.yaml
+29
-0
ansible/scripts/global-postup.sh.j2
ansible/scripts/global-postup.sh.j2
+1
-1
ansible/scripts/postup.sh.j2
ansible/scripts/postup.sh.j2
+1
-1
src/inventory.ts
src/inventory.ts
+16
-5
update-all.sh
update-all.sh
+7
-0
update.sh
update.sh
+1
-1
No files found.
ansible/configure.yaml
View file @
f50f981d
...
@@ -83,31 +83,31 @@
...
@@ -83,31 +83,31 @@
-
name
:
ocserv pre-configure
-
name
:
ocserv pre-configure
include_tasks
:
'
protocols/oc/ocserv-pre.yaml'
include_tasks
:
'
protocols/oc/ocserv-pre.yaml'
when
:
ocservNeeded and not noBird
when
:
ocservNeeded and not noBird
-
name
:
disable bug self-link
become
:
true
ignore_errors
:
true
systemd
:
name
:
'
wg-quick@{{item}}'
state
:
stopped
enabled
:
false
masked
:
true
with_items
:
-
mc-{{inventory_hostname_short}}
-
mci{{inventory_hostname_short}}
# 为了提高测试时候的性能,不改动wg的时候注释掉这段
# 为了提高测试时候的性能,不改动wg的时候注释掉这段
-
name
:
'
clean
up
null
connections
first'
-
name
:
'
clean
up
null
connections
first'
include_tasks
:
'
protocols/{{item.protocol}}/configure.yaml'
include_tasks
:
'
protocols/{{item.protocol}}/configure.yaml'
vars
:
vars
:
conn
:
'
{{item}}'
conn
:
'
{{item}}'
with_items
:
'
{{
connections
}}'
with_items
:
'
{{
connections
}}'
when
:
"
not
noUpdateLinks
and
(not
onlyUpdateLink
or
item.name
==
onlyUpdateLink)
and
item.protocol
==
'null'
"
when
:
"
not
noUpdateLinks
and
item.protocol
==
'null'
and
not
item.noUpdate
"
-
name
:
'
loop
through
list
from
a
variable'
-
name
:
'
loop
through
list
from
a
variable'
include_tasks
:
'
protocols/{{item.protocol}}/configure.yaml'
include_tasks
:
'
protocols/{{item.protocol}}/configure.yaml'
vars
:
vars
:
conn
:
'
{{item}}'
conn
:
'
{{item}}'
with_items
:
'
{{
connections
}}'
with_items
:
'
{{
connections
}}'
when
:
"
not
noUpdateLinks
and
(not
onlyUpdateLink
or
item.name
==
onlyUpdateLink)
and
item.protocol
!=
'null'
"
when
:
"
not
noUpdateLinks
and
item.protocol
!=
'null'
and
not
item.noUpdate
"
# end
# end
-
name
:
disable bug self-link
become
:
true
ignore_errors
:
true
systemd
:
name
:
'
wg-quick@{{item}}'
state
:
stopped
enabled
:
false
masked
:
true
with_items
:
-
mc-{{inventory_hostname_short}}
-
mci{{inventory_hostname_short}}
-
name
:
services conf
-
name
:
services conf
copy
:
copy
:
content
:
'
{{dockerServices
|
to_yaml}}'
content
:
'
{{dockerServices
|
to_yaml}}'
...
@@ -123,13 +123,13 @@
...
@@ -123,13 +123,13 @@
template
:
template
:
src
:
babeld.conf.j2
src
:
babeld.conf.j2
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
when
:
not noBird
#
- name: babeld reload conf
-
name
:
babeld reload conf
#
template:
template
:
#
src: babeld-reload.conf.j2
src
:
babeld-reload.conf.j2
#
dest: /tmp/babeld-reload.conf
dest
:
/tmp/babeld-reload.conf
#
notify: reload_babeld
notify
:
reload_babeld
-
name
:
frps conf
-
name
:
frps conf
template
:
template
:
src
:
protocols/wgfrp/frps.ini.j2
src
:
protocols/wgfrp/frps.ini.j2
...
@@ -162,7 +162,7 @@
...
@@ -162,7 +162,7 @@
template
:
template
:
src
:
babeld.conf.j2
src
:
babeld.conf.j2
dest
:
'
/etc/babeld.conf'
dest
:
'
/etc/babeld.conf'
notify
:
restart_babeld_systemd
#
notify: restart_babeld_systemd
when
:
systemBird
when
:
systemBird
-
name
:
enable systemd babeld
-
name
:
enable systemd babeld
become
:
true
become
:
true
...
@@ -206,7 +206,7 @@
...
@@ -206,7 +206,7 @@
services
:
services
:
-
frpc-{{item.name}}
-
frpc-{{item.name}}
with_items
:
'
{{connections}}'
with_items
:
'
{{connections}}'
when
:
'
item.protocol
==
"wgfrp"
and
item.frpType
==
"frpc"
and
not
noBird'
when
:
'
item.protocol
==
"wgfrp"
and
item.frpType
==
"frpc"
and
not
noBird
and
not
item.noUpdate
'
-
name
:
restart_ocserv
-
name
:
restart_ocserv
docker_compose
:
docker_compose
:
project_src
:
'
{{ansible_user_dir}}/nextgen-network/services'
project_src
:
'
{{ansible_user_dir}}/nextgen-network/services'
...
@@ -221,7 +221,7 @@
...
@@ -221,7 +221,7 @@
services
:
services
:
-
openconnect-{{item.name}}
-
openconnect-{{item.name}}
with_items
:
'
{{connections}}'
with_items
:
'
{{connections}}'
when
:
'
item.protocol
==
"oc"
and
item.ocType
==
"client"
and
not
noBird'
when
:
'
item.protocol
==
"oc"
and
item.ocType
==
"client"
and
not
noBird
and
not
item.noUpdate
'
-
name
:
restart_bird_systemd
-
name
:
restart_bird_systemd
become
:
true
become
:
true
systemd
:
systemd
:
...
@@ -232,6 +232,7 @@
...
@@ -232,6 +232,7 @@
systemd
:
systemd
:
name
:
babeld
name
:
babeld
state
:
restarted
state
:
restarted
when
:
systemBird
-
name
:
reload_chnroute
-
name
:
reload_chnroute
become
:
true
become
:
true
shell
:
|
shell
:
|
...
...
ansible/install.yaml
View file @
f50f981d
...
@@ -31,9 +31,13 @@
...
@@ -31,9 +31,13 @@
Pin-Priority: 90
Pin-Priority: 90
dest
:
/etc/apt/preferences.d/limit-unstable
dest
:
/etc/apt/preferences.d/limit-unstable
when
:
systemBird and ansible_distribution == 'Debian' and ansible_distribution_release != 'sid'
when
:
systemBird and ansible_distribution == 'Debian' and ansible_distribution_release != 'sid'
-
name
:
install packages for systemd things
-
name
:
netcat-openbsd
become
:
true
become
:
true
apt
:
apt
:
update_cache
:
true
update_cache
:
true
name
:
netcat-openbsd
-
name
:
install packages for systemd things
become
:
true
apt
:
name
:
babeld,bird2
name
:
babeld,bird2
when
:
systemBird
when
:
systemBird
ansible/protocols/oc/ocserv-user-env.j2
View file @
f50f981d
...
@@ -3,7 +3,8 @@ export localAddress={{address}}
...
@@ -3,7 +3,8 @@ export localAddress={{address}}
export remoteLocalAddress={{conn.remoteLocalAddress}}
export remoteLocalAddress={{conn.remoteLocalAddress}}
export localPeerAddress={{conn.localPeerAddress}}
export localPeerAddress={{conn.localPeerAddress}}
export remotePeerAddress={{conn.remotePeerAddress}}
export remotePeerAddress={{conn.remotePeerAddress}}
export link6Address={{conn.link6Address}}
export localPeerAddress6={{conn.localPeerAddress6}}
export remotePeerAddress6={{conn.remotePeerAddress6}}
export localRubbishAddress=10.199.{{id}}.1
export localRubbishAddress=10.199.{{id}}.1
export remoteNextMark={{conn.remoteNextMark}}
export remoteNextMark={{conn.remoteNextMark}}
export inbound={{conn.inbound}}
export inbound={{conn.inbound}}
...
...
ansible/protocols/oc/openconnect-post-scripts/disconnect.sh.j2
View file @
f50f981d
#!/bin/bash
#!/bin/bash
dev
=
"
$TUNDEV
"
localPeerAddress
={{
conn.localPeerAddress
}}
remotePeerAddress
={{
conn.remotePeerAddress
}}
l
ink6Address
={{
conn.link6Address
}}
remoteNextMark
={{
conn.remoteNextMark
}}
inbound
={{
conn.inbound
}}
outbound
={{
conn.outbound
}}
mtu
={{
conn.mtu|int - 58
}}
{{
ansible_user_dir
}}
/nextgen-network/scripts/predown.sh
dev
=
"
$TUNDEV
"
localPeerAddress
={{
conn.localPeerAddress
}}
remotePeerAddress
={{
conn.remotePeerAddress
}}
l
ocalPeerAddress6
={{
conn.localPeerAddress6
}}
remotePeerAddress6
={{
conn.remotePeerAddress6
}}
remoteNextMark
={{
conn.remoteNextMark
}}
inbound
={{
conn.inbound
}}
outbound
={{
conn.outbound
}}
mtu
={{
conn.mtu|int - 58
}}
{{
ansible_user_dir
}}
/nextgen-network/scripts/predown.sh
true
true
ansible/protocols/oc/openconnect-post-scripts/post-connect.sh.j2
View file @
f50f981d
#!/bin/bash
#!/bin/bash
dev
=
"
$TUNDEV
"
localPeerAddress
={{
conn.localPeerAddress
}}
remotePeerAddress
={{
conn.remotePeerAddress
}}
link6Address
={{
conn.link6Address
}}
remoteNextMark
={{
conn.remoteNextMark
}}
inbound
={{
conn.inbound
}}
outbound
={{
conn.outbound
}}
mtu
={{
conn.mtu|int - 58
}}
{{
ansible_user_dir
}}
/nextgen-network/scripts/predown.sh
# Force reload at 12.23
dev
=
"
$TUNDEV
"
localPeerAddress
={{
conn.localPeerAddress
}}
remotePeerAddress
={{
conn.remotePeerAddress
}}
link6Address
={{
conn.link6Address
}}
remoteNextMark
={{
conn.remoteNextMark
}}
inbound
={{
conn.inbound
}}
outbound
={{
conn.outbound
}}
mtu
={{
conn.mtu|int - 58
}}
{{
ansible_user_dir
}}
/nextgen-network/scripts/postup.sh
dev
=
"
$TUNDEV
"
localPeerAddress
={{
conn.localPeerAddress
}}
remotePeerAddress
={{
conn.remotePeerAddress
}}
localPeerAddress6
={{
conn.localPeerAddress6
}}
remotePeerAddress6
={{
conn.remotePeerAddress6
}}
remoteNextMark
={{
conn.remoteNextMark
}}
inbound
={{
conn.inbound
}}
outbound
={{
conn.outbound
}}
mtu
={{
conn.mtu|int - 58
}}
{{
ansible_user_dir
}}
/nextgen-network/scripts/predown.sh
dev
=
"
$TUNDEV
"
localPeerAddress
={{
conn.localPeerAddress
}}
remotePeerAddress
={{
conn.remotePeerAddress
}}
localPeerAddress6
={{
conn.localPeerAddress6
}}
remotePeerAddress6
={{
conn.remotePeerAddress6
}}
remoteNextMark
={{
conn.remoteNextMark
}}
inbound
={{
conn.inbound
}}
outbound
={{
conn.outbound
}}
mtu
={{
conn.mtu|int - 58
}}
{{
ansible_user_dir
}}
/nextgen-network/scripts/postup.sh
true
true
ansible/protocols/wg/wg.conf.j2
View file @
f50f981d
...
@@ -8,8 +8,8 @@ FwMark = {{conn.localGatewayMark}}
...
@@ -8,8 +8,8 @@ FwMark = {{conn.localGatewayMark}}
MTU = {{conn.mtu|int - 80}}
MTU = {{conn.mtu|int - 80}}
Table = off
Table = off
PostUp = dev=%i localPeerAddress={{conn.localPeerAddress}} remotePeerAddress={{conn.remotePeerAddress}} l
ink6Address={{conn.link6Address
}} remoteNextMark={{conn.remoteNextMark}} inbound={{conn.inbound}} outbound={{conn.outbound}} mtu={{conn.mtu|int - 80}} {{ansible_user_dir}}/nextgen-network/scripts/postup.sh
PostUp = dev=%i localPeerAddress={{conn.localPeerAddress}} remotePeerAddress={{conn.remotePeerAddress}} l
ocalPeerAddress6={{conn.localPeerAddress6}} remotePeerAddress6={{conn.remotePeerAddress6
}} remoteNextMark={{conn.remoteNextMark}} inbound={{conn.inbound}} outbound={{conn.outbound}} mtu={{conn.mtu|int - 80}} {{ansible_user_dir}}/nextgen-network/scripts/postup.sh
PreDown = dev=%i localPeerAddress={{conn.localPeerAddress}} remotePeerAddress={{conn.remotePeerAddress}} l
ink6Address={{conn.link6Address
}} remoteNextMark={{conn.remoteNextMark}} inbound={{conn.inbound}} outbound={{conn.outbound}} mtu={{conn.mtu|int - 80}} {{ansible_user_dir}}/nextgen-network/scripts/predown.sh
PreDown = dev=%i localPeerAddress={{conn.localPeerAddress}} remotePeerAddress={{conn.remotePeerAddress}} l
ocalPeerAddress6={{conn.localPeerAddress6}} remotePeerAddress6={{conn.remotePeerAddress6
}} remoteNextMark={{conn.remoteNextMark}} inbound={{conn.inbound}} outbound={{conn.outbound}} mtu={{conn.mtu|int - 80}} {{ansible_user_dir}}/nextgen-network/scripts/predown.sh
[Peer]
[Peer]
PublicKey = {{conn.wgPublicKey}}
PublicKey = {{conn.wgPublicKey}}
...
@@ -19,4 +19,4 @@ Endpoint = {{conn.remoteAddress}}:{{conn.remotePort}}
...
@@ -19,4 +19,4 @@ Endpoint = {{conn.remoteAddress}}:{{conn.remotePort}}
PersistentKeepalive = 1
PersistentKeepalive = 1
{% endif %}
{% endif %}
# forced change 12.
12
# forced change 12.
23
ansible/protocols/wgfrp/wgfrp.conf.j2
View file @
f50f981d
...
@@ -6,8 +6,8 @@ ListenPort = {{conn.localPort}}
...
@@ -6,8 +6,8 @@ ListenPort = {{conn.localPort}}
{% endif %}
{% endif %}
MTU = {{conn.mtu|int - 80}}
MTU = {{conn.mtu|int - 80}}
Table = off
Table = off
PostUp = dev=%i localPeerAddress={{conn.localPeerAddress}}
remotePeerAddress={{conn.remotePeerAddress}} link6Address={{conn.link6Address
}} remoteNextMark={{conn.remoteNextMark}} inbound={{conn.inbound}} outbound={{conn.outbound}} mtu={{conn.mtu|int - 80}} {{ansible_user_dir}}/nextgen-network/scripts/postup.sh
PostUp = dev=%i localPeerAddress={{conn.localPeerAddress}}
localPeerAddress6={{conn.localPeerAddress6}} remotePeerAddress6={{conn.remotePeerAddress6
}} remoteNextMark={{conn.remoteNextMark}} inbound={{conn.inbound}} outbound={{conn.outbound}} mtu={{conn.mtu|int - 80}} {{ansible_user_dir}}/nextgen-network/scripts/postup.sh
PreDown = dev=%i localPeerAddress={{conn.localPeerAddress}}
remotePeerAddress={{conn.remotePeerAddress}} link6Address={{conn.link6Address
}} remoteNextMark={{conn.remoteNextMark}} inbound={{conn.inbound}} outbound={{conn.outbound}} mtu={{conn.mtu|int - 80}} {{ansible_user_dir}}/nextgen-network/scripts/predown.sh
PreDown = dev=%i localPeerAddress={{conn.localPeerAddress}}
localPeerAddress6={{conn.localPeerAddress6}} remotePeerAddress6={{conn.remotePeerAddress6
}} remoteNextMark={{conn.remoteNextMark}} inbound={{conn.inbound}} outbound={{conn.outbound}} mtu={{conn.mtu|int - 80}} {{ansible_user_dir}}/nextgen-network/scripts/predown.sh
[Peer]
[Peer]
PublicKey = {{conn.wgPublicKey}}
PublicKey = {{conn.wgPublicKey}}
AllowedIPs = 0.0.0.0/0, ::/0
AllowedIPs = 0.0.0.0/0, ::/0
...
...
ansible/restart-babeld.yaml
0 → 100644
View file @
f50f981d
---
-
hosts
:
wg
tasks
:
-
name
:
load vars
include_vars
:
file
:
'
../result/{{item}}.yaml'
with_items
:
# - global-vars
-
vars-{{inventory_hostname_short}}
-
name
:
restart_babeld_systemd
become
:
true
systemd
:
name
:
babeld
state
:
restarted
when
:
systemBird
-
name
:
restart_babeld
# ocserv would be always restarted whenever key changes..
docker_compose
:
project_src
:
'
{{ansible_user_dir}}/nextgen-network/services'
restarted
:
true
services
:
-
babeld
when
:
not noBird
-
name
:
restart ocserv
docker_compose
:
project_src
:
'
{{ansible_user_dir}}/nextgen-network/services'
restarted
:
true
services
:
-
ocserv
when
:
ocservNeeded and not noBird
ansible/scripts/global-postup.sh.j2
View file @
f50f981d
#!/usr/bin/env bash
#!/usr/bin/env bash
# Forced update 12.2
2
# Forced update 12.2
3
source
{{
ansible_user_dir
}}
/nextgen-network/scripts/utility.sh
source
{{
ansible_user_dir
}}
/nextgen-network/scripts/utility.sh
echo
"running"
>
/tmp/mycard_global_postup_done
echo
"running"
>
/tmp/mycard_global_postup_done
...
...
ansible/scripts/postup.sh.j2
View file @
f50f981d
...
@@ -4,7 +4,7 @@ source {{ansible_user_dir}}/nextgen-network/scripts/utility.sh
...
@@ -4,7 +4,7 @@ source {{ansible_user_dir}}/nextgen-network/scripts/utility.sh
#set -e
#set -e
ip addr add
"
$localPeerAddress
"
peer
"
$remotePeerAddress
"
dev
"
$dev
"
scope
link
ip addr add
"
$localPeerAddress
"
peer
"
$remotePeerAddress
"
dev
"
$dev
"
scope
link
ip
-6
addr add
"
$link6Address
"
dev
"
$dev
"
scope
link
ip
addr add
"
$localPeerAddress6
"
peer
"
$remotePeerAddress6
"
dev
"
$dev
"
scope
link
if
[
"
$outbound
"
==
True
]
;
then
if
[
"
$outbound
"
==
True
]
;
then
ip route add default dev
"
$dev
"
table
"
$remoteNextMark
"
ip route add default dev
"
$dev
"
table
"
$remoteNextMark
"
...
...
src/inventory.ts
View file @
f50f981d
...
@@ -25,6 +25,7 @@ class InventoryBuilder {
...
@@ -25,6 +25,7 @@ class InventoryBuilder {
resolveCache
:
Map
<
string
,
string
>
;
resolveCache
:
Map
<
string
,
string
>
;
resolver
:
dns
.
Resolver
;
resolver
:
dns
.
Resolver
;
vars
:
any
;
vars
:
any
;
linksOnly
:
string
[];
constructor
()
{
constructor
()
{
this
.
resolveCache
=
new
Map
();
this
.
resolveCache
=
new
Map
();
...
@@ -95,6 +96,9 @@ class InventoryBuilder {
...
@@ -95,6 +96,9 @@ class InventoryBuilder {
for
(
const
host
of
Object
.
values
(
this
.
hosts
))
{
for
(
const
host
of
Object
.
values
(
this
.
hosts
))
{
host
.
wgPublickey
=
await
this
.
wgPublickey
(
host
.
wgPrivateKey
);
host
.
wgPublickey
=
await
this
.
wgPublickey
(
host
.
wgPrivateKey
);
}
}
if
(
process
.
env
.
ONLY_LINKS
)
{
this
.
linksOnly
=
process
.
env
.
ONLY_LINKS
.
split
(
"
,
"
);
}
this
.
vars
=
await
this
.
loadUtilities
();
this
.
vars
=
await
this
.
loadUtilities
();
const
inventoryValue
=
{
wg
:
{
hosts
:
Object
.
fromEntries
(
Object
.
values
(
this
.
hosts
).
map
(
host
=>
[
host
.
name
,
this
.
getHostConnectionInfo
(
host
)]))}
};
const
inventoryValue
=
{
wg
:
{
hosts
:
Object
.
fromEntries
(
Object
.
values
(
this
.
hosts
).
map
(
host
=>
[
host
.
name
,
this
.
getHostConnectionInfo
(
host
)]))}
};
await
fs
.
promises
.
writeFile
(
'
result/inventory.yaml
'
,
YAML
.
stringify
(
inventoryValue
));
await
fs
.
promises
.
writeFile
(
'
result/inventory.yaml
'
,
YAML
.
stringify
(
inventoryValue
));
...
@@ -128,8 +132,7 @@ class InventoryBuilder {
...
@@ -128,8 +132,7 @@ class InventoryBuilder {
const
vars
=
{
const
vars
=
{
routeLists
:
this
.
routeLists
,
routeLists
:
this
.
routeLists
,
routeListNames
:
Object
.
keys
(
this
.
routeLists
),
routeListNames
:
Object
.
keys
(
this
.
routeLists
),
noUpdateLinks
:
!!
process
.
env
.
NO_LINK
,
noUpdateLinks
:
!!
process
.
env
.
NO_LINK
onlyUpdateLink
:
process
.
env
.
ONLY_LINK
||
null
};
};
for
(
let
col
in
raw_utility
)
{
for
(
let
col
in
raw_utility
)
{
vars
[
col
]
=
raw_utility
[
col
].
value
;
vars
[
col
]
=
raw_utility
[
col
].
value
;
...
@@ -267,7 +270,11 @@ class InventoryBuilder {
...
@@ -267,7 +270,11 @@ class InventoryBuilder {
const
wgPublicKey
=
remote
.
wgPublickey
;
const
wgPublicKey
=
remote
.
wgPublickey
;
const
localPeerAddress
=
primary
?
`10.200.
${
local
.
id
}
.
${
remote
.
id
}
`
:
`10.201.
${
local
.
id
}
.
${
remote
.
id
}
`
;
const
localPeerAddress
=
primary
?
`10.200.
${
local
.
id
}
.
${
remote
.
id
}
`
:
`10.201.
${
local
.
id
}
.
${
remote
.
id
}
`
;
const
remotePeerAddress
=
primary
?
`10.200.
${
remote
.
id
}
.
${
local
.
id
}
`
:
`10.201.
${
remote
.
id
}
.
${
local
.
id
}
`
;
const
remotePeerAddress
=
primary
?
`10.200.
${
remote
.
id
}
.
${
local
.
id
}
`
:
`10.201.
${
remote
.
id
}
.
${
local
.
id
}
`
;
const
link6Address
=
`fe80::
${
primary
?
1
:
2
}
:
${
local
.
id
}
:
${
remote
.
id
}
/64`
;
const
localPeerAddress6Block
=
((
local
.
id
<<
8
)
|
remote
.
id
).
toString
(
16
);
const
remotePeerAddress6Block
=
((
remote
.
id
<<
8
)
|
local
.
id
).
toString
(
16
);
const
localPeerAddress6
=
`fe80::
${
primary
?
1
:
2
}
:
${
localPeerAddress6Block
}
`
;
const
remotePeerAddress6
=
`fe80::
${
primary
?
1
:
2
}
:
${
remotePeerAddress6Block
}
`
;
const
frpType
=
protocol
===
'
wgfrp
'
?
(
this
.
gatewayCompare
(
localGateway
,
remoteGateway
)
?
'
frps
'
:
'
frpc
'
)
:
undefined
;
const
frpType
=
protocol
===
'
wgfrp
'
?
(
this
.
gatewayCompare
(
localGateway
,
remoteGateway
)
?
'
frps
'
:
'
frpc
'
)
:
undefined
;
const
ocType
=
protocol
===
'
oc
'
?
(
this
.
gatewayCompareOcserv
(
local
,
remote
,
localGateway
,
remoteGateway
)
?
'
server
'
:
'
client
'
)
:
undefined
;
const
ocType
=
protocol
===
'
oc
'
?
(
this
.
gatewayCompareOcserv
(
local
,
remote
,
localGateway
,
remoteGateway
)
?
'
server
'
:
'
client
'
)
:
undefined
;
...
@@ -342,6 +349,8 @@ class InventoryBuilder {
...
@@ -342,6 +349,8 @@ class InventoryBuilder {
console
.
log
(
`
${
local
.
name
}
GW
${
localGateway
.
isp
}
${
inbound
?
'
<
'
:
'
=
'
}
=
${
frpType
===
'
frps
'
?
'
s
'
:
'
=
'
}
=[
${
protocol
}
]=
${
frpType
===
'
frpc
'
?
'
s
'
:
'
=
'
}
=>
${
remote
.
name
}
GW
${
remoteGateway
.
isp
}
`
);
console
.
log
(
`
${
local
.
name
}
GW
${
localGateway
.
isp
}
${
inbound
?
'
<
'
:
'
=
'
}
=
${
frpType
===
'
frps
'
?
'
s
'
:
'
=
'
}
=[
${
protocol
}
]=
${
frpType
===
'
frpc
'
?
'
s
'
:
'
=
'
}
=>
${
remote
.
name
}
GW
${
remoteGateway
.
isp
}
`
);
}
}
const
noUpdate
=
this
.
linksOnly
&&
!
(
this
.
linksOnly
.
includes
(
remote
.
name
)
||
this
.
linksOnly
.
includes
(
local
.
name
));
return
{
return
{
name
,
name
,
metric
,
metric
,
...
@@ -358,14 +367,16 @@ class InventoryBuilder {
...
@@ -358,14 +367,16 @@ class InventoryBuilder {
wgPublicKey
,
wgPublicKey
,
localPeerAddress
,
localPeerAddress
,
remotePeerAddress
,
remotePeerAddress
,
link6Address
,
localPeerAddress6
,
remotePeerAddress6
,
remoteFrpsPort
,
remoteFrpsPort
,
//remoteOcservPort,
//remoteOcservPort,
frpType
,
frpType
,
ocType
,
ocType
,
inbound
,
inbound
,
outbound
,
outbound
,
mtu
mtu
,
noUpdate
,
};
};
}
}
...
...
update-all.sh
0 → 100755
View file @
f50f981d
#!/bin/bash
./update.sh
"
$@
"
cd
ansible
ansible-playbook
-i
../result/inventory.yaml
"
$@
"
restart-babeld.yaml
cd
..
update.sh
View file @
f50f981d
...
@@ -28,7 +28,7 @@ _strip_wg_conf() {
...
@@ -28,7 +28,7 @@ _strip_wg_conf() {
# _strip_wg_conf ./protocols/wg/wg.conf.j2 ./protocols/wg/wg-setconf.conf.j2
# _strip_wg_conf ./protocols/wg/wg.conf.j2 ./protocols/wg/wg-setconf.conf.j2
_strip_wg_conf ./protocols/wgfrp/wgfrp.conf.j2 ./protocols/wgfrp/wgfrp-setconf.conf.j2
_strip_wg_conf ./protocols/wgfrp/wgfrp.conf.j2 ./protocols/wgfrp/wgfrp-setconf.conf.j2
cat
babeld.conf.j2
>
babeld-reload.conf.j2
sed
-r
'/^(#.*)?$/d;/^reflect-kernel-metric/d;/^local-port-readwrite/d;/^redistribute/d'
babeld.conf.j2
>
babeld-reload.conf.j2
echo
'quit'
>>
babeld-reload.conf.j2
echo
'quit'
>>
babeld-reload.conf.j2
ansible-playbook
-i
../result/inventory.yaml
"
$@
"
configure.yaml
ansible-playbook
-i
../result/inventory.yaml
"
$@
"
configure.yaml
...
...
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