Ticket #77 (closed enhancement: fixed)
[PATCH] make luci.ip.IPvX a bit more forgiving
| Reported by: | reporter | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | LuCI 0.9.0 |
| Component: | LuCI Base | Keywords: | |
| Cc: | mss@… |
Description
Here's a small patch which allows for the following:
ip4 = luci.ip.IPv4("1.2.3.4")
ip4 = luci.ip.IPv4("::ffff:1.2.3.4")
ip4 = luci.ip.IPv4("[::ffff:1.2.3.4]")
ip4 = luci.ip.IPv4("[1.2.3.4]")
ip6 = luci.ip.IPv6("1::2")
ip6 = luci.ip.IPv6("[1::2]")
I use this for something like this:
local ip = luci.ip.IPv4(luci.http.getenv("REMOTE_ADDR")):string()
local mac
for _, arp in ipairs(luci.sys.net.arptable()) do
if arp["IP address"] == ip then
mac = arp["HW address"]
break
end
end
Ie. as a simple way to sanitize IPv4 addresses handed in from external apps which might put the ::ffff: prefix in front (and square brackets around) on IPv6 capable systems.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

