Merge pull request #1452 from mkresin/master
[project/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_status / index.htm
index 8c3e01e..18f66c2 100644 (file)
                local wan = ntm:get_wannet()
                local wan6 = ntm:get_wan6net()
 
-               local conn_count = tonumber((
-                       luci.sys.exec("wc -l /proc/net/nf_conntrack") or
-                       luci.sys.exec("wc -l /proc/net/ip_conntrack") or
-                       ""):match("%d+")) or 0
+               local conn_count = tonumber(
+                       fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0
 
                local conn_max = tonumber((
                        luci.sys.exec("sysctl net.nf_conntrack_max") or
 
                if wan6 then
                        rv.wan6 = {
-                               ip6addr = wan6:ip6addr(),
-                               gw6addr = wan6:gw6addr(),
-                               dns     = wan6:dns6addrs(),
-                               uptime  = wan6:uptime(),
-                               ifname  = wan6:ifname(),
-                               link    = wan6:adminlink()
+                               ip6addr   = wan6:ip6addr(),
+                               gw6addr   = wan6:gw6addr(),
+                               dns       = wan6:dns6addrs(),
+                               ip6prefix = wan6:ip6prefix(),
+                               uptime    = wan6:uptime(),
+                               proto     = wan6:proto(),
+                               ifname    = wan6:ifname(),
+                               link      = wan6:adminlink()
                        }
                end
 
                        if (ifc6 && ifc6.ifname && ifc6.proto != 'none')
                        {
                                var s = String.format(
-                                       '<strong><%:Address%>: </strong>%s<br />' +
+                                       '<strong><%:Type%>: </strong>%s%s<br />',
+                                               ifc6.proto, (ifc6.ip6prefix) ? '-pd' : ''
+                               );
+                               
+                               if (!ifc6.ip6prefix)
+                               {
+                                       s += String.format(
+                                               '<strong><%:Address%>: </strong>%s<br />',
+                                               (ifc6.ip6addr) ? ifc6.ip6addr : '::'
+                                       );
+                               }
+                               else
+                               {
+                                       s += String.format(
+                                               '<strong><%:Prefix Delegated%>: </strong>%s<br />',
+                                               ifc6.ip6prefix
+                                       );
+                                       if (ifc6.ip6addr)
+                                       {
+                                               s += String.format(
+                                                       '<strong><%:Address%>: </strong>%s<br />',
+                                                       ifc6.ip6addr
+                                               );
+                                       }
+                               }
+
+                               s += String.format(
                                        '<strong><%:Gateway%>: </strong>%s<br />',
-                                               (ifc6.ip6addr) ? ifc6.ip6addr : '::',
                                                (ifc6.gw6addr) ? ifc6.gw6addr : '::'
                                );
 
                                {
                                        var timestr;
 
-                                       if (info.leases[i].expires <= 0)
+                                       if (info.leases[i].expires === false)
+                                               timestr = '<em><%:unlimited%></em>';
+                                       else if (info.leases[i].expires <= 0)
                                                timestr = '<em><%:expired%></em>';
                                        else
                                                timestr = String.format('%t', info.leases[i].expires);
                                {
                                        var timestr;
 
-                                       if (info.leases6[i].expires <= 0)
+                                       if (info.leases6[i].expires === false)
+                                               timestr = '<em><%:unlimited%></em>';
+                                       else if (info.leases6[i].expires <= 0)
                                                timestr = '<em><%:expired%></em>';
                                        else
                                                timestr = String.format('%t', info.leases6[i].expires);
                                                tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
 
                                        var host = hosts[duid2mac(info.leases6[i].duid)];
-                                       if (host)
-                                               tr.insertCell(-1).innerHTML = String.format(
-                                                       '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis">%s</div>',
-                                                       ((host.name && (host.ipv4 || host.ipv6))
-                                                               ? '%h (%s)'.format(host.name, host.ipv4 || host.ipv6)
-                                                               : '%h'.format(host.name || host.ipv4 || host.ipv6)).nobr()
-                                               );
+                                       if (!info.leases6[i].hostname)
+                                               tr.insertCell(-1).innerHTML =
+                                                       (host && (host.name || host.ipv4 || host.ipv6))
+                                                               ? '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space: nowrap">? (%h)</div>'.format(host.name || host.ipv4 || host.ipv6)
+                                                               : '?';
                                        else
-                                               tr.insertCell(-1).innerHTML = info.leases6[i].hostname ? info.leases6[i].hostname : '?';
+                                               tr.insertCell(-1).innerHTML =
+                                                       (host && host.name && info.leases6[i].hostname != host.name)
+                                                               ? '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space: nowrap">%h (%h)</div>'.format(info.leases6[i].hostname, host.name)
+                                                               : info.leases6[i].hostname;
 
                                        tr.insertCell(-1).innerHTML = info.leases6[i].ip6addr;
                                        tr.insertCell(-1).innerHTML = info.leases6[i].duid;
                                                                '<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%><br />',
                                                                icon, net.signal, net.noise,
                                                                net.quality,
-                                                               net.link, net.ssid,
+                                                               net.link, net.ssid || '?',
                                                                net.mode,
                                                                net.channel, net.frequency,
                                                                net.bitrate || '?'
                                                        s += String.format(
                                                                '<strong><%:BSSID%>:</strong> %s<br />' +
                                                                '<strong><%:Encryption%>:</strong> %s',
-                                                                       net.bssid,
+                                                                       net.bssid || '?',
                                                                        net.encryption
                                                        );
                                                }