Author: richard
Date: Fri Apr 3 08:50:44 2009
New Revision: 5122
URL: http://svn.slimdevices.com/jive?rev=5122&view=rev
Log:
r5...@harrypotter (orig r5119): richard | 2009-04-03 16:30:52 +0100
Bug: N/A
Description:
Move Diagnostics applet to squeezeos builds.
r5...@harrypotter (orig r5120): richard | 2009-04-03 16:38:53 +0100
Bug: N/A
Description:
Port forward the diagnostics applet.
Added:
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt
Removed:
7.4/branches/pango/squeezeplay/src/squeezeplay_jive/share/applets/Diagnostics/
Modified:
7.4/branches/pango/ (props changed)
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
Propchange: 7.4/branches/pango/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Fri Apr 3 08:50:44 2009
@@ -4,7 +4,7 @@
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.2/trunk:2921
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.3/private-branches/jive-refresh:3653
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.3/trunk:5110
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.4/trunk:5112
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.4/trunk:5120
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:2013
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378
Added:
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua
URL:
http://svn.slimdevices.com/jive/7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua?rev=5122&view=auto
==============================================================================
---
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua
(added)
+++
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua
Fri Apr 3 08:50:44 2009
@@ -1,0 +1,320 @@
+
+local ipairs, tostring = ipairs, tostring
+
+-- stuff we use
+local io = require("io")
+local oo = require("loop.simple")
+local lfs = require("lfs")
+local math = require("math")
+local string = require("string")
+local table = require("table")
+
+local Applet = require("jive.Applet")
+local DNS = require("jive.net.DNS")
+local Networking = require("jive.net.Networking")
+local Process = require("jive.net.Process")
+local SocketTcp = require("jive.net.SocketTcp")
+local SlimServer = require("jive.slim.SlimServer")
+local Framework = require("jive.ui.Framework")
+local Label = require("jive.ui.Label")
+local SimpleMenu = require("jive.ui.SimpleMenu")
+local Surface = require("jive.ui.Surface")
+local Task = require("jive.ui.Task")
+local Textarea = require("jive.ui.Textarea")
+local Window = require("jive.ui.Window")
+
+local debug = require("jive.utils.debug")
+local log = require("jive.utils.log").logger("applets.misc")
+
+
+local jnt = jnt
+local JIVE_VERSION = jive.JIVE_VERSION
+
+
+module(..., Framework.constants)
+oo.class(_M, Applet)
+
+
+local tests = {
+ "FIRMWARE_VERSION",
+ "MAC_ADDRESS",
+ "WLAN_SSID",
+ "WLAN_ENCRYPTION",
+ "WLAN_STRENGTH",
+ "IP_ADDRESS",
+ "SUBNET_MASK",
+ "GATEWAY",
+ "DNS_SERVER",
+ "SN_ADDRESS",
+ "SN_PING",
+ "SN_PORT_3483",
+ "SN_PORT_9000",
+ "SC_ADDRESS",
+ "SC_PING",
+ "SC_PORT_3483",
+ "SC_PORT_9000",
+ "UPTIME",
+ "MEMORY",
+}
+
+
+function setValue(self, key, value)
+ if value then
+ self.labels[key]:setValue(self:string(value))
+ else
+ self.labels[key]:setValue("")
+ end
+end
+
+
+function serverPort(self, server, port, key)
+ if not server then
+ self:setValue(key, "NOT_CONNECTED")
+ return
+ end
+
+ Task("ports", self, function()
+ local serverip = server:getIpPort()
+
+ local ip, err
+ if DNS:isip(serverip) then
+ ip = serverip
+ else
+ ip, err = DNS:toip(serverip)
+ end
+
+ if ip == nil then
+ self:setValue(key, "PORT_FAIL")
+ test.running = false
+ return
+ end
+
+ local tcp = SocketTcp(jnt, ip, port, "porttest")
+
+ tcp:t_connect()
+ tcp:t_addWrite(function(err)
+ local res, err = tcp.t_sock:send(" ")
+
+ if err then
+ self:setValue(key, "PORT_FAIL")
+ else
+ self:setValue(key, "PORT_OK")
+ end
+
+ tcp:close()
+ end)
+ end):addTask()
+end
+
+
+function serverPing(self, server, dnsKey, pingKey)
+ local serverip = server and server:getIpPort()
+
+ if not serverip then
+ self:setValue(dnsKey, "NOT_CONNECTED")
+ self:setValue(pingKey, "NOT_CONNECTED")
+ return
+ end
+
+ Task("ping", self, function()
+ local ipaddr
+
+ -- DNS lookup
+ if DNS:isip(serverip) then
+ ipaddr = serverip
+ else
+ ipaddr = DNS:toip(serverip)
+ end
+
+ if not ipaddr then
+ self:setValue(dnsKey, "DNS_FAIL")
+ self:setValue(pingKey, "PING_FAIL")
+ return
+ end
+
+ self:setValue(dnsKey, ipaddr)
+
+ -- Ping
+ local pingOK = false
+ local ping = Process(jnt, "ping -c 1 " .. ipaddr)
+ ping:read(function(chunk)
+ if chunk then
+ if string.match(chunk, "bytes from") then
+ pingOK = true
+ end
+ else
+ if pingOK then
+ self:setValue(pingKey, "PING_OK")
+ else
+ self:setValue(pingKey, "PING_FAIL")
+ end
+ end
+ end)
+ end):addTask()
+end
+
+
+function wlanStatus(self, iface)
+ Task("Netstatus", self, function()
+ local status = iface:t_wpaStatus()
+ local snr = iface:getSNR()
+
+ if status.ssid then
+ local encryption = status.key_mgmt
+ -- white lie :)
+ if string.match(status.pairwise_cipher, "WEP") then
+ encryption = "WEP"
+ end
+
+ self:setValue("WLAN_SSID", status.ssid)
+ self:setValue("WLAN_ENCRYPTION", encryption)
+ self:setValue("WLAN_STRENGTH", self:string("WLAN_SNR",
snr))
+
+ if status.ip_address then
+ self:setValue("IP_ADDRESS",
tostring(status.ip_address))
+ self:setValue("SUBNET_MASK",
tostring(status.ip_subnet))
+ self:setValue("GATEWAY",
tostring(status.ip_gateway))
+ self:setValue("DNS_SERVER",
tostring(status.ip_dns))
+ end
+ else
+ self:setValue("WLAN_SSID", "NOT_CONNECTED")
+ self:setValue("WLAN_ENCRYPTION", nil)
+ self:setValue("WLAN_STRENGTH", nil)
+ end
+ end):addTask()
+end
+
+
+function systemStatus(self)
+ local uptime = ""
+ local memory = ""
+
+ local f = io.open("/proc/uptime")
+ if f then
+ local time = f:read("*all")
+ f:close()
+
+ time = string.match(time, "(%d+)")
+
+ uptime = {}
+ uptime.days = math.floor(time / 216000)
+ time = math.fmod(time, 216000)
+ uptime.hours = math.floor(time / 3600)
+ time = math.fmod(time, 3600)
+ uptime.minutes = math.floor(time / 60)
+
+ local ut = {}
+ if uptime.days > 0 then
+ ut[#ut + 1] = tostring(self:string("UPTIME_DAYS",
uptime.days))
+ end
+ if uptime.hours > 0 then
+ ut[#ut + 1] = tostring(self:string("UPTIME_HOURS",
uptime.hours))
+ end
+ ut[#ut + 1] = tostring(self:string("UPTIME_MINUTES",
uptime.minutes))
+ uptime = table.concat(ut, " ")
+ end
+
+ local f = io.open("/proc/meminfo")
+ if f then
+ local mem = {}
+
+ while true do
+ local line = f:read()
+ if line == nil then
+ break
+ end
+
+ local key, value = string.match(line, "(.+):%s+(%d+)")
+ mem[key] = value
+ end
+ f:close()
+
+ memory = math.ceil(((mem.MemTotal - (mem.MemFree + mem.Buffers
+ mem.Cached)) / mem.MemTotal) * 100) .. "%"
+ end
+
+ self:setValue("UPTIME", uptime)
+ self:setValue("MEMORY", memory)
+end
+
+
+function dovalues(self, menu)
+ local uuid, mac = jnt:getUUID()
+
+ -- fixed values
+ self:setValue("FIRMWARE_VERSION", JIVE_VERSION)
+ self:setValue("MAC_ADDRESS", mac)
+
+ -- networks
+ local iface = Networking:wirelessInterface()
+ local wlan = Networking(jnt, iface)
+
+ self:wlanStatus(wlan)
+
+
+ -- servers
+ local sn = false
+ for name, server in SlimServer:iterate() do
+ if server:isSqueezeNetwork() then
+ sn = server
+ end
+ end
+
+ local sc = SlimServer:getCurrentServer()
+
+
+ self:serverPing(sn, "SN_ADDRESS", "SN_PING")
+ self:serverPing(sc, "SC_ADDRESS", "SC_PING")
+
+ self:serverPort(sn, 3483, "SN_PORT_3483")
+ self:serverPort(sn, 9000, "SN_PORT_9000")
+ self:serverPort(sc, 3483, "SC_PORT_3483")
+ self:serverPort(sc, 9000, "SC_PORT_9000")
+
+ self:systemStatus()
+end
+
+
+function diagnosticsMenu(self)
+ local window = Window("window", self:string("DIAGNOSTICS"))
+ window:setAllowScreensaver(false)
+
+ local menu = SimpleMenu("menu")
+
+ self.labels = {}
+
+ for i,name in ipairs(tests) do
+ self.labels[name] = Label("value", "")
+
+ menu:addItem({
+ text = self:string(name),
+ })
+ menu:addItem({
+ text = "",
+ icon = self.labels[name],
+ })
+ end
+
+ dovalues(self, menu)
+ menu:addTimer(5000, function()
+ dovalues(self, menu)
+ end)
+
+
+ window:addWidget(menu)
+
+ self:tieAndShowWindow(window)
+ return window
+end
+
+
+--[[
+
+=head1 LICENSE
+
+Copyright 2007 Logitech. All Rights Reserved.
+
+This file is subject to the Logitech Public Source License Version 1.0. Please
see the LICENCE file for details.
+
+=cut
+--]]
+
Added:
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua
URL:
http://svn.slimdevices.com/jive/7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua?rev=5122&view=auto
==============================================================================
---
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua
(added)
+++
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua
Fri Apr 3 08:50:44 2009
@@ -1,0 +1,34 @@
+
+local oo = require("loop.simple")
+
+local AppletMeta = require("jive.AppletMeta")
+
+local appletManager = appletManager
+local jiveMain = jiveMain
+
+
+module(...)
+oo.class(_M, AppletMeta)
+
+
+function jiveVersion(meta)
+ return 1, 1
+end
+
+
+function registerApplet(meta)
+ jiveMain:addItem(meta:menuItem('diagnostics', 'advancedSettings',
"DIAGNOSTICS", function(applet, ...) applet:diagnosticsMenu() end))
+end
+
+
+--[[
+
+=head1 LICENSE
+
+Copyright 2007 Logitech. All Rights Reserved.
+
+This file is subject to the Logitech Public Source License Version 1.0. Please
see the LICENCE file for details.
+
+=cut
+--]]
+
Added:
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt
URL:
http://svn.slimdevices.com/jive/7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt?rev=5122&view=auto
==============================================================================
---
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt
(added)
+++
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt
Fri Apr 3 08:50:44 2009
@@ -1,0 +1,351 @@
+
+DIAGNOSTICS
+ DA Systemdiagnosticering
+ DE Systemdiagnose
+ EN Diagnostics
+ ES Diagnóstico del sistema
+ FI Järjestelmädiagnostiikka
+ FR Diagnostic système
+ IT Diagnostica del sistema
+ NL Diagnostische gegevens van het systeem
+ NO Systemdiagnose
+ SV Systemdiagnostik
+
+NOT_CONNECTED
+ DA Ikke tilsluttet
+ DE Nicht verbunden
+ EN Not connected
+ ES No conectado
+ FI Ei yhdistetty
+ FR Non connecté
+ IT Non connesso
+ NL Niet verbonden
+ NO Ikke koplet til
+ SV Ej ansluten
+
+PORT_FAIL
+ DA Der kan ikke etableres forbindelse
+ DE Verbindung kann nicht hergestellt werden
+ EN Can't connect
+ ES No se puede conectar
+ FI Ei voi yhdistää
+ FR Connexion impossible
+ IT Impossibile connettersi
+ NL Kan geen verbinding maken
+ NO Kan ikke kople til
+ SV Det gick inte att ansluta
+
+PORT_OK
+ DA OK
+ DE OK
+ EN OK
+ ES Correcto
+ FI OK
+ FR OK
+ IT OK
+ NL OK
+ NO OK
+ SV OK
+
+DNS_FAIL
+ DA DNS mislykkedes
+ DE DNS-Fehler
+ EN DNS failed
+ ES Fallo en DNS
+ FI DNS epäonnistui
+ FR Echec du DNS
+ IT Errore DNS
+ NL DNS mislukt
+ NO DNS mislyktes
+ SV DNS misslyckades
+
+PING_OK
+ DA OK
+ DE OK
+ EN OK
+ ES Correcto
+ FI OK
+ FR OK
+ IT OK
+ NL OK
+ NO OK
+ SV OK
+
+PING_FAIL
+ DA Ping-kommando mislykkedes
+ DE Ping-Fehler
+ EN Can't ping
+ ES No se puede hacer ping
+ FI Ei voi suorittaa ping-toimintoa
+ FR Impossible d'exécuter la commande PING
+ IT Impossibile eseguire il ping
+ NL Kan de opdracht Ping niet uitvoeren
+ NO Kan ikke sende ping
+ SV Det gick inte att skicka ping
+
+WLAN_SNR
+ DA %s signal/støjforhold:
+ DE %s-SNR
+ EN %s SNR
+ ES %s SNR
+ FI %s SNR
+ FR SNR %s
+ IT %s SNR
+ NL %s SNR
+ NO %s signal-til-støy-forhold
+ SV Brusvärde %s
+
+FIRMWARE_VERSION
+ DA Version:
+ DE Version:
+ EN Version:
+ ES Versión:
+ FI Versio:
+ FR Version:
+ IT Versione:
+ NL Versie:
+ NO Versjon:
+ SV Version:
+
+MAC_ADDRESS
+ DA MAC-adresse:
+ DE MAC-Adresse:
+ EN MAC Address:
+ ES Dirección MAC:
+ FI MAC-osoite:
+ FR Adresse MAC:
+ IT Indirizzo MAC:
+ NL MAC-adres:
+ NO MAC-adresse:
+ SV MAC-adress:
+
+WLAN_SSID
+ DA Trådløst netværk:
+ DE Kabelloses Netzwerk:
+ EN Wireless network:
+ ES Red inalámbrica:
+ FI Langaton verkko:
+ FR Réseau sans fil:
+ IT Rete senza fili:
+ NL Draadloos netwerk:
+ NO Trådløst nettverk:
+ SV Trådlöst nätverk:
+
+WLAN_ENCRYPTION
+ DA Kryptering for trådløst netværk:
+ DE Kabellos-Verschlüsselung:
+ EN Wireless encryption:
+ ES Cifrado inalámbrico:
+ FI Langaton salaus:
+ FR Chiffrement sans fil:
+ IT Crittografia senza fili:
+ NL Draadloze codering:
+ NO Trådløs kryptering:
+ SV Trådlös kryptering:
+
+WLAN_STRENGTH
+ DA Trådløst signal:
+ DE Kabellos-Signal:
+ EN Wireless signal:
+ ES Señal inalámbrica:
+ FI Langaton signaali:
+ FR Signal sans fil:
+ IT Segnale senza fili:
+ NL Draadloos signaal:
+ NO Trådløst signal:
+ SV Trådlös signal:
+
+IP_ADDRESS
+ DA IP-adresse:
+ DE IP-Adresse:
+ EN IP Address:
+ ES Dirección IP:
+ FI IP-osoite:
+ FR Adresse IP:
+ IT Indirizzo IP:
+ NL IP-adres:
+ NO Ip-adresse:
+ SV IP-adress:
+
+SUBNET_MASK
+ DA IP-undernet:
+ DE IP-Subnetzmaske:
+ EN IP Subnet:
+ ES Subred IP:
+ FI IP-aliverkko:
+ FR Sous-réseau IP:
+ IT Subnet IP:
+ NL IP-subnet:
+ NO Ip-delnett:
+ SV IP-delnät:
+
+GATEWAY
+ DA Gatewayens IP-adresse:
+ DE IP-Gateway:
+ EN IP Gateway:
+ ES Puerta de enlace IP:
+ FI IP-yhdyskäytävä:
+ FR Passerelle IP:
+ IT Gateway IP:
+ NL Gateway van IP:
+ NO Ip for gateway:
+ SV Gateway-adress:
+
+DNS_SERVER
+ DA DNS-server:
+ DE DNS-Server:
+ EN DNS Server:
+ ES Servidor DNS:
+ FI DNS-palvelin:
+ FR Serveur DNS:
+ IT Server DNS:
+ NL DNS-server:
+ NO DNS-server:
+ SV DNS-server:
+
+SN_ADDRESS
+ DA SqueezeNetwork:
+ DE SqueezeNetwork:
+ EN SqueezeNetwork:
+ ES SqueezeNetwork:
+ FI SqueezeNetwork:
+ FR SqueezeNetwork:
+ IT SqueezeNetwork:
+ NL SqueezeNetwork:
+ NO SqueezeNetwork:
+ SV SqueezeNetwork:
+
+SN_PING
+ DA Ping:
+ DE Ping:
+ EN Ping:
+ ES Ping:
+ FI Ping:
+ FR Ping:
+ IT Ping:
+ NL Ping:
+ NO Ping:
+ SV Ping:
+
+SN_PORT_3483
+ DA TCP port 3483:
+ DE TCP-Anschluss 3483:
+ EN TCP port 3483:
+ ES Puerto TCP 3483:
+ FI TCP-portti 3483:
+ FR Port TCP 3483:
+ IT Porta TCP 3483:
+ NL TCP-poort 3483:
+ NO TCP-port 3483:
+ SV TCP-port 3483:
+
+SN_PORT_9000
+ DA TCP port 9000:
+ DE TCP-Anschluss 9000:
+ EN TCP port 9000:
+ ES Puerto TCP 9000:
+ FI TCP-portti 9000:
+ FR Port TCP 9000:
+ IT Porta TCP 9000:
+ NL TCP-poort 9000:
+ NO TCP-port 9000:
+ SV TCP-port 9000:
+
+SC_ADDRESS
+ DA SqueezeCenter:
+ DE SqueezeCenter:
+ EN SqueezeCenter:
+ ES SqueezeCenter:
+ FI SqueezeCenter:
+ FR SqueezeCenter:
+ IT SqueezeCenter:
+ NL SqueezeCenter:
+ NO SqueezeCenter:
+ SV SqueezeCenter:
+
+SC_PING
+ DA Ping:
+ DE Ping:
+ EN Ping:
+ ES Ping:
+ FI Ping:
+ FR Ping:
+ IT Ping:
+ NL Ping:
+ NO Ping:
+ SV Ping:
+
+SC_PORT_3483
+ DA TCP port 3483:
+ DE TCP-Anschluss 3483:
+ EN TCP port 3483:
+ ES Puerto TCP 3483:
+ FI TCP-portti 3483:
+ FR Port TCP 3483:
+ IT Porta TCP 3483:
+ NL TCP-poort 3483:
+ NO TCP-port 3483:
+ SV TCP-port 3483:
+
+SC_PORT_9000
+ DA TCP port 9000:
+ DE TCP-Anschluss 9000:
+ EN TCP port 9000:
+ ES Puerto TCP 9000:
+ FI TCP-portti 9000:
+ FR Port TCP 9000:
+ IT Porta TCP 9000:
+ NL TCP-poort 9000:
+ NO TCP-port 9000:
+ SV TCP-port 9000:
+
+UPTIME
+ DA Oppetid:
+ DE Zeit aktiv:
+ EN Uptime:
+ ES Tiempo de actividad:
+ FI Toiminta-aika:
+ FR Temps d'utilisation :
+ IT Tempo di attività :
+ NL Actieve tijdsduur:
+ NO Oppetid:
+ SV Aktiv tid:
+
+UPTIME_DAYS
+ DA %s dage
+ DE %s Tage
+ EN %s days
+ ES %s dÃas
+ FI %s päivää
+ FR %s jours
+ IT %s giorni
+ NL %s dagen
+ NO %s dager
+ SV %s dagar
+
+UPTIME_HOURS
+ DA %s timer
+ DE %s Stunden
+ EN %s hours
+ ES %s horas
+ FI %s tuntia
+ FR %s heures
+ IT %s ore
+ NL %s uren
+ NO %s timer
+ SV %s timmar
+
+UPTIME_MINUTES
+ DA %s minutter
+ DE %s Minuten
+ EN %s minutes
+ ES %s minutos
+ FI %s minuuttia
+ FR %s minutes
+ IT %s minuti
+ NL %s minuten
+ NO %s minutter
+ SV %s minuter
+
+MEMORY
+ EN Memory used
Modified:
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
URL:
http://svn.slimdevices.com/jive/7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua?rev=5122&r1=5121&r2=5122&view=diff
==============================================================================
---
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
(original)
+++
7.4/branches/pango/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
Fri Apr 3 08:50:44 2009
@@ -496,6 +496,59 @@
local status = {}
for k,v in string.gmatch(statusStr, "([^=]+)=([^\n]+)\n") do
status[k] = v
+ end
+
+ -- exit early if we are not connected
+ if status.wpa_state ~= "COMPLETED" then
+ return status
+ end
+
+ local f, err = io.popen("/sbin/ifconfig " .. self.interface)
+ if f == nil then
+ log:error("Can't read ifconfig: ", err)
+ else
+ local ifconfig = f:read("*all")
+ f:close()
+
+ local ipaddr = string.match(ifconfig, "inet addr:([%d\.]+)")
+ local subnet = string.match(ifconfig, "Mask:([%d\.]+)")
+
+ status.ip_address = ipaddr
+ status.ip_subnet = subnet
+ end
+
+ -- exit early if we do not have an ip address
+ if not status.ip_address then
+ return status
+ end
+
+ local f, err = io.popen("/bin/ip route")
+ if f == nil then
+ log:error("Can't read default route: ", err)
+ else
+ local iproute = f:read("*all")
+ f:close()
+
+ local gateway = string.match(iproute, "default via ([%d\.]+)")
+
+ status.ip_gateway = gateway
+ end
+
+ local f = io.open("/etc/resolv.conf")
+ if f ~= nil then
+ while true do
+ local line = f:read("*l")
+ if line == nil then
+ break
+ end
+
+ local dns = string.match(line, "nameserver ([%d\.]+)")
+ if dns then
+ status.ip_dns = dns
+ break
+ end
+ end
+ f:close()
end
return status
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive-checkins