diff --git a/luci-app-mptcp/luasrc/controller/mptcp.lua b/luci-app-mptcp/luasrc/controller/mptcp.lua index 3a5433bcc..986cb9725 100644 --- a/luci-app-mptcp/luasrc/controller/mptcp.lua +++ b/luci-app-mptcp/luasrc/controller/mptcp.lua @@ -95,28 +95,26 @@ function multipath_bandwidth() value=(string.gsub(value, "^%[%[", "")) value=(string.gsub(value, "%]%]", "")) local temp1 = string.split(value, "],") - res[key][1]=temp1[1] - for i=2,60 do - res[key][i]={} - if temp1[i] ~= "" and temp1[i] ~= nil then + if temp1[2] ~= nil then + res[key][1]=temp1[1] + for i=2,60 do + res[key][i]={} res[key][i]=(string.gsub(temp1[i], "%[", " ")) - else - res[key][i]="0,0,0,0,0" end - end - for i=1,60 do - res[key][i] = string.split(res[key][i], ",") - for j=1,5 do - if "string"== type(res[key][i][j]) then - res[key][i][j]= tonumber(res[key][i][j]) - end - if "string"==type(res["total"][i][j]) then - res["total"][i][j]= tonumber(res["total"][i][j]) - end - if j ==1 then - res["total"][i][j] = res[key][i][j] - else - res["total"][i][j] = res["total"][i][j] + res[key][i][j] + for i=1,60 do + res[key][i] = string.split(res[key][i], ",") + for j=1,5 do + if "string"== type(res[key][i][j]) then + res[key][i][j]= tonumber(res[key][i][j]) + end + if "string"==type(res["total"][i][j]) then + res["total"][i][j]= tonumber(res["total"][i][j]) + end + if j ==1 then + res["total"][i][j] = res[key][i][j] + else + res["total"][i][j] = res["total"][i][j] + res[key][i][j] + end end end end