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
dd19d7eb
Commit
dd19d7eb
authored
May 22, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update pcc rule
parent
6754a9e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
11 deletions
+23
-11
ansible/scripts/switch-rules-up.sh.j2
ansible/scripts/switch-rules-up.sh.j2
+17
-1
ansible/scripts/utility.sh.j2
ansible/scripts/utility.sh.j2
+6
-10
No files found.
ansible/scripts/switch-rules-up.sh.j2
View file @
dd19d7eb
...
@@ -10,6 +10,12 @@ interface_switch_oversea -A u_{{plan.name}}_oversea {{plan.destMark}}
...
@@ -10,6 +10,12 @@ interface_switch_oversea -A u_{{plan.name}}_oversea {{plan.destMark}}
restore_mark_switch
-A
{{
plan.destMark
}}
restore_mark_switch
-A
{{
plan.destMark
}}
{
% endfor %
}
{
% endfor %
}
{
%
for
gw
in
gateways %
}
{
%
if
not gw.hidden %
}
ensure_isp_ipset
{{
gw.isp
}}
{
% endif %
}
{
% endfor %
}
## local gateways
## local gateways
{
%
for
gw
in
gateways %
}
{
%
for
gw
in
gateways %
}
{
%
if
not gw.hidden %
}
{
%
if
not gw.hidden %
}
...
@@ -17,7 +23,17 @@ restore_mark_switch -A {{plan.destMark}}
...
@@ -17,7 +23,17 @@ restore_mark_switch -A {{plan.destMark}}
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
}}
{
%
for
rule
in
gw.pccRules %
}
{
%
for
rule
in
gw.pccRules %
}
interface_switch_pcc
-A
{{
gw.isp
}}
{{
gw.selectionMark
}}
{{
rule.src
}}
{{
rule.dst
}}
$IPTABLES_EXEC
-t
mangle
-A
NEXTGEN_SWITCH
\
-m
mark
--mark
0
\
-m
set
--match-set
mycard src
\
{
%
for
tgw
in
gateways %
}
{
%
if
not tgw.hidden %
}
-m
set
!
--match-set
"u_{{tgw.isp}}_oversea"
src
\
-m
set
!
--match-set
"u_{{tgw.isp}}_china"
src
\
{
% endif %
}
{
% endfor %
}
-m
set
!
--match-set
mycard dst
-s
"{{rule.src}}"
-d
"{{rule.dst}}"
\
-j
CONNMARK
--set-xmark
"{{gw.selectionMark}}"
{
% endfor %
}
{
% endfor %
}
restore_mark_switch
-A
{{
gw.selectionMark
}}
restore_mark_switch
-A
{{
gw.selectionMark
}}
{
% endif %
}
{
% endif %
}
...
...
ansible/scripts/utility.sh.j2
View file @
dd19d7eb
...
@@ -10,6 +10,12 @@ wait_lock() {
...
@@ -10,6 +10,12 @@ wait_lock() {
done
done
}
}
ensure_isp_ipset() {
ISP=$1
ipset create "u_${ISP}_china" hash:net maxelem 1000000 || true
ipset create "u_${ISP}_oversea" hash:net maxelem 1000000 || true
}
ensure_ipset_and_chain() {
ensure_ipset_and_chain() {
{% for list in routeListNames %}
{% for list in routeListNames %}
ipset restore -f {{ansible_user_dir}}/nextgen-network/ipsets/{{list}}.ipset || true
ipset restore -f {{ansible_user_dir}}/nextgen-network/ipsets/{{list}}.ipset || true
...
@@ -68,16 +74,6 @@ interface_switch_oversea() {
...
@@ -68,16 +74,6 @@ interface_switch_oversea() {
$IPTABLES_EXEC -t mangle "$OPTION" NEXTGEN_SWITCH -m mark --mark 0 -m set --match-set "$IPSET" src -m set ! --match-set mycard dst -m set --match-set chnrouter dst -j CONNMARK --set-xmark "$MARK"
$IPTABLES_EXEC -t mangle "$OPTION" NEXTGEN_SWITCH -m mark --mark 0 -m set --match-set "$IPSET" src -m set ! --match-set mycard dst -m set --match-set chnrouter dst -j CONNMARK --set-xmark "$MARK"
}
}
interface_switch_pcc() {
OPTION=$1
ISP=$2
MARK=$3
SRC=$4
DST=$5
ipset create "$IPSET" hash:net maxelem 1000000 || true
$IPTABLES_EXEC -t mangle "$OPTION" NEXTGEN_SWITCH -m mark --mark 0 -m set --match-set mycard src -m set ! --match-set "u_${ISP}_oversea" src -m set ! --match-set "u_${ISP}_china" src -m set ! --match-set mycard dst -s "$SRC" -d "$DST" -j CONNMARK --set-xmark "$MARK"
}
interface_switch_redirect() {
interface_switch_redirect() {
OPTION=$1
OPTION=$1
MARK=$2
MARK=$2
...
...
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