diff --git a/feeds/qca-wifi-7/hostapd/files/hostapd.uc b/feeds/qca-wifi-7/hostapd/files/hostapd.uc index 47006a6fb..7c3cb56aa 100644 --- a/feeds/qca-wifi-7/hostapd/files/hostapd.uc +++ b/feeds/qca-wifi-7/hostapd/files/hostapd.uc @@ -1,7 +1,8 @@ let libubus = require("ubus"); -import { open, readfile } from "fs"; +import { open, readfile, writefile } from "fs"; import { wdev_remove, is_equal, vlist_new, phy_is_fullmac, phy_open, wdev_set_radio_mask } from "common"; +let uci = require('uci').cursor(); let ubus = libubus.connect(null, 60); hostapd.data.config = {}; @@ -1006,7 +1007,6 @@ let main_obj = { hostapd.data.ubus = ubus; hostapd.data.obj = ubus.publish("hostapd", main_obj); - let auth_obj = {}; hostapd.data.auth_obj = ubus.publish("hostapd-auth", auth_obj); @@ -1026,10 +1026,21 @@ return { hostapd.ubus.disconnect(); }, afc_request: function(iface, data) { - let ret = ubus.call("afc", "request", { data }); - if (type(ret) != "object") - return; - return ret.data; + let wireless_config = uci.get_all('wireless'); + for (let l, afc_server in wireless_config) { + if (afc_server['.type'] == 'afc-server' && afc_server.url && data) { + hostapd.printf(`Sending AFC request: ${data}`); + writefile("/tmp/afc-request.json", data); + + system(`curl -s -X POST ${afc_server.url} -H \'accept: \*\/\*\' -H \'Authorization: Bearer ${afc_server.access_token}\' -H \'Content-Type: application/json\' -d \'${data}\' --output /tmp/afc-response.json`); + + let afc_response = (readfile("/tmp/afc-response.json")); + if (afc_response) + return afc_response; + else + return; + } + } }, bss_create: function(phy, name, obj) { phy = hostapd.data.config[phy];