Show
Ignore:
Timestamp:
05/10/11 00:04:26 (2 years ago)
Author:
jow
Message:

luci-0.10: merge trunk

Location:
luci/branches/luci-0.10/libs/sys
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • luci/branches/luci-0.10/libs/sys

    • Property svn:mergeinfo deleted
  • luci/branches/luci-0.10/libs/sys/luasrc/sys.lua

    r6790 r7038  
    172172    local meminfo = fs.readfile("/proc/meminfo") 
    173173 
    174     local system = cpuinfo:match("system typ.-:%s*([^\n]+)") 
    175     local model = "" 
    176174    local memtotal = tonumber(meminfo:match("MemTotal:%s*(%d+)")) 
    177175    local memcached = tonumber(meminfo:match("\nCached:%s*(%d+)")) 
    178176    local memfree = tonumber(meminfo:match("MemFree:%s*(%d+)")) 
    179177    local membuffers = tonumber(meminfo:match("Buffers:%s*(%d+)")) 
    180     local bogomips = tonumber(cpuinfo:match("BogoMIPS.-:%s*([^\n]+)")) 
    181  
    182     if not system then 
    183         system = nixio.uname().machine 
    184         model = cpuinfo:match("model name.-:%s*([^\n]+)") 
    185         if not model then 
    186             model = cpuinfo:match("Processor.-:%s*([^\n]+)") 
    187         end 
    188     else 
    189         model = cpuinfo:match("cpu model.-:%s*([^\n]+)") 
    190     end 
     178    local bogomips = tonumber(cpuinfo:match("[Bb]ogo[Mm][Ii][Pp][Ss].-: ([^\n]+)")) or 0 
     179 
     180    local system = 
     181        cpuinfo:match("system type\t+: ([^\n]+)") or 
     182        cpuinfo:match("Processor\t+: ([^\n]+)") or 
     183        cpuinfo:match("model name\t+: ([^\n]+)") 
     184 
     185    local model = 
     186        cpuinfo:match("machine\t+: ([^\n]+)") or 
     187        cpuinfo:match("Hardware\t+: ([^\n]+)") or 
     188        luci.util.pcdata(fs.readfile("/proc/diag/model")) or 
     189        nixio.uname().machine or 
     190        system 
    191191 
    192192    return system, model, memtotal, memcached, membuffers, memfree, bogomips 
     
    241241            line = line:match "^(.-( [^ =]+=).-)%2" 
    242242            local entry, flags = _parse_mixed_record(line, " +") 
    243             entry.layer3 = flags[1] 
    244             entry.layer4 = flags[3] 
    245             for i=1, #entry do 
    246                 entry[i] = nil 
    247             end 
    248  
    249             if callback then 
    250                 callback(entry) 
    251             else 
    252                 connt[#connt+1] = entry 
     243            if flags[6] ~= "TIME_WAIT" then 
     244                entry.layer3 = flags[1] 
     245                entry.layer4 = flags[3] 
     246                for i=1, #entry do 
     247                    entry[i] = nil 
     248                end 
     249 
     250                if callback then 
     251                    callback(entry) 
     252                else 
     253                    connt[#connt+1] = entry 
     254                end 
    253255            end 
    254256        end 
     
    257259            line = line:match "^(.-( [^ =]+=).-)%2" 
    258260            local entry, flags = _parse_mixed_record(line, " +") 
    259             entry.layer3 = "ipv4" 
    260             entry.layer4 = flags[1] 
    261             for i=1, #entry do 
    262                 entry[i] = nil 
    263             end 
    264  
    265             if callback then 
    266                 callback(entry) 
    267             else 
    268                 connt[#connt+1] = entry 
     261            if flags[4] ~= "TIME_WAIT" then 
     262                entry.layer3 = "ipv4" 
     263                entry.layer4 = flags[1] 
     264                for i=1, #entry do 
     265                    entry[i] = nil 
     266                end 
     267 
     268                if callback then 
     269                    callback(entry) 
     270                else 
     271                    connt[#connt+1] = entry 
     272                end 
    269273            end 
    270274        end 
     
    303307 
    304308    net.routes6(function(rt) 
    305         if rt.dest:prefix() == 0 and (not route or route.metric > rt.metric) then 
     309        if rt.dest:prefix() == 0 and rt.device ~= "lo" and  
     310           (not route or route.metric > rt.metric) 
     311        then 
    306312            route = rt 
    307313        end 
    308314    end) 
     315 
     316    if not route then 
     317        local global_unicast = luci.ip.IPv6("2000::/3") 
     318        net.routes6(function(rt) 
     319            if rt.dest:equal(global_unicast) and 
     320               (not route or route.metric > rt.metric) 
     321            then 
     322                route = rt 
     323            end 
     324        end) 
     325    end 
    309326 
    310327    return route