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
2e919a0b
Commit
2e919a0b
authored
Mar 24, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implant of ladder
parent
43df9b4e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
71 additions
and
43 deletions
+71
-43
.gitignore
.gitignore
+3
-0
ansible/bird.conf.j2
ansible/bird.conf.j2
+9
-23
lists/patch-gfwiplist.yaml
lists/patch-gfwiplist.yaml
+0
-0
lists/requirements.txt
lists/requirements.txt
+1
-0
lists/reverse.py
lists/reverse.py
+0
-11
lists/route_helper.py
lists/route_helper.py
+36
-0
lists/run.sh
lists/run.sh
+7
-2
src/inventory.ts
src/inventory.ts
+15
-7
No files found.
.gitignore
View file @
2e919a0b
...
@@ -107,6 +107,9 @@ dist
...
@@ -107,6 +107,9 @@ dist
.vscode-test
.vscode-test
/data/
/data/
/result/
/result/
/lists/chnroutes*
/lists/gfwiplist*
/lists/result.yaml
*.retry
*.retry
*-setconf.conf.j2
*-setconf.conf.j2
...
...
ansible/bird.conf.j2
View file @
2e919a0b
...
@@ -46,40 +46,26 @@ protocol kernel {
...
@@ -46,40 +46,26 @@ protocol kernel {
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
ipv4 table gfwiplist;
ipv4 table chnroute_reverse;
{% for plan in route_tables %}
{% for net in gfwiplist %}
ipv4 table {{plan.name}};
protocol static {
{% for net in plan.list %}
ipv4 {
table gfwiplist;
};
igp table master4;
route {{net}} recursive 10.199.0.12;
}
{% endfor %}
{% for net in chnroute_reverse %}
protocol static {
protocol static {
ipv4 {
ipv4 {
table
chnroute_reverse
;
table
{{plan.name}}
;
};
};
igp table master4;
igp table master4;
route {{net}} recursive
10.199.0.12
;
route {{net}} recursive
{{plan.gatewayAddress}}
;
}
}
{% endfor %}
{% endfor %}
protocol kernel {
protocol kernel {
ipv4 {
ipv4 {
table
gfwiplist
;
table
{{plan.name}}
;
export all;
export all;
};
};
kernel table 401;
kernel table {{plan.table}};
}
protocol kernel {
ipv4 {
table chnroute_reverse;
export all;
};
kernel table 402;
}
}
{% endfor %}
protocol ospf v2 {
protocol ospf v2 {
ipv4 {
ipv4 {
...
...
lists/
gfwiplist-patch
.yaml
→
lists/
patch-gfwiplist
.yaml
View file @
2e919a0b
File moved
lists/requirements.txt
View file @
2e919a0b
netaddr==0.7.19
netaddr==0.7.19
pyyaml
lists/reverse.py
deleted
100644 → 0
View file @
43df9b4e
#!/usr/bin/env python3
from
netaddr
import
*
universe
=
IPSet
([
'0.0.0.0/0'
])
special
=
IPSet
([
line
.
strip
()
for
line
in
open
(
'special.txt'
)])
chnroutes
=
IPSet
([
line
.
strip
()
for
line
in
open
(
'chnroutes.txt'
)
if
not
line
.
startswith
(
'#'
)])
result
=
universe
-
special
-
chnroutes
for
network
in
result
.
iter_cidrs
():
print
(
network
)
lists/route_helper.py
0 → 100644
View file @
2e919a0b
#!/usr/bin/env python3
from
netaddr
import
*
import
yaml
def
read_yaml_file
(
name
):
file
=
open
(
name
,
'r'
,
encoding
=
"utf-8"
)
data
=
yaml
.
load
(
file
,
Loader
=
yaml
.
SafeLoader
)
file
.
close
()
return
data
def
write_yaml_file
(
name
,
data
):
file
=
open
(
name
,
'w'
,
encoding
=
"utf-8"
)
yaml
.
dump
(
data
,
file
)
file
.
close
()
universe
=
IPSet
([
'0.0.0.0/0'
])
special
=
IPSet
([
line
.
strip
()
for
line
in
open
(
'special.txt'
)])
chnroutes
=
IPSet
([
line
.
strip
()
for
line
in
open
(
'chnroutes.txt'
)
if
not
line
.
startswith
(
'#'
)])
gfwiplist
=
IPSet
([
line
.
strip
()
for
line
in
open
(
'gfwiplist.txt'
)
if
not
line
.
startswith
(
'#'
)])
result
=
{
'chnroute_reverse'
:
[],
'gfwiplist'
:
[]}
chnroute_reverse
=
universe
-
special
-
chnroutes
for
route
in
chnroute_reverse
.
iter_cidrs
():
result
[
'chnroute_reverse'
]
.
append
(
str
(
route
))
gfwiplist_patches
=
read_yaml_file
(
'patch-gfwiplist.yaml'
)
gfwiplist_add
=
IPSet
(
gfwiplist_patches
[
'add'
])
gfwiplist_remove
=
IPSet
(
gfwiplist_patches
[
'remove'
])
gfwiplist_patched
=
(
gfwiplist
|
gfwiplist_add
)
-
gfwiplist_remove
-
special
for
route
in
gfwiplist_patched
.
iter_cidrs
():
result
[
'gfwiplist'
]
.
append
(
str
(
route
))
write_yaml_file
(
"result.yaml"
,
result
)
lists/
chnroutes
.sh
→
lists/
run
.sh
100644 → 100755
View file @
2e919a0b
...
@@ -5,7 +5,12 @@ if [ -d "chnroutes2" ]; then
...
@@ -5,7 +5,12 @@ if [ -d "chnroutes2" ]; then
else
else
git clone https://github.com/misakaio/chnroutes2.git
git clone https://github.com/misakaio/chnroutes2.git
fi
fi
ln
-sf
chnroutes2/chnroutes.txt chnroutes.txt
ln
-sf
chnroutes2/chnroutes.txt chnroutes.txt
if
[
-d
"gfwiplist"
]
;
then
(
cd
gfwiplist
&&
git pull
)
else
git clone https://github.com/SteamedFish/gfwiplist.git
fi
ln
-sf
gfwiplist/gfwiplist.txt gfwiplist.txt
#pip3 install -r requirements.txt
#pip3 install -r requirements.txt
python3 r
everse
.py
python3 r
oute_helper
.py
src/inventory.ts
View file @
2e919a0b
...
@@ -40,18 +40,26 @@ class InventoryBuilder {
...
@@ -40,18 +40,26 @@ 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
vars
=
await
this
.
loadUtilities
();
const
vars
=
await
this
.
loadUtilities
(
hosts
);
const
result
=
YAML
.
stringify
({
wg
:
{
hosts
,
vars
}
});
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
()
{
async
loadUtilities
(
hosts
)
{
const
raw_data
=
_
.
keyBy
(
await
this
.
load
(
'
configurations
'
),
'
key
'
);
const
raw_utility
=
_
.
keyBy
(
await
this
.
load
(
'
configurations
'
),
'
key
'
);
let
route_tables
=
await
this
.
load
(
'
route tables
'
)
const
route_lists
=
YAML
.
parse
(
fs
.
readFileSync
(
path
.
join
(
'
lists
'
,
'
result.yaml
'
),
"
utf8
"
));
for
(
let
plan
of
route_tables
)
{
plan
.
name
=
plan
.
list
+
"
_
"
+
plan
.
gateway
.
replace
(
/-/g
,
"
_
"
).
split
(
"
.
"
)[
0
]
plan
.
list
=
JSON
.
parse
(
JSON
.
stringify
(
route_lists
[
plan
.
list
]));
plan
.
gatewayAddress
=
hosts
[
plan
.
gateway
].
address
;
}
const
vars
=
{
const
vars
=
{
all_subnets
:
JSON
.
parse
(
JSON
.
stringify
(
this
.
all_subnets
))
all_subnets
:
this
.
all_subnets
,
route_tables
};
};
for
(
let
col
in
raw_
data
)
{
for
(
let
col
in
raw_
utility
)
{
vars
[
col
]
=
raw_
data
[
col
].
value
;
vars
[
col
]
=
raw_
utility
[
col
].
value
;
}
}
return
vars
;
return
vars
;
...
@@ -59,7 +67,7 @@ class InventoryBuilder {
...
@@ -59,7 +67,7 @@ class InventoryBuilder {
host_vars
(
host
)
{
host_vars
(
host
)
{
const
connections
=
[];
const
connections
=
[];
const
null_connection
=
"
10000,null
"
;
const
null_connection
=
"
10000,null
"
;
const
lan_interfaces
=
host
.
lan_interfaces
.
split
(
"
,
"
)
;
const
lan_interfaces
=
host
.
lan_interfaces
.
length
>
0
?
host
.
lan_interfaces
.
split
(
"
,
"
)
:
[]
;
for
(
const
h
of
this
.
connections
)
{
for
(
const
h
of
this
.
connections
)
{
if
(
h
!=
host
.
name
)
{
if
(
h
!=
host
.
name
)
{
const
to
=
host
[
h
];
const
to
=
host
[
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