added new endpoint /active_iface for determining which wan interface is currently primary
This commit is contained in:
@@ -49,6 +49,7 @@ local success, load_result = pcall(function()
|
||||
local router = Router:new()
|
||||
|
||||
router:add_route("GET", "/network_config", network_handlers.get_network_config)
|
||||
router:add_route("GET", "/active_iface", network_handlers.get_active_iface)
|
||||
router:add_route("POST", "/connect_wifi", network_handlers.set_connect_wifi)
|
||||
router:add_route("GET", "/SOS", network_handlers.set_connect_wifi_sos)
|
||||
router:add_route("GET", "/wifi_scan", wifi_handlers.get_wifi_scan)
|
||||
|
||||
@@ -4,6 +4,16 @@ local utils = require("skyweave.utils") -- Updated path
|
||||
|
||||
local network_handler = {}
|
||||
|
||||
function network_handler.get_active_iface(request_context)
|
||||
local live_gateway_ip, live_gateway_iface = utils.get_active_default_gateway()
|
||||
local response_data = {
|
||||
active_gateway_ip = live_gateway_ip,
|
||||
active_interface = live_gateway_iface,
|
||||
errCode = 0,
|
||||
errMsg = "OK"
|
||||
}
|
||||
end
|
||||
|
||||
-- Original: function handlers.get_network_config(params)
|
||||
function network_handler.get_network_config(request_context)
|
||||
local wan_iface_name = request_context.query.interface or "wan" -- Default to "wan"
|
||||
|
||||
Reference in New Issue
Block a user