This commit is contained in:
SirPdboy 2021-09-29 10:16:30 +08:00 committed by GitHub
parent 8fc6805ed4
commit fbfd8dd9cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,7 +120,8 @@ if nixio.fs.access("/usr/bin/dockerd") and not m.uci:get_bool("dockerd", "docker
for i, v in ipairs(interfaces) do
o:value(v, v)
end
o = s:taboption("ac", DynamicList, "ac_allowed_container", translate("Containers allowed to be accessed"), translate("Which container(s) under bridge network can be accessed, even from interfaces that are not allowed, fill-in Container Id or Name"))
o = s:taboption("ac", DynamicList, "ac_allowed_ports", translate("Ports allowed to be accessed"), translate("Which Port(s) can be accessed, it's not restricted by the Allowed Access interfaces configuration. Use this configuration with caution!"))
o.placeholder = "8080/tcp"
local docker = require "luci.model.docker"
local containers, res, lost_state
local dk = docker.new()
@ -137,8 +138,12 @@ if nixio.fs.access("/usr/bin/dockerd") and not m.uci:get_bool("dockerd", "docker
-- allowed_container.placeholder = "container name_or_id"
if containers then
for i, v in ipairs(containers) do
if v.State == "running" and v.NetworkSettings and v.NetworkSettings.Networks and v.NetworkSettings.Networks.bridge and v.NetworkSettings.Networks.bridge.IPAddress then
o:value(v.Id:sub(1,12), v.Names[1]:sub(2) .. " | " .. v.NetworkSettings.Networks.bridge.IPAddress)
if v.State == "running" and v.Ports then
for _, port in ipairs(v.Ports) do
if port.PublicPort and port.IP and not string.find(port.IP,":") then
o:value(port.PublicPort.."/"..port.Type, v.Names[1]:sub(2) .. " | " .. port.PublicPort .. " | " .. port.Type)
end
end
end
end
end