[luci] [LuCI] #77: [PATCH] make luci.ip.IPvX a bit more forgiving

LuciTrac trac at luci.subsignal.org
Sat Aug 1 22:31:25 CEST 2009


#77: [PATCH] make luci.ip.IPvX a bit more forgiving
-------------------------+--------------------------------------------------
 Reporter:  reporter     |       Owner:            
     Type:  enhancement  |      Status:  new       
 Priority:  minor        |   Milestone:  LuCI 0.9.0
Component:  LuCI Base    |    Keywords:            
-------------------------+--------------------------------------------------
 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.

-- 
Ticket URL: <http://luci.subsignal.org/trac/ticket/77>
LuCI <http://luci.subsignal.org/trac>
LuCI - Lua Configuration Interface


More information about the luci mailing list