From 262f058d36b3f32e1fad4bcc3d4210075958ea43 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 08:23:19 +0200 Subject: [PATCH 01/17] add User Agent to Wget call against the Broker --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index 3e8e68d9..fdf105d5 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -120,10 +120,11 @@ is_loadbalancing_enabled() { get_wgkex_data(){ local version="$1" WGKEX_BROKER="$PROTO://$WGKEX_BROKER_BASE_PATH/api/$version/wg/key/exchange" + local user_agent="OpenWrt xx.xx Gluon xx.xx checkuplink x.x" logger -p info -t checkuplink "Contacting wgkex broker $WGKEX_BROKER" - if ! WGKEX_DATA=$(force_wan_connection wget -q -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then + if ! WGKEX_DATA=$(force_wan_connection wget -q -U=$user_agent -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then logger -p err -t checkuplink "Contacting wgkex broker failed, response: $WGKEX_DATA" else logger -p info -t checkuplink "Got data from wgkex broker: $WGKEX_DATA" From 7371b808f6dea752b128477fd8355ff61fe06323 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 08:46:51 +0200 Subject: [PATCH 02/17] add example --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index fdf105d5..9ececc4f 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -120,8 +120,9 @@ is_loadbalancing_enabled() { get_wgkex_data(){ local version="$1" WGKEX_BROKER="$PROTO://$WGKEX_BROKER_BASE_PATH/api/$version/wg/key/exchange" - local user_agent="OpenWrt xx.xx Gluon xx.xx checkuplink x.x" - + local user_agent="Mozilla/5.0 OpenWrt xx.xx Gluon xx.xx Modell/xxx checkuplink/1.0" +#more examples +#OpenWrt/21.02.0 (GLUON/2024.1; Checkuplink/2.0) x64 logger -p info -t checkuplink "Contacting wgkex broker $WGKEX_BROKER" if ! WGKEX_DATA=$(force_wan_connection wget -q -U=$user_agent -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then From 7b67808af0afac4c5e96e576247735b6e177d36a Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 10:38:17 +0200 Subject: [PATCH 03/17] build User Agent --- .../gluon-mesh-wireguard-vxlan/checkuplink | 19 ++++++++++++--- .../get-user-agent-infos.lua | 24 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index 9ececc4f..3b5afdae 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -117,12 +117,25 @@ is_loadbalancing_enabled() { return 0 } +get_user_agent(){ + local userAgentInfos=$(lua /lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua) + + #OpenWrt/21.02.0 (kernel/5.10.206; gluon/v2023.1.2+; firmware/v2024.3.1) checkuplink/2.0 VMware, Inc. VMware Virtual Platform + openwrt_version="$(echo "$userAgentInfos" | sed -n 1p)" + kernel="$(echo "$userAgentInfos" | sed -n 2p)" + gluon_version="$(echo "$userAgentInfos" | sed -n 3p)" + firmware_release="$(echo "$userAgentInfos" | sed -n 4p)" + model="$(echo "$userAgentInfos" | sed -n 4p)" + + local user_agent="OpenWrt/$openwrt_version (kernel/$kernel; gluon/$gluon_version; firmware/$firmware_release) checkuplink/2.0 $model" + + echo $user_agent +} + get_wgkex_data(){ local version="$1" WGKEX_BROKER="$PROTO://$WGKEX_BROKER_BASE_PATH/api/$version/wg/key/exchange" - local user_agent="Mozilla/5.0 OpenWrt xx.xx Gluon xx.xx Modell/xxx checkuplink/1.0" -#more examples -#OpenWrt/21.02.0 (GLUON/2024.1; Checkuplink/2.0) x64 + local user_agent=$(get_user_agent()) logger -p info -t checkuplink "Contacting wgkex broker $WGKEX_BROKER" if ! WGKEX_DATA=$(force_wan_connection wget -q -U=$user_agent -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua new file mode 100644 index 00000000..3ad2d375 --- /dev/null +++ b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua @@ -0,0 +1,24 @@ +local json = require 'jsonc' +local util = require 'gluon.util' +local info = require 'gluon.info' + +-- Get System Infos +local data = assert(json.parse(util.exec('ubus call system board')), "Malformed JSON response, wrong JSON format") + +assert(data.release, "Malformed JSON response, missing required value: release") +local Openwrt_version = assert(data.release.version, "Malformed JSON response, missing required value: version") +local kernel = assert(data.kernel, "Malformed JSON response, missing required value: kernel") + +local model = assert(data.model, "Malformed JSON response, missing required value: model") + +-- Get Gluon Infos +local infos = info.get_info() + +local gluon_version = assert(infos.gluon_version, "Malformed gluon-info, missing required value: gluon version") +local firmware_release = assert(infos.firmware_release, "Malformed gluon-info, missing required value: firmware release") + +print(Openwrt_version) +print(kernel) +print(gluon_version) +print(firmware_release) +print(model) From e487c8b08593a143d992aa090222901e118476d3 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 10:48:22 +0200 Subject: [PATCH 04/17] some more bugfixes --- .../lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index 3b5afdae..bf1bb1fa 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -120,14 +120,14 @@ is_loadbalancing_enabled() { get_user_agent(){ local userAgentInfos=$(lua /lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua) - #OpenWrt/21.02.0 (kernel/5.10.206; gluon/v2023.1.2+; firmware/v2024.3.1) checkuplink/2.0 VMware, Inc. VMware Virtual Platform openwrt_version="$(echo "$userAgentInfos" | sed -n 1p)" kernel="$(echo "$userAgentInfos" | sed -n 2p)" gluon_version="$(echo "$userAgentInfos" | sed -n 3p)" firmware_release="$(echo "$userAgentInfos" | sed -n 4p)" - model="$(echo "$userAgentInfos" | sed -n 4p)" + model="$(echo "$userAgentInfos" | sed -n 5p)" - local user_agent="OpenWrt/$openwrt_version (kernel/$kernel; gluon/$gluon_version; firmware/$firmware_release) checkuplink/2.0 $model" + #OpenWrt/21.02.0 (kernel/5.10.206; gluon/v2023.1.2+; firmware/v2024.3.1) VMware, Inc. VMware Virtual Platform + local user_agent="OpenWrt/$openwrt_version (kernel/$kernel; gluon/$gluon_version; firmware/$firmware_release) $model" echo $user_agent } @@ -135,7 +135,7 @@ get_user_agent(){ get_wgkex_data(){ local version="$1" WGKEX_BROKER="$PROTO://$WGKEX_BROKER_BASE_PATH/api/$version/wg/key/exchange" - local user_agent=$(get_user_agent()) + local user_agent=$(get_user_agent) logger -p info -t checkuplink "Contacting wgkex broker $WGKEX_BROKER" if ! WGKEX_DATA=$(force_wan_connection wget -q -U=$user_agent -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then From 77b1687d99f9e73062f05dfc7239958f384732e3 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 10:50:52 +0200 Subject: [PATCH 05/17] ad some more ; --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index bf1bb1fa..ccfb2e32 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -126,8 +126,8 @@ get_user_agent(){ firmware_release="$(echo "$userAgentInfos" | sed -n 4p)" model="$(echo "$userAgentInfos" | sed -n 5p)" - #OpenWrt/21.02.0 (kernel/5.10.206; gluon/v2023.1.2+; firmware/v2024.3.1) VMware, Inc. VMware Virtual Platform - local user_agent="OpenWrt/$openwrt_version (kernel/$kernel; gluon/$gluon_version; firmware/$firmware_release) $model" + #OpenWrt/21.02.0 (kernel/5.10.206; gluon/v2023.1.2+; firmware/v2024.3.1;) VMware, Inc. VMware Virtual Platform + local user_agent="OpenWrt/$openwrt_version (kernel/$kernel; gluon/$gluon_version; firmware/$firmware_release;) $model" echo $user_agent } From e63f70b3c6207dc6cf345018e42b3a68229a4253 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 10:57:27 +0200 Subject: [PATCH 06/17] promote gluon and firmware --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index ccfb2e32..fef31eb1 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -127,7 +127,7 @@ get_user_agent(){ model="$(echo "$userAgentInfos" | sed -n 5p)" #OpenWrt/21.02.0 (kernel/5.10.206; gluon/v2023.1.2+; firmware/v2024.3.1;) VMware, Inc. VMware Virtual Platform - local user_agent="OpenWrt/$openwrt_version (kernel/$kernel; gluon/$gluon_version; firmware/$firmware_release;) $model" + local user_agent="OpenWrt/$openwrt_version (kernel/$kernel) gluon/$gluon_version firmware/$firmware_release $model" echo $user_agent } From 5080713b21845d3f4f6345461b44323437118094 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 11:32:47 +0200 Subject: [PATCH 07/17] Update Formating --- .../gluon-mesh-wireguard-vxlan/checkuplink | 17 +++++++++-------- .../get-user-agent-infos.lua | 9 +++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index fef31eb1..cc0ddde8 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -120,14 +120,15 @@ is_loadbalancing_enabled() { get_user_agent(){ local userAgentInfos=$(lua /lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua) - openwrt_version="$(echo "$userAgentInfos" | sed -n 1p)" - kernel="$(echo "$userAgentInfos" | sed -n 2p)" - gluon_version="$(echo "$userAgentInfos" | sed -n 3p)" - firmware_release="$(echo "$userAgentInfos" | sed -n 4p)" - model="$(echo "$userAgentInfos" | sed -n 5p)" - - #OpenWrt/21.02.0 (kernel/5.10.206; gluon/v2023.1.2+; firmware/v2024.3.1;) VMware, Inc. VMware Virtual Platform - local user_agent="OpenWrt/$openwrt_version (kernel/$kernel) gluon/$gluon_version firmware/$firmware_release $model" + gluon_version="$(echo "$userAgentInfos" | sed -n 1p)" + board_name="$(echo "$userAgentInfos" | sed -n 2p)" + openwrt_version="$(echo "$userAgentInfos" | sed -n 3p)" + kernel="$(echo "$userAgentInfos" | sed -n 4p)" + target="$(echo "$userAgentInfos" | sed -n 5p)" + firmware_release="$(echo "$userAgentInfos" | sed -n 6p)" + + #gluon/v2023.1.2+ (vmware-inc-vmware-virtual-platform) OpenWrt/22.03-SNAPSHOT (kernel/5.10.206; x86/64) firmware/v2024.3.1 + local user_agent="gluon/$gluon_version ($board_name) OpenWrt/$openwrt_version (kernel/$kernel; $target) firmware/$firmware_release" echo $user_agent } diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua index 3ad2d375..f3ff6470 100644 --- a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua +++ b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua @@ -7,18 +7,19 @@ local data = assert(json.parse(util.exec('ubus call system board')), "Malformed assert(data.release, "Malformed JSON response, missing required value: release") local Openwrt_version = assert(data.release.version, "Malformed JSON response, missing required value: version") +local target = assert(data.release.target, "Malformed JSON response, missing required value: target") +local board_name = assert(data.board_name, "Malformed JSON response, missing required value: board_name") local kernel = assert(data.kernel, "Malformed JSON response, missing required value: kernel") -local model = assert(data.model, "Malformed JSON response, missing required value: model") - -- Get Gluon Infos local infos = info.get_info() local gluon_version = assert(infos.gluon_version, "Malformed gluon-info, missing required value: gluon version") local firmware_release = assert(infos.firmware_release, "Malformed gluon-info, missing required value: firmware release") +print(gluon_version) +print(board_name) print(Openwrt_version) print(kernel) -print(gluon_version) +print(target) print(firmware_release) -print(model) From c0047ebe7b1d8cd449397c315dd599b347120c2e Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 11:36:36 +0200 Subject: [PATCH 08/17] fix line is too long --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 4 ++-- .../gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index cc0ddde8..38d74a6e 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -125,10 +125,10 @@ get_user_agent(){ openwrt_version="$(echo "$userAgentInfos" | sed -n 3p)" kernel="$(echo "$userAgentInfos" | sed -n 4p)" target="$(echo "$userAgentInfos" | sed -n 5p)" - firmware_release="$(echo "$userAgentInfos" | sed -n 6p)" + fw_release="$(echo "$userAgentInfos" | sed -n 6p)" #gluon/v2023.1.2+ (vmware-inc-vmware-virtual-platform) OpenWrt/22.03-SNAPSHOT (kernel/5.10.206; x86/64) firmware/v2024.3.1 - local user_agent="gluon/$gluon_version ($board_name) OpenWrt/$openwrt_version (kernel/$kernel; $target) firmware/$firmware_release" + local user_agent="gluon/$gluon_version ($board_name) OpenWrt/$openwrt_version (kernel/$kernel; $target) firmware/$fw_release" echo $user_agent } diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua index f3ff6470..b6f437ac 100644 --- a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua +++ b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua @@ -15,11 +15,11 @@ local kernel = assert(data.kernel, "Malformed JSON response, missing required va local infos = info.get_info() local gluon_version = assert(infos.gluon_version, "Malformed gluon-info, missing required value: gluon version") -local firmware_release = assert(infos.firmware_release, "Malformed gluon-info, missing required value: firmware release") +local fw_release = assert(infos.firmware_release, "Malformed gluon-info, missing required value: firmware release") print(gluon_version) print(board_name) print(Openwrt_version) print(kernel) print(target) -print(firmware_release) +print(fw_release) From 714127bed596c8893fd7f8f67cc163dc7f7cb533 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 11:37:39 +0200 Subject: [PATCH 09/17] fix shellcheck --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index 38d74a6e..c7cd9023 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -130,7 +130,7 @@ get_user_agent(){ #gluon/v2023.1.2+ (vmware-inc-vmware-virtual-platform) OpenWrt/22.03-SNAPSHOT (kernel/5.10.206; x86/64) firmware/v2024.3.1 local user_agent="gluon/$gluon_version ($board_name) OpenWrt/$openwrt_version (kernel/$kernel; $target) firmware/$fw_release" - echo $user_agent + echo "$user_agent" } get_wgkex_data(){ From 0ce302978f64ac8a0b7b3f335d6934386cd06349 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 12:06:55 +0200 Subject: [PATCH 10/17] try fix ci --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index c7cd9023..46567118 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -118,7 +118,8 @@ is_loadbalancing_enabled() { } get_user_agent(){ - local userAgentInfos=$(lua /lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua) + local userAgentInfos gluon_version board_name openwrt_version kernel fw_release user_agent + userAgentInfos=$(lua /lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua) gluon_version="$(echo "$userAgentInfos" | sed -n 1p)" board_name="$(echo "$userAgentInfos" | sed -n 2p)" @@ -128,7 +129,7 @@ get_user_agent(){ fw_release="$(echo "$userAgentInfos" | sed -n 6p)" #gluon/v2023.1.2+ (vmware-inc-vmware-virtual-platform) OpenWrt/22.03-SNAPSHOT (kernel/5.10.206; x86/64) firmware/v2024.3.1 - local user_agent="gluon/$gluon_version ($board_name) OpenWrt/$openwrt_version (kernel/$kernel; $target) firmware/$fw_release" + user_agent="gluon/$gluon_version ($board_name) OpenWrt/$openwrt_version (kernel/$kernel; $target) firmware/$fw_release" echo "$user_agent" } @@ -139,7 +140,7 @@ get_wgkex_data(){ local user_agent=$(get_user_agent) logger -p info -t checkuplink "Contacting wgkex broker $WGKEX_BROKER" - if ! WGKEX_DATA=$(force_wan_connection wget -q -U=$user_agent -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then + if ! WGKEX_DATA=$(force_wan_connection wget -q -U="$user_agent" -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then logger -p err -t checkuplink "Contacting wgkex broker failed, response: $WGKEX_DATA" else logger -p info -t checkuplink "Got data from wgkex broker: $WGKEX_DATA" From e5456ed685aff9216571fab8df4cc221aaad5ba7 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 12:21:04 +0200 Subject: [PATCH 11/17] Declare and assign separately --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index 46567118..9a697c4a 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -135,9 +135,11 @@ get_user_agent(){ } get_wgkex_data(){ - local version="$1" + local version user_agent + version="$1" + user_agent=$(get_user_agent) + WGKEX_BROKER="$PROTO://$WGKEX_BROKER_BASE_PATH/api/$version/wg/key/exchange" - local user_agent=$(get_user_agent) logger -p info -t checkuplink "Contacting wgkex broker $WGKEX_BROKER" if ! WGKEX_DATA=$(force_wan_connection wget -q -U="$user_agent" -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then From 62b6ba901c61f42d6670cec8e54a4c34c5ce240f Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 12:35:36 +0200 Subject: [PATCH 12/17] fix UserAgent --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index 9a697c4a..b3e0c909 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -142,7 +142,7 @@ get_wgkex_data(){ WGKEX_BROKER="$PROTO://$WGKEX_BROKER_BASE_PATH/api/$version/wg/key/exchange" logger -p info -t checkuplink "Contacting wgkex broker $WGKEX_BROKER" - if ! WGKEX_DATA=$(force_wan_connection wget -q -U="$user_agent" -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then + if ! WGKEX_DATA=$(force_wan_connection wget -q -U "$user_agent" -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then logger -p err -t checkuplink "Contacting wgkex broker failed, response: $WGKEX_DATA" else logger -p info -t checkuplink "Got data from wgkex broker: $WGKEX_DATA" From 647c99382ff74e235d9a089cb66f670a4800e4c7 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 18:46:18 +0200 Subject: [PATCH 13/17] move get_user_agent function in lua --- .../gluon-mesh-wireguard-vxlan/checkuplink | 18 +----------------- .../get-user-agent-infos.lua | 7 +------ 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index b3e0c909..bc937f41 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -117,27 +117,11 @@ is_loadbalancing_enabled() { return 0 } -get_user_agent(){ - local userAgentInfos gluon_version board_name openwrt_version kernel fw_release user_agent - userAgentInfos=$(lua /lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua) - - gluon_version="$(echo "$userAgentInfos" | sed -n 1p)" - board_name="$(echo "$userAgentInfos" | sed -n 2p)" - openwrt_version="$(echo "$userAgentInfos" | sed -n 3p)" - kernel="$(echo "$userAgentInfos" | sed -n 4p)" - target="$(echo "$userAgentInfos" | sed -n 5p)" - fw_release="$(echo "$userAgentInfos" | sed -n 6p)" - - #gluon/v2023.1.2+ (vmware-inc-vmware-virtual-platform) OpenWrt/22.03-SNAPSHOT (kernel/5.10.206; x86/64) firmware/v2024.3.1 - user_agent="gluon/$gluon_version ($board_name) OpenWrt/$openwrt_version (kernel/$kernel; $target) firmware/$fw_release" - - echo "$user_agent" -} get_wgkex_data(){ local version user_agent version="$1" - user_agent=$(get_user_agent) + user_agent=$(lua /lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua) WGKEX_BROKER="$PROTO://$WGKEX_BROKER_BASE_PATH/api/$version/wg/key/exchange" logger -p info -t checkuplink "Contacting wgkex broker $WGKEX_BROKER" diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua index b6f437ac..d932f0d3 100644 --- a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua +++ b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua @@ -17,9 +17,4 @@ local infos = info.get_info() local gluon_version = assert(infos.gluon_version, "Malformed gluon-info, missing required value: gluon version") local fw_release = assert(infos.firmware_release, "Malformed gluon-info, missing required value: firmware release") -print(gluon_version) -print(board_name) -print(Openwrt_version) -print(kernel) -print(target) -print(fw_release) +print(string.format("gluon/%s (%s) OpenWrt/%s (kernel/%s; %s) firmware/%s", gluon_version, board_name, Openwrt_version, kernel, target, fw_release)) From f4b2142a2bb71794aabcbce2dd2384cb6b8fc2ba Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 18:47:28 +0200 Subject: [PATCH 14/17] fix to long lua code --- .../gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua index d932f0d3..59e17661 100644 --- a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua +++ b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua @@ -17,4 +17,5 @@ local infos = info.get_info() local gluon_version = assert(infos.gluon_version, "Malformed gluon-info, missing required value: gluon version") local fw_release = assert(infos.firmware_release, "Malformed gluon-info, missing required value: firmware release") -print(string.format("gluon/%s (%s) OpenWrt/%s (kernel/%s; %s) firmware/%s", gluon_version, board_name, Openwrt_version, kernel, target, fw_release)) +print(string.format("gluon/%s (%s) OpenWrt/%s (kernel/%s; %s) firmware/%s", +gluon_version, board_name, Openwrt_version, kernel, target, fw_release)) From 21c5bffff6db207214eb42c93a18d3f6512b5d37 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 18:49:12 +0200 Subject: [PATCH 15/17] fix lua linter --- .../gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua index 59e17661..0796835a 100644 --- a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua +++ b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua @@ -17,5 +17,5 @@ local infos = info.get_info() local gluon_version = assert(infos.gluon_version, "Malformed gluon-info, missing required value: gluon version") local fw_release = assert(infos.firmware_release, "Malformed gluon-info, missing required value: firmware release") -print(string.format("gluon/%s (%s) OpenWrt/%s (kernel/%s; %s) firmware/%s", +print(string.format("gluon/%s (%s) OpenWrt/%s (kernel/%s; %s) firmware/%s", gluon_version, board_name, Openwrt_version, kernel, target, fw_release)) From 5e724f0e4699c2f78fb9bc9d49a82c8dafb130a1 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 1 Apr 2024 19:33:53 +0200 Subject: [PATCH 16/17] move code around --- .../files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index bc937f41..ecbaef7f 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -121,9 +121,9 @@ is_loadbalancing_enabled() { get_wgkex_data(){ local version user_agent version="$1" + WGKEX_BROKER="$PROTO://$WGKEX_BROKER_BASE_PATH/api/$version/wg/key/exchange" user_agent=$(lua /lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua) - WGKEX_BROKER="$PROTO://$WGKEX_BROKER_BASE_PATH/api/$version/wg/key/exchange" logger -p info -t checkuplink "Contacting wgkex broker $WGKEX_BROKER" if ! WGKEX_DATA=$(force_wan_connection wget -q -U "$user_agent" -O- --post-data='{"domain": "'"$SEGMENT"'","public_key": "'"$PUBLICKEY"'"}' "$WGKEX_BROKER"); then From 15dfb38139683769f352a576e12b8bf57d06839e Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 2 Apr 2024 08:33:42 +0000 Subject: [PATCH 17/17] fix uppercase letter --- .../gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua index 0796835a..f5c5a362 100644 --- a/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua +++ b/ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua @@ -6,7 +6,7 @@ local info = require 'gluon.info' local data = assert(json.parse(util.exec('ubus call system board')), "Malformed JSON response, wrong JSON format") assert(data.release, "Malformed JSON response, missing required value: release") -local Openwrt_version = assert(data.release.version, "Malformed JSON response, missing required value: version") +local openwrt_version = assert(data.release.version, "Malformed JSON response, missing required value: version") local target = assert(data.release.target, "Malformed JSON response, missing required value: target") local board_name = assert(data.board_name, "Malformed JSON response, missing required value: board_name") local kernel = assert(data.kernel, "Malformed JSON response, missing required value: kernel") @@ -18,4 +18,4 @@ local gluon_version = assert(infos.gluon_version, "Malformed gluon-info, missing local fw_release = assert(infos.firmware_release, "Malformed gluon-info, missing required value: firmware release") print(string.format("gluon/%s (%s) OpenWrt/%s (kernel/%s; %s) firmware/%s", -gluon_version, board_name, Openwrt_version, kernel, target, fw_release)) +gluon_version, board_name, openwrt_version, kernel, target, fw_release))