luci-0.9: merge r4848, r4849 and r4850
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 16 Jun 2009 14:44:01 +0000 (14:44 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 16 Jun 2009 14:44:01 +0000 (14:44 +0000)
libs/lucid-http/luasrc/lucid/http/handler/catchall.lua
modules/freifunk/root/etc/rc.local.d/01-config-migration [new file with mode: 0644]

index 3b2c2b0a0cab11fb8a57269ca8c8d0c1521a95fe..7a62ebb0d848801c351277de3c55befb3ced092c 100644 (file)
@@ -14,6 +14,8 @@ $Id$
 local srv = require "luci.lucid.http.server"
 local proto = require "luci.http.protocol"
 local util = require "luci.util"
+local ip = require "luci.ip"
+local ipairs = ipairs
 
 module "luci.lucid.http.handler.catchall"
 
@@ -28,6 +30,19 @@ function Redirect.handle_GET(self, request)
        local target = self.target
        local protocol = request.env.HTTPS and "https://" or "http://"
        local server = request.env.SERVER_ADDR
+
+       if request.env.REMOTE_ADDR and not request.env.REMOTE_ADDR:find(":") then
+               local compare = ip.IPv4(request.env.REMOTE_ADDR)
+               for _, iface in ipairs(request.server.interfaces) do
+                       if iface.family == "inet" and iface.addr and iface.netmask then
+                               if ip.IPv4(iface.addr, iface.netmask):contains(compare) then
+                                       server = iface.addr
+                                       break
+                               end
+                       end
+               end
+       end
+
        if server:find(":") then
                server = "[" .. server .. "]"
        end
@@ -51,4 +66,4 @@ Redirect.handle_POST = Redirect.handle_GET
 function Redirect.handle_HEAD(self, request)
        local stat, head = self:handle_GET(request)
        return stat, head
-end
\ No newline at end of file
+end
diff --git a/modules/freifunk/root/etc/rc.local.d/01-config-migration b/modules/freifunk/root/etc/rc.local.d/01-config-migration
new file mode 100644 (file)
index 0000000..1ab7239
--- /dev/null
@@ -0,0 +1,41 @@
+# Fixup various configurations to remove quirks
+# from former versions.
+
+_log() {
+       logger -t "Config Migration" "$1"
+}
+
+_uci() {
+       uci get "$1" 2>/dev/null
+}
+
+
+# Splash redirector had a wrong virtual url match
+# which resulted in "No such handler"
+
+[ "$(_uci lucid.splashredir.virtual)" == "/" ] && {
+       _log "Fix splash redirector configuration"
+       uci set lucid.splashredir.virtual=''
+       uci commit lucid
+       /etc/init.d/lucid restart
+}
+
+
+# Newer OLSR versions have the MinTCVtime hack active,
+# ensure proper timings or olsrd won't start
+
+FIX=0
+for i in 0 1 2 3 4; do
+       [ -z "$(_uci olsrd.@Interface[$i].TcInterval)" ] && \
+       [ -z "$(_uci olsrd.@Interface[$i].TcValidityTime)" ] || {
+               uci delete olsrd.@Interface[$i].TcInterval
+               uci delete olsrd.@Interface[$i].TcValidityTime
+               FIX=1
+       }
+done
+
+[ "$FIX" == 1 ] && {
+       _log "Fix olsrd configuration for MinTCVTime hack"
+       uci commit olsrd
+       /etc/init.d/olsrd restart
+}