Skip to content

Commit 29f5a60

Browse files
committed
Merge pull request ovh#32 from simlelievre/bugfix/lua
overthebox: check if there is no headers
2 parents 0422f20 + 2b43148 commit 29f5a60

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

Diff for: mwan3otb/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=mwan3otb
1111
PKG_VERSION:=1.7
12-
PKG_RELEASE:=21
12+
PKG_RELEASE:=22
1313
PKG_MAINTAINER:=Jeroen Louwes <[email protected]>
1414
PKG_LICENSE:=GPLv2
1515

Diff for: mwan3otb/files/usr/sbin/track.lua

+1
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ bw_stats.command= "/usr/bin/luci-bwc"
595595
function bw_stats:collect()
596596
-- run bandwidth monitor
597597
local handle = io.popen(string.format("%s -i %s", bw_stats.command, opts["i"]))
598+
if not handle then return 0 end
598599
local result = handle:read("*a")
599600
handle:close()
600601
-- store rsult in table

Diff for: overthebox/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=overthebox
1111
PKG_VERSION:=0.3
12-
PKG_RELEASE:=7
12+
PKG_RELEASE:=8
1313

1414
PKG_BUILD_DIR:=$(BUILD_DIR)/overthebox-$(PKG_VERSION)
1515

Diff for: overthebox/files/usr/lib/lua/overthebox.lua

+5-9
Original file line numberDiff line numberDiff line change
@@ -845,15 +845,11 @@ function API(uri, method, data)
845845
print()
846846
end
847847

848-
for k, v in pairs(headers) do
849-
if k == "x-otb-client-ip" then
850-
if v:match("(%d+)%.(%d+)%.(%d+)%.(%d+)") then
851-
fd = io.open("/tmp/wanip", "w")
852-
if fd then
853-
fd:write(v)
854-
fd:close()
855-
end
856-
end
848+
if ( headers and type(headers) == "table" and headers["x-otb-client-ip"] and headers["x-otb-client-ip"]:match("(%d+)%.(%d+)%.(%d+)%.(%d+)") ) then
849+
fd = io.open("/tmp/wanip", "w")
850+
if fd then
851+
fd:write(headers["x-otb-client-ip"])
852+
fd:close()
857853
end
858854
end
859855

0 commit comments

Comments
 (0)