From 656f02b6a4e4a24fa6343b6296c092c4e33a23a7 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 28 Feb 2024 11:02:53 +0100 Subject: Update vpn-tinc to use IPv6 --- playbooks.d/vpn-tinc/playbook.bash | 61 +++++++++++++++++++----------------- playbooks.d/vpn-tinc/share/tinc.conf | 7 +++-- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/playbooks.d/vpn-tinc/playbook.bash b/playbooks.d/vpn-tinc/playbook.bash index 91d79f5..909dc8f 100644 --- a/playbooks.d/vpn-tinc/playbook.bash +++ b/playbooks.d/vpn-tinc/playbook.bash @@ -11,8 +11,6 @@ playbook_add() local data local etc local host - local ipv4 - local ipv6 local name local tinc local tincd @@ -20,17 +18,10 @@ playbook_add() data="$(playbook_path "data")" etc="$(config "fs.etcdir")/tinc/tyilnet" host="$(tr "." "_" <<< "${BASHTARD_PLATFORM[fqdn]}")" - ipv4="$(config "$BASHTARD_PLAYBOOK.ipv4")" - ipv6="$(config "$BASHTARD_PLAYBOOK.ipv6")" name="$(config "$BASHTARD_PLAYBOOK.name")" tinc="$(config "app.tinc")" tincd="$(config "app.tincd")" - case "${BASHTARD_PLATFORM[key]}" in - freebsd) iptool=ifconfig ;; - *) iptool=ip - esac - info "$BASHTARD_PLAYBOOK/add" "Installing tinc" pkg install "tinc" @@ -39,24 +30,6 @@ playbook_add() "$etc" \ "$etc/hosts" - file_template tinc.conf \ - "name=$host" \ - > "$etc/tinc.conf" - - file_template "tinc-up-$iptool" \ - "ip4=$ipv4" \ - "ip6=$ipv6" \ - > "$etc/tinc-up" - - file_template "tinc-down-$iptool" \ - "ip4=$ipv4" \ - "ip6=$ipv6" \ - > "$etc/tinc-down" - - file_template "host" \ - "ip4=$ipv4" \ - "ip6=$ipv6" \ - > "$etc/hosts/$host" chmod +x \ "$etc/tinc-up" \ @@ -77,12 +50,13 @@ playbook_add() info "$BASHTARD_PLAYBOOK/add" "Adding new host to Bashtard configs" mkdir -pv -- "$data/hosts" + + playbook_sync + cp -v -- \ "$etc/hosts/$host" \ "$data/hosts/$host" - playbook_sync - info "$BASHTARD_PLAYBOOK" "Enabling VPN service" case "${BASHTARD_PLATFORM[key]}" in @@ -117,14 +91,43 @@ playbook_sync() local etc local hash local host + local iptool + local ipv4 + local ipv6 local name data="$(playbook_path "data")" etc="$(config "fs.etcdir")/tinc/$(config "$BASHTARD_PLAYBOOK.name")" hash="$(dir_hash "$etc/hosts")" host="$(tr "." "_" <<< "${BASHTARD_PLATFORM[fqdn]}")" + ipv4="$(config "$BASHTARD_PLAYBOOK.ipv4")" + ipv6="$(config "$BASHTARD_PLAYBOOK.ipv6")" name="$(config "$BASHTARD_PLAYBOOK.name")" + case "${BASHTARD_PLATFORM[key]}" in + freebsd) iptool=ifconfig ;; + *) iptool=ip + esac + + file_template tinc.conf \ + "name=$host" \ + > "$etc/tinc.conf" + + file_template "tinc-up-$iptool" \ + "ip4=$ipv4" \ + "ip6=$ipv6" \ + > "$etc/tinc-up" + + file_template "tinc-down-$iptool" \ + "ip4=$ipv4" \ + "ip6=$ipv6" \ + > "$etc/tinc-down" + + file_template "host" \ + "ip4=$ipv4" \ + "ip6=$ipv6" \ + > "$etc/hosts/$host" + info "$BASHTARD_PLAYBOOK" "Regenerating tinc hosts" rm -fr -- "$etc/hosts" mkdir -p -- "$etc/hosts" diff --git a/playbooks.d/vpn-tinc/share/tinc.conf b/playbooks.d/vpn-tinc/share/tinc.conf index 89ccdfd..11696a7 100644 --- a/playbooks.d/vpn-tinc/share/tinc.conf +++ b/playbooks.d/vpn-tinc/share/tinc.conf @@ -1,7 +1,10 @@ Name = ${name} ConnectTo = caeghi_tyil_net -ConnectTo = denahnu_tyil_net +ConnectTo = faiwoo_tyil_net ConnectTo = gaeru_tyil_net -ConnectTo = hurzak_tyil_net ConnectTo = jaomox_tyil_net +ConnectTo = mieshu_tyil_net +ConnectTo = nouki_tyil_net +ConnectTo = oolah_tyil_net +ConnectTo = qohrei_tyil_net -- cgit v1.1