Merge pull request #655 from hnyman/nat6

Add support for showing ipv6 NAT table in Luci
This commit is contained in:
Jo-Philipp Wich 2016-03-17 15:32:26 +01:00
commit 516689a646
2 changed files with 21 additions and 0 deletions

View file

@ -19,6 +19,8 @@ luci.util = require "luci.util"
luci.sys = require "luci.sys" luci.sys = require "luci.sys"
luci.ip = require "luci.ip" luci.ip = require "luci.ip"
local pcall = pcall
local io = require "io"
local tonumber, ipairs, table = tonumber, ipairs, table local tonumber, ipairs, table = tonumber, ipairs, table
module("luci.sys.iptparser") module("luci.sys.iptparser")
@ -37,6 +39,15 @@ function IptParser.__init__( self, family )
else else
self._nulladdr = "::/0" self._nulladdr = "::/0"
self._tables = { "filter", "mangle", "raw" } self._tables = { "filter", "mangle", "raw" }
local ok, lines = pcall(io.lines, "/proc/net/ip6_tables_names")
if ok and lines then
local line
for line in lines do
if line == "nat" then
self._tables = { "filter", "nat", "mangle", "raw" }
end
end
end
self._command = "ip6tables -t %s --line-numbers -nxvL" self._command = "ip6tables -t %s --line-numbers -nxvL"
end end

View file

@ -9,6 +9,7 @@
require "luci.sys.iptparser" require "luci.sys.iptparser"
local wba = require "luci.tools.webadmin" local wba = require "luci.tools.webadmin"
local fs = require "nixio.fs" local fs = require "nixio.fs"
local io = require "io"
local has_ip6tables = fs.access("/usr/sbin/ip6tables") local has_ip6tables = fs.access("/usr/sbin/ip6tables")
local mode = 4 local mode = 4
@ -47,6 +48,15 @@
local tables = { "Filter", "NAT", "Mangle", "Raw" } local tables = { "Filter", "NAT", "Mangle", "Raw" }
if mode == 6 then if mode == 6 then
tables = { "Filter", "Mangle", "Raw" } tables = { "Filter", "Mangle", "Raw" }
local ok, lines = pcall(io.lines, "/proc/net/ip6_tables_names")
if ok and lines then
local line
for line in lines do
if line == "nat" then
tables = { "Filter", "NAT", "Mangle", "Raw" }
end
end
end
end end
-%> -%>