Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add User Agent to Wget call against the Broker #37

Closed
wants to merge 17 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,16 @@ is_loadbalancing_enabled() {
return 0
}


get_wgkex_data(){
local version="$1"
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 -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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 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")

-- Get Gluon Infos
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))