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
09ed5cac
Commit
09ed5cac
authored
May 05, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
haproxy rules
parent
dc1f12e9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
6 deletions
+15
-6
ansible/scripts/switch-rules-up.sh.j2
ansible/scripts/switch-rules-up.sh.j2
+3
-1
ansible/scripts/utility.sh.j2
ansible/scripts/utility.sh.j2
+5
-0
config.sh
config.sh
+1
-1
src/inventory.ts
src/inventory.ts
+6
-4
No files found.
ansible/scripts/switch-rules-up.sh.j2
View file @
09ed5cac
...
@@ -14,12 +14,14 @@ restore_mark_switch -A {{plan.destMark}}
...
@@ -14,12 +14,14 @@ restore_mark_switch -A {{plan.destMark}}
## local gateways
## local gateways
{
%
for
gw
in
gateways %
}
{
%
for
gw
in
gateways %
}
{
%
if
not gw.hidden %
}
{
%
if
gw.selectionMark
>
0 %
}
{
%
if
gw.selectionMark
>
0 %
}
interface_switch_china
-A
u_
{{
gw.isp
}}
_china
{{
gw.selectionMark
}}
interface_switch_china
-A
u_
{{
gw.isp
}}
_china
{{
gw.selectionMark
}}
interface_switch_oversea
-A
u_
{{
gw.isp
}}
_oversea
{{
gw.selectionMark
}}
interface_switch_oversea
-A
u_
{{
gw.isp
}}
_oversea
{{
gw.selectionMark
}}
restore_mark_switch
-A
{{
gw.selectionMark
}}
restore_mark_switch
-A
{{
gw.selectionMark
}}
{
%
if
not gw.hidden %
}
interface_switch_tproxy
-A
{{
gw.selectionMark
}}
{{
gw.haproxyPort
}}
interface_switch_tproxy
-A
{{
gw.selectionMark
}}
{{
gw.haproxyPort
}}
{
%
else
%
}
interface_switch_tproxy_default
-A
{{
gw.haproxyPort
}}
{
% endif %
}
{
% endif %
}
{
% endif %
}
{
% endif %
}
{
% endfor %
}
{
% endfor %
}
...
...
ansible/scripts/utility.sh.j2
View file @
09ed5cac
...
@@ -74,3 +74,8 @@ interface_switch_tproxy() {
...
@@ -74,3 +74,8 @@ interface_switch_tproxy() {
HAPROXY_PORT=$3
HAPROXY_PORT=$3
$IPTABLES_EXEC -t mangle "$OPTION" NEXTGEN_SWITCH -m mark --mark "$MARK" -m set ! --match-set mycard dst -p tcp -m multiport --dports 80,443 -j TPROXY --on-port "$HAPROXY_PORT" --tproxy-mark 999
$IPTABLES_EXEC -t mangle "$OPTION" NEXTGEN_SWITCH -m mark --mark "$MARK" -m set ! --match-set mycard dst -p tcp -m multiport --dports 80,443 -j TPROXY --on-port "$HAPROXY_PORT" --tproxy-mark 999
}
}
interface_switch_tproxy_default() {
OPTION=$1
HAPROXY_PORT=$2
$IPTABLES_EXEC -t mangle "$OPTION" NEXTGEN_SWITCH -m mark --mark 0 -m set --match-set mycard src -m set ! --match-set mycard dst -p tcp -m multiport --dports 80,443 -j TPROXY --on-port "$HAPROXY_PORT" --tproxy-mark 999
}
config.sh
View file @
09ed5cac
...
@@ -7,5 +7,5 @@ cd data
...
@@ -7,5 +7,5 @@ cd data
(
for
sheet
in
$sheets
(
for
sheet
in
$sheets
do
do
echo
"https://docs.google.com/spreadsheets/d/
${
doc
}
/export?exportFormat=csv&gid=
${
sheet
}
"
echo
"https://docs.google.com/spreadsheets/d/
${
doc
}
/export?exportFormat=csv&gid=
${
sheet
}
"
done
)
| wget
--content-disposition
-i
-
done
)
| wget
-
4
-
-content-disposition
-i
-
cd
..
cd
..
src/inventory.ts
View file @
09ed5cac
...
@@ -80,11 +80,13 @@ class InventoryBuilder {
...
@@ -80,11 +80,13 @@ class InventoryBuilder {
const
gateways
=
await
this
.
load
(
'
gateways2
'
);
const
gateways
=
await
this
.
load
(
'
gateways2
'
);
for
(
let
gateway
of
gateways
)
{
for
(
let
gateway
of
gateways
)
{
gateway
.
isCN
=
this
.
hosts
[
gateway
.
router
]
&&
this
.
hosts
[
gateway
.
router
].
location
.
startsWith
(
'
CN
'
);
gateway
.
isCN
=
this
.
hosts
[
gateway
.
router
]
&&
this
.
hosts
[
gateway
.
router
].
location
.
startsWith
(
'
CN
'
);
gateway
.
hidden
=
!!
gateway
.
hidden
;
if
(
gateway
.
mark
)
{
if
(
gateway
.
mark
)
{
gateway
.
selectionMark
=
gateway
.
mark
+
50
;
gateway
.
selectionMark
=
gateway
.
mark
+
50
;
gateway
.
haproxyPort
=
gateway
.
mark
+
60000
;
}
else
{
}
else
{
gateway
.
mark
=
0
;
gateway
.
selectionMark
=
0
;
gateway
.
selectionMark
=
0
;
gateway
.
haproxyPort
=
60100
;
}
}
}
}
return
gateways
;
return
gateways
;
...
@@ -116,7 +118,7 @@ class InventoryBuilder {
...
@@ -116,7 +118,7 @@ class InventoryBuilder {
this
.
linksLimit
=
process
.
env
.
LIMIT_LINKS
.
split
(
"
,
"
);
this
.
linksLimit
=
process
.
env
.
LIMIT_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
));
// console.log(Object.values(this.hosts));
// console.log(Object.values(this.hosts));
const
hosts
=
await
Promise
.
all
(
Object
.
values
(
this
.
hosts
).
map
(
async
(
h
)
=>
({
const
hosts
=
await
Promise
.
all
(
Object
.
values
(
this
.
hosts
).
map
(
async
(
h
)
=>
({
...
...
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