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-wget-infos.lua similarity index 91% rename from ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-user-agent-infos.lua rename to ffmuc-mesh-vpn-wireguard-vxlan/luasrc/lib/gluon/gluon-mesh-wireguard-vxlan/get-wget-infos.lua index f5c5a362..d6462f39 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-wget-infos.lua @@ -19,3 +19,10 @@ local fw_release = assert(infos.firmware_release, "Malformed gluon-info, missing print(string.format("gluon/%s (%s) OpenWrt/%s (kernel/%s; %s) firmware/%s", gluon_version, board_name, openwrt_version, kernel, target, fw_release)) + +print(gluon_version) +print(board_name) +print(openwrt_version) +print(kernel) +print(target) +print(fw_release) diff --git a/ffmuc-mesh-vpn-wireguard-vxlan/shsrc/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink b/ffmuc-mesh-vpn-wireguard-vxlan/shsrc/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink index 540fc06f..bdab5e86 100755 --- a/ffmuc-mesh-vpn-wireguard-vxlan/shsrc/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink +++ b/ffmuc-mesh-vpn-wireguard-vxlan/shsrc/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink @@ -137,15 +137,34 @@ is_loadbalancing_enabled() { return 0 } +customwget() { + wget_infos=$(lua /lib/gluon/gluon-mesh-wireguard-vxlan/get-wget-infos.lua) + user_agent=$(echo "$wget_infos" | sed -n 1p) + gluon_version=$(echo "$wget_infos" | sed -n 2p) + board_name=$(echo "$wget_infos" | sed -n 3p) + openwrt_version=$(echo "$wget_infos" | sed -n 4p) + kernel=$(echo "$wget_infos" | sed -n 5p) + target=$(echo "$wget_infos" | sed -n 6p) + fw_release=$(echo "$wget_infos" | sed -n 7p) + + force_wan_connection wget -q -U "$user_agent" \ + --header="X-Gluon-Version: $gluon_version" \ + --header="X-Board-Name: $board_name" \ + --header="X-Openwrt-Version: $openwrt_version" \ + --header="X-Kernel-Version: $kernel" \ + --header="X-Target-Name: $target" \ + --header="X-Firmware-Version: $fw_release" \ + -O- "$@" +} + 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) 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=$(customwget --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"