Skip to content

Commit

Permalink
build User Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
T0biii committed Apr 1, 2024
1 parent 7371b80 commit 7b67808
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Check warning on line 138 in ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 The mentioned syntax error was in this command expansion. Raw Output: ./ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink:138:19: info: The mentioned syntax error was in this command expansion. (ShellCheck.SC1009)

Check failure on line 138 in ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 Couldn't parse this function. Fix to allow more checks. Raw Output: ./ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink:138:21: error: Couldn't parse this function. Fix to allow more checks. (ShellCheck.SC1073)

Check failure on line 138 in ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 Expected a { to open the function definition. Raw Output: ./ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink:138:37: error: Expected a { to open the function definition. (ShellCheck.SC1064)

Check failure on line 138 in ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 Fix any mentioned problems and try again. Raw Output: ./ffmuc-mesh-vpn-wireguard-vxlan/files/lib/gluon/gluon-mesh-wireguard-vxlan/checkuplink:138:37: error: Fix any mentioned problems and try again. (ShellCheck.SC1072)
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7b67808

Please sign in to comment.