Comments you submit will be routed for moderation. If you have an account, please log in first.

Ticket #77 (closed enhancement: fixed)

Opened 4 years ago

Last modified 4 years ago

[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

less-strict-ip.patch Download (0.6 KB) - added by reporter 4 years ago.

Change History

Changed 4 years ago by reporter

Changed 4 years ago by jow

  • status changed from new to closed
  • resolution set to fixed

see r5191 and r5192.

Add/Change #77 ([PATCH] make luci.ip.IPvX a bit more forgiving)

Author


E-mail address and user name can be saved in the Preferences.


Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.