Changeset 6952
- Timestamp:
- 03/13/11 15:00:45 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/modules/admin-full/luasrc/controller/admin/network.lua
r6923 r6952 212 212 local info 213 213 local dev = net:ifname() 214 local data = { id = iface, uptime = net:uptime() } 214 local data = { 215 id = iface, 216 proto = net:proto(), 217 uptime = net:uptime(), 218 gwaddr = net:gwaddr(), 219 dnsaddrs = net:dnsaddrs() 220 } 215 221 for _, info in ipairs(nixio.getifaddrs()) do 216 222 local name = info.name:match("[^:]+") … … 281 287 282 288 luci.sys.call("env -i /sbin/ifup %q >/dev/null 2>/dev/null" % iface) 283 284 require "luci.fs"285 if luci.fs.access("/etc/config/radvd") then286 luci.sys.call("/etc/init.d/radvd restart >/dev/null 2>/dev/null")287 end288 289 289 luci.http.status(200, "Reconnected") 290 290 return … … 329 329 local netm = require "luci.model.network".init() 330 330 local path = luci.dispatcher.context.requestpath 331 local arp = luci.sys.net.arptable()332 331 local rv = { } 333 332 … … 364 363 365 364 function lease_status() 366 local rv = { } 367 local leasefile = "/var/dhcp.leases" 368 369 local uci = require "luci.model.uci".cursor() 370 local nfs = require "nixio.fs" 371 372 uci:foreach("dhcp", "dnsmasq", 373 function(s) 374 if s.leasefile and nfs.access(s.leasefile) then 375 leasefile = s.leasefile 376 return false 377 end 378 end) 379 380 local fd = io.open(leasefile, "r") 381 if fd then 382 while true do 383 local ln = fd:read("*l") 384 if not ln then 385 break 386 else 387 local ts, mac, ip, name = ln:match("^(%d+) (%S+) (%S+) (%S+)") 388 if ts and mac and ip and name then 389 rv[#rv+1] = { 390 expires = os.difftime(tonumber(ts) or 0, os.time()), 391 macaddr = mac, 392 ipaddr = ip, 393 hostname = (name ~= "*") and name 394 } 395 end 396 end 397 end 398 fd:close() 399 end 365 local s = require "luci.tools.status" 400 366 401 367 luci.http.prepare_content("application/json") 402 luci.http.write_json( rv)368 luci.http.write_json(s.dhcp_leases()) 403 369 end 404 370
