Commit e0f9949b authored by nanahira's avatar nanahira

fix bird

parent b6618a05
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
host_key_checking = False host_key_checking = False
strategy_plugins = mitogen-0.2.9/ansible_mitogen/plugins/strategy strategy_plugins = mitogen-0.2.9/ansible_mitogen/plugins/strategy
strategy = mitogen_free strategy = mitogen_free
inventory = ../result/inventory.yaml
...@@ -43,7 +43,6 @@ protocol kernel { ...@@ -43,7 +43,6 @@ protocol kernel {
}; };
kernel table {{plan.destMark}}; kernel table {{plan.destMark}};
} }
{% endif %}
{% endfor %} {% endfor %}
protocol ospf v2 { protocol ospf v2 {
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
- name: table pref 81 lookup main - name: table pref 81 lookup main
become: true become: true
shell: 'ip -4 rule add pref 81 to {{item}} lookup main || true' shell: 'ip -4 rule add pref 81 to {{item}} lookup main || true'
with_items: '{{routeLists.mycard}}'
# 为了提高测试时候的性能,不改动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'
...@@ -91,3 +92,11 @@ ...@@ -91,3 +92,11 @@
restarted: true restarted: true
services: services:
- frps - frps
- name: restart_frpc
docker_compose:
project_src: '{{ansible_user_dir}}/nextgen-network/services'
restarted: true
services:
- frpc_{{item}}
with_items: '{{connections}}'
when: 'item.type == "wgfrp" and item.'
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- name: '{{conn.name}}: frpc template' - name: '{{conn.name}}: frpc template'
template: template:
src: 'frpc.ini.j2' src: 'frpc.ini.j2'
dest: '{{ansible_user_dir}}/nextgen-network/services/frpc_{{item.name}}.ini' dest: '{{ansible_user_dir}}/nextgen-network/services/frpc-{{item.name}}.ini'
when: 'conn.frpType == "frpc"' when: 'conn.frpType == "frpc"'
notify: restart_frpc notify: restart_frpc
......
...@@ -5,25 +5,25 @@ source {{ansible_user_dir}}/nextgen-network/scripts/utility.sh ...@@ -5,25 +5,25 @@ source {{ansible_user_dir}}/nextgen-network/scripts/utility.sh
{% for plan in routePlans %} {% for plan in routePlans %}
interface_switch_chnroute -D u_{{plan.name}}_chnroute {{plan.destMark}} interface_switch_chnroute -D u_{{plan.name}}_chnroute {{plan.destMark}}
{% endfor %} {% endfor %}
{% for gateway in gateways %} {% for gw in gateways %}
interface_switch_chnroute -D u_{{gateway.isp}}_chnroute {{gateway.selectionMark}} interface_switch_chnroute -D u_{{gw.isp}}_chnroute {{gw.selectionMark}}
{% endfor %} {% endfor %}
## all ## all
{% for plan in routePlans %} {% for plan in routePlans %}
interface_switch -D u_{{plan.name}}_all {{plan.destMark}} interface_switch -D u_{{plan.name}}_all {{plan.destMark}}
{% endfor %} {% endfor %}
{% for gateway in gateways %} {% for gw in gateways %}
interface_switch -D u_{{gateway.isp}}_all {{gateway.selectionMark}} interface_switch -D u_{{gw.isp}}_all {{gw.selectionMark}}
{% endfor %} {% endfor %}
## restore mark ## restore mark
{% for plan in routePlans %} {% for plan in routePlans %}
ip rule del pref 400 fwmark {{gateway.selectionMark}} lookup {{plan.destMark}} ip rule del pref 400 fwmark {{plan.destMark}} lookup {{plan.destMark}}
restore_mark -D {{plan.destMark}} restore_mark -D {{plan.destMark}}
{% endfor %} {% endfor %}
{% for gateway in gateways %} {% for gw in gateways %}
restore_mark -D {{gateway.selectionMark}} restore_mark -D {{gw.selectionMark}}
{% endfor %} {% endfor %}
true true
...@@ -5,25 +5,25 @@ source {{ansible_user_dir}}/nextgen-network/scripts/utility.sh ...@@ -5,25 +5,25 @@ source {{ansible_user_dir}}/nextgen-network/scripts/utility.sh
{% for plan in routePlans %} {% for plan in routePlans %}
interface_switch_chnroute -A u_{{plan.name}}_chnroute {{plan.destMark}} interface_switch_chnroute -A u_{{plan.name}}_chnroute {{plan.destMark}}
{% endfor %} {% endfor %}
{% for gateway in gateways %} {% for gw in gateways %}
interface_switch_chnroute -A u_{{gateway.isp}}_chnroute {{gateway.selectionMark}} interface_switch_chnroute -A u_{{gw.isp}}_chnroute {{gw.selectionMark}}
{% endfor %} {% endfor %}
## all ## all
{% for plan in routePlans %} {% for plan in routePlans %}
interface_switch -A u_{{plan.name}}_all {{plan.destMark}} interface_switch -A u_{{plan.name}}_all {{plan.destMark}}
{% endfor %} {% endfor %}
{% for gateway in gateways %} {% for gw in gateways %}
interface_switch -A u_{{gateway.isp}}_all {{gateway.selectionMark}} interface_switch -A u_{{gw.isp}}_all {{gw.selectionMark}}
{% endfor %} {% endfor %}
## restore mark ## restore mark
{% for plan in routePlans %} {% for plan in routePlans %}
ip rule add pref 400 fwmark {{gateway.selectionMark}} lookup {{plan.destMark}} ip rule add pref 400 fwmark {{plan.destMark}} lookup {{plan.destMark}}
restore_mark -A {{plan.destMark}} restore_mark -A {{plan.destMark}}
{% endfor %} {% endfor %}
{% for gateway in gateways %} {% for gw in gateways %}
restore_mark -A {{gateway.selectionMark}} restore_mark -A {{gw.selectionMark}}
{% endfor %} {% endfor %}
true true
...@@ -79,7 +79,7 @@ class InventoryBuilder { ...@@ -79,7 +79,7 @@ class InventoryBuilder {
restart: "always", restart: "always",
image: "git-registry.mycard.moe/nanahira/docker-bird", image: "git-registry.mycard.moe/nanahira/docker-bird",
network_mode: "host", network_mode: "host",
cap_add: ["NET_ADMIN"], cap_add: ["NET_ADMIN", "NET_BROADCAST", "NET_RAW"],
volumes: ["./bird.conf:/etc/bird/bird.conf:ro"] volumes: ["./bird.conf:/etc/bird/bird.conf:ro"]
} }
} }
...@@ -116,6 +116,7 @@ class InventoryBuilder { ...@@ -116,6 +116,7 @@ class InventoryBuilder {
return { return {
ansible_ssh_user: host.user, ansible_ssh_user: host.user,
ansible_python_interpreter: "python3",
address: host.address, address: host.address,
isCN: host.location.startsWith("CN"), isCN: host.location.startsWith("CN"),
key: host.wgPrivateKey, key: host.wgPrivateKey,
...@@ -172,12 +173,12 @@ class InventoryBuilder { ...@@ -172,12 +173,12 @@ class InventoryBuilder {
} }
if (frpType === "frpc") { if (frpType === "frpc") {
local.dockerServices.services[`frpc_${remote.name}`] = { local.dockerServices.services[`frpc-${name}`] = {
restart: "always", restart: "always",
image: "fatedier/frpc:v0.34.2", image: "fatedier/frpc:v0.34.2",
network_mode: "host", network_mode: "host",
command: "-c /frpc.ini", command: "-c /frpc.ini",
volumes: [`./frpc_${remote.name}.ini:/frpc.ini:ro`] volumes: [`./frpc-${name}.ini:/frpc.ini:ro`]
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment