luci-0.10: merge r7113, r7114, r7115, r7116 and r7117
authorJo-Philipp Wich <jow@openwrt.org>
Fri, 10 Jun 2011 23:17:39 +0000 (23:17 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Fri, 10 Jun 2011 23:17:39 +0000 (23:17 +0000)
applications/luci-ahcp/Makefile [new file with mode: 0644]
applications/luci-ahcp/luasrc/controller/ahcp.lua [new file with mode: 0644]
applications/luci-ahcp/luasrc/model/cbi/ahcp.lua [new file with mode: 0644]
applications/luci-ahcp/luasrc/view/admin_status/index/ahcp.htm [new file with mode: 0644]
applications/luci-ahcp/luasrc/view/ahcp_status.htm [new file with mode: 0644]
applications/luci-ahcp/root/etc/uci-defaults/luci-ahcp [new file with mode: 0755]
applications/luci-openvpn/luasrc/model/cbi/openvpn-advanced.lua
applications/luci-openvpn/luasrc/model/cbi/openvpn-basic.lua
contrib/package/luci/Makefile
modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua

diff --git a/applications/luci-ahcp/Makefile b/applications/luci-ahcp/Makefile
new file mode 100644 (file)
index 0000000..a70e950
--- /dev/null
@@ -0,0 +1,4 @@
+PO = ahcp
+
+include ../../build/config.mk
+include ../../build/module.mk
diff --git a/applications/luci-ahcp/luasrc/controller/ahcp.lua b/applications/luci-ahcp/luasrc/controller/ahcp.lua
new file mode 100644 (file)
index 0000000..ea73903
--- /dev/null
@@ -0,0 +1,63 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id: init.lua 6731 2011-01-14 19:44:03Z soma $
+]]--
+
+module("luci.controller.ahcp", package.seeall)
+
+function index()
+       if not nixio.fs.access("/etc/config/ahcpd") then
+               return
+       end
+
+       require("luci.i18n")
+       luci.i18n.loadc("ahcp")
+
+       entry({"admin", "network", "ahcpd"}, cbi("ahcp"), luci.i18n.translate("AHCP Server"), 90).i18n = "ahcp"
+       entry({"admin", "network", "ahcpd", "status"}, call("ahcp_status"))
+end
+
+function ahcp_status()
+       local nfs = require "nixio.fs"
+       local uci = require "luci.model.uci".cursor()
+       local lsd = uci:get_first("ahcpd", "ahcpd", "lease_dir") or "/var/lib/leases"
+       local idf = uci:get_first("ahcpd", "ahcpd", "id_file")   or "/var/lib/ahcpd-unique-id"
+
+       local rv = {
+               uid    = "00:00:00:00:00:00:00:00",
+               leases = { }
+       }
+
+       idf = nfs.readfile(idf)
+       if idf and #idf == 8 then
+               rv.uid = "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X" %{ idf:byte(1, 8) }
+       end
+
+       local itr = nfs.dir(lsd)
+       if itr then
+               local addr
+               for addr in itr do
+                       if addr:match("^%d+%.%d+%.%d+%.%d+$") then
+                               local s = nfs.stat(lsd .. "/" .. addr)
+                               rv.leases[#rv.leases+1] = {
+                                       addr = addr,
+                                       age  = s and (os.time() - s.mtime) or 0
+                               }
+                       end
+               end
+       end
+
+       table.sort(rv.leases, function(a, b) return a.age < b.age end)
+
+       luci.http.prepare_content("application/json")
+       luci.http.write_json(rv)
+end
diff --git a/applications/luci-ahcp/luasrc/model/cbi/ahcp.lua b/applications/luci-ahcp/luasrc/model/cbi/ahcp.lua
new file mode 100644 (file)
index 0000000..18764a1
--- /dev/null
@@ -0,0 +1,121 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id: init.lua 5764 2010-03-08 19:05:34Z jow $
+]]--
+
+m = Map("ahcpd", translate("AHCP Server"), translate("AHCP is an autoconfiguration protocol " ..
+       "for IPv6 and dual-stack IPv6/IPv4 networks designed to be used in place of router " ..
+       "discovery and DHCP on networks where it is difficult or impossible to configure a " ..
+       "server within every link-layer broadcast domain, for example mobile ad-hoc networks."))
+
+
+m:section(SimpleSection).template = "ahcp_status"
+
+s = m:section(TypedSection, "ahcpd")
+s:tab("general", translate("General Setup"))
+s:tab("advanced", translate("Advanced Settings"))
+s.addremove = false
+s.anonymous = true
+
+
+mode = s:taboption("general", ListValue, "mode", translate("Operation mode"))
+mode:value("server", translate("Server"))
+mode:value("forwarder", translate("Forwarder"))
+
+net = s:taboption("general", Value, "interface", translate("Served interfaces"))
+net.template = "cbi/network_netlist"
+net.widget   = "checkbox"
+net.nocreate = true
+
+function net.cfgvalue(self, section)
+       return m.uci:get("ahcpd", section, "interface")
+end
+
+pfx = s:taboption("general", DynamicList, "prefix", translate("Announced prefixes"),
+       translate("Specifies the announced IPv4 and IPv6 network prefixes in CIDR notation"))
+pfx.optional  = true
+pfx.datatype  = "ipaddr"
+pfx:depends("mode", "server")
+
+nss = s:taboption("general", DynamicList, "name_server", translate("Announced DNS servers"),
+       translate("Specifies the announced IPv4 and IPv6 name servers"))
+nss.optional = true
+nss.datatype = "ipaddr"
+nss:depends("mode", "server")
+
+ntp = s:taboption("general", DynamicList, "ntp_server", translate("Announced NTP servers"),
+       translate("Specifies the announced IPv4 and IPv6 NTP servers"))
+ntp.optional = true
+ntp.datatype = "ipaddr"
+ntp:depends("mode", "server")
+
+mca = s:taboption("general", Value, "multicast_address", translate("Multicast address"))
+mca.optional    = true
+mca.placeholder = "ff02::cca6:c0f9:e182:5359"
+mca.datatype    = "ip6addr"
+
+port = s:taboption("general", Value, "port", translate("Port"))
+port.optional    = true
+port.placeholder = 5359
+port.datatype    = "port"
+
+fam = s:taboption("general", ListValue, "_family", translate("Protocol family"))
+fam:value("", translate("IPv4 and IPv6"))
+fam:value("ipv4", translate("IPv4 only"))
+fam:value("ipv6", translate("IPv6 only"))
+
+function fam.cfgvalue(self, section)
+       local v4 = m.uci:get_bool("ahcpd", section, "ipv4_only")
+       local v6 = m.uci:get_bool("ahcpd", section, "ipv6_only")
+       if v4 then
+               return "ipv4"
+       elseif v6 then
+               return "ipv6"
+       end
+       return ""
+end
+
+function fam.write(self, section, value)
+       if value == "ipv4" then
+               m.uci:set("ahcpd", section, "ipv4_only", "true")
+               m.uci:delete("ahcpd", section, "ipv6_only")
+       elseif value == "ipv6" then
+               m.uci:set("ahcpd", section, "ipv6_only", "true")
+               m.uci:delete("ahcpd", section, "ipv4_only")
+       end
+end
+
+function fam.remove(self, section)
+       m.uci:delete("ahcpd", section, "ipv4_only")
+       m.uci:delete("ahcpd", section, "ipv6_only")
+end
+
+ltime = s:taboption("general", Value, "lease_time", translate("Lease validity time"))
+ltime.optional    = true
+ltime.placeholder = 3666
+ltime.datatype    = "uinteger"
+
+
+ld = s:taboption("advanced", Value, "lease_dir", translate("Lease directory"))
+ld.datatype    = "directory"
+ld.placeholder = "/var/lib/leases"
+
+id = s:taboption("advanced", Value, "id_file", translate("Unique ID file"))
+--id.datatype    = "file"
+id.placeholder = "/var/lib/ahcpd-unique-id"
+
+log = s:taboption("advanced", Value, "log_file", translate("Log file"))
+--log.datatype    = "file"
+log.placeholder = "/var/log/ahcpd.log"
+
+
+return m
diff --git a/applications/luci-ahcp/luasrc/view/admin_status/index/ahcp.htm b/applications/luci-ahcp/luasrc/view/admin_status/index/ahcp.htm
new file mode 100644 (file)
index 0000000..ef4cfca
--- /dev/null
@@ -0,0 +1 @@
+<%+ahcp_status%>
diff --git a/applications/luci-ahcp/luasrc/view/ahcp_status.htm b/applications/luci-ahcp/luasrc/view/ahcp_status.htm
new file mode 100644 (file)
index 0000000..bc595ce
--- /dev/null
@@ -0,0 +1,60 @@
+<script type="text/javascript">//<![CDATA[
+       var stxhr = new XHR();
+       var update_status = function() {
+               stxhr.get('<%=luci.dispatcher.build_url("admin", "network", "ahcpd", "status")%>', null,
+                       function(x, st)
+                       {
+                               var tb = document.getElementById('ahcpd_status_table');
+                               var tx = document.getElementById('ahcpd_status_text');
+                               if (st && tb && tx)
+                               {
+                                       /* clear all rows */
+                                       while( tb.rows.length > 1 )
+                                               tb.deleteRow(1);
+
+                                       for( var i = 0; i < st.leases.length; i++ )
+                                       {
+                                               var tr = tb.insertRow(-1);
+                                                       tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
+
+                                               tr.insertCell(-1).innerHTML = st.leases[i].addr;
+                                               tr.insertCell(-1).innerHTML = String.format('%t', st.leases[i].age);
+                                       }
+
+                                       if( tb.rows.length == 1 )
+                                       {
+                                               var tr = tb.insertRow(-1);
+                                                       tr.className = 'cbi-section-table-row';
+
+                                               var td = tr.insertCell(-1);
+                                                       td.colSpan = 2;
+                                                       td.innerHTML = '<em><br /><%:There are no active leases.%></em>';
+                                       }
+
+                                       if( st.uid == '00:00:00:00:00:00:00:00' )
+                                               tx.innerHTML = 'The AHCP Service is not running.';
+                                       else
+                                               tx.innerHTML = String.format('The AHCP Service is running with ID %s.', st.uid);
+                               }
+
+                               window.setTimeout(update_status, 5000);
+                       }
+               )
+       };
+
+       update_status();
+//]]></script>
+
+<fieldset class="cbi-section">
+       <legend><%:Active AHCP Leases%></legend>
+       <p id="ahcpd_status_text"></p>
+       <table class="cbi-section-table" id="ahcpd_status_table">
+               <tr class="cbi-section-table-titles">
+                       <th class="cbi-section-table-cell"><%:Address%></th>
+                       <th class="cbi-section-table-cell"><%:Age%></th>
+               </tr>
+               <tr class="cbi-section-table-row">
+                       <td colspan="5"><em><br /><%:Collecting data...%></em></td>
+               </tr>
+       </table>
+</fieldset>
diff --git a/applications/luci-ahcp/root/etc/uci-defaults/luci-ahcp b/applications/luci-ahcp/root/etc/uci-defaults/luci-ahcp
new file mode 100755 (executable)
index 0000000..f2b2487
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+uci -q batch <<-EOF >/dev/null
+       delete ucitrack.@ahcpd[-1]
+       add ucitrack ahcpd
+       set ucitrack.@ahcpd[-1].init=ahcpd
+       commit ucitrack
+EOF
+
+rm -f /tmp/luci-indexcache
+exit 0
index 13dfd12978c2e966a411bb6a266fbd0256d4647a..da97ee986e6b70e91a740e8c8a54e264cd4e9ba4 100644 (file)
@@ -58,6 +58,7 @@ local knownParams = {
                { Flag,                 "client_disconnect",            0 },
                { Value,                "learn_address",                        "/usr/bin/ovpn-learnaddress" },
                { Value,                "auth_user_pass_verify",        "/usr/bin/ovpn-userpass via-env" },
+               { ListValue,            "script_security",              { 0, 1, 2, 3 }, {mode="server" } },
        } },
 
        { "networking", {
@@ -115,6 +116,7 @@ local knownParams = {
                { Flag,                 "management_query_passwords",   0 },    -- management
                { Flag,                 "management_hold",              0 },    -- management
                { Flag,                 "management_log_cache",         100 },  -- management
+               { ListValue,            "topology",                     { "net30", "p2p", "subnet" }, {dev_type="tun" } },
        } },
 
        { "vpn", {
index b3e22d48006cb05fdddd4e2bffa52039e8d40030..4f2f8d9f7acf13e1af5a0db1dda638681558a43b 100644 (file)
@@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
-       http://www.apache.org/licenses/LICENSE-2.0
+http://www.apache.org/licenses/LICENSE-2.0
 
 $Id$
 ]]--
@@ -17,36 +17,36 @@ require("luci.model.uci")
 
 
 local basicParams = {
+       --                                                              
+       -- Widget, Name, Default(s), Description
        --
-       -- Widget               Name                                    Optn.   Default(s)
-       --
-
-       { ListValue,    "verb",                                 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 } },
-       { Value,                "nice",                                 0 },
-       { Value,                "port",                                 1194 },
-       { ListValue,    "dev_type",                             { "tun", "tap" } },
-       { Flag,                 "tun_ipv6",                             0 },
-
-       { Value,                "ifconfig",                             "10.200.200.3 10.200.200.1" },
-       { Value,                "server",                               "10.200.200.0 255.255.255.0" },
-       { Value,                "server_bridge",                "192.168.1.1 255.255.255.0 192.168.1.128 192.168.1.254" },
-       { Flag,                 "nobind",                               0 },
-
-       { Flag,                 "comp_lzo",                             0 },
-       { Value,                "keepalive",                    "10 60" },
-
-       { ListValue,    "proto",                                { "udp", "tcp" } },
-
-       { Flag,                 "client",                               0 },
-       { Flag,                 "client_to_client",             0 },
-       { DynamicList,  "remote",                               "vpnserver.example.org" },
-
-       { FileUpload,   "secret",                               "/etc/openvpn/secret.key 1" },
-       { FileUpload,   "pkcs12",                               "/etc/easy-rsa/keys/some-client.pk12" },
-       { FileUpload,   "ca",                                   "/etc/easy-rsa/keys/ca.crt" },
-       { FileUpload,   "dh",                                   "/etc/easy-rsa/keys/dh1024.pem" },
-       { FileUpload,   "cert",                                 "/etc/easy-rsa/keys/some-client.crt" },
-       { FileUpload,   "key",                                  "/etc/easy-rsa/keys/some-client.key" },
+                                       
+       { ListValue, "verb", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, translate("Set output verbosity") },
+       { Value, "nice",0, translate("Change process priority") },
+       { Value,"port",1194, translate("TCP/UDP port # for both local and remote") },
+       { ListValue,"dev_type",{ "tun", "tap" }, translate("Type of used device") },
+       { Flag,"tun_ipv6",0, translate("Make tun device IPv6 capable") },
+
+       { Value,"ifconfig","10.200.200.3 10.200.200.1", translate("") },
+       { Value,"server","10.200.200.0 255.255.255.0", translate("Configure server mode") },
+       { Value,"server_bridge","192.168.1.1 255.255.255.0 192.168.1.128 192.168.1.254", translate("Configure server bridge") },
+       { Flag,"nobind",0, translate("Do not bind to local address and port") },
+
+       { Flag,"comp_lzo",0, translate("Use fast LZO compression") },
+       { Value,"keepalive","10 60", translate("") },
+
+       { ListValue,"proto",{ "udp", "tcp" }, translate("Use protocol") },
+
+       { Flag,"client",0, translate("Configure client mode") },
+       { Flag,"client_to_client",0, translate("Allow client-to-client traffic") },
+       { DynamicList,"remote","vpnserver.example.org", translate("Remote host name or ip address") },
+
+       { FileUpload,"secret","/etc/openvpn/secret.key 1", translate("Enable Static Key encryption mode (non-TLS)") },
+       { FileUpload,"pkcs12","/etc/easy-rsa/keys/some-client.pk12", translate("PKCS#12 file containing keys") },
+       { FileUpload,"ca","/etc/easy-rsa/keys/ca.crt", translate("Certificate authority") },
+       { FileUpload,"dh","/etc/easy-rsa/keys/dh1024.pem", translate("Diffie Hellman parameters") },
+       { FileUpload,"cert","/etc/easy-rsa/keys/some-client.crt", translate("Local certificate") },
+       { FileUpload,"key","/etc/easy-rsa/keys/some-client.key", translate("Local private key") },
 }
 
 
@@ -63,8 +63,7 @@ local s = m:section( NamedSection, arg[1], "openvpn" )
 for _, option in ipairs(basicParams) do
        local o = s:option(
                option[1], option[2],
-               translate("openvpn_param_%s" % option[2]),
-               translate("openvpn_param_%s_desc" % option[2])
+               option[2], option[4]
        )
        
        o.optional = true
@@ -100,3 +99,4 @@ for _, option in ipairs(basicParams) do
 end
 
 return m
+
index 8c1a947476ef62eba91485d8944575bee85acb68..f5d08902dabbb36a49d59470afba5331ae0913d5 100644 (file)
@@ -400,6 +400,9 @@ $(eval $(call application,vnstat,LuCI Support for VnStat,\
 $(eval $(call application,radvd,LuCI Support for Radvd,\
        +luci-mod-admin-full +PACKAGE_luci-app-radvd:radvd))
 
+$(eval $(call application,ahcp,LuCI Support for AHCPd,\
+       +luci-mod-admin-full +PACKAGE_luci-app-ahcp:ahcpd))
+
 $(eval $(call application,lqtapifoss,Lantiq voip))
 
 ### Server Gateway Interfaces ###
index cf76c8617cc01a171fac8ef78d287234d9230842..798b388fa54b5878bdf59fa1e00a6822e83ca319 100644 (file)
@@ -33,6 +33,7 @@ local has_ipv6   = fs.access("/proc/net/ipv6_route")
 local has_6in4   = fs.access("/lib/network/6in4.sh")
 local has_6to4   = fs.access("/lib/network/6to4.sh")
 local has_relay  = fs.access("/lib/network/relay.sh")
+local has_ahcp   = fs.access("/lib/network/ahcp.sh")
 
 m = Map("network", translate("Interfaces") .. " - " .. arg[1]:upper(), translate("On this page you can configure the network interfaces. You can bridge several interfaces by ticking the \"bridge interfaces\" field and enter the names of several network interfaces separated by spaces. You can also use <abbr title=\"Virtual Local Area Network\">VLAN</abbr> notation <samp>INTERFACE.VLANNR</samp> (<abbr title=\"for example\">e.g.</abbr>: <samp>eth0.1</samp>)."))
 m:chain("wireless")
@@ -68,6 +69,7 @@ if has_pppd  then s:tab("ppp", translate("PPP Settings")) end
 if has_pppoa then s:tab("atm", translate("ATM Settings")) end
 if has_6in4 or has_6to4 then s:tab("tunnel", translate("Tunnel Settings")) end
 if has_relay then s:tab("relay", translate("Relay Settings")) end
+if has_ahcp then s:tab("ahcp", translate("AHCP Settings")) end
 s:tab("physical", translate("Physical Settings"))
 if has_firewall then s:tab("firewall", translate("Firewall Settings")) end
 
@@ -94,6 +96,7 @@ if has_pptp  then p:value("pptp",  "PPTP")    end
 if has_6in4  then p:value("6in4",  "6in4")    end
 if has_6to4  then p:value("6to4",  "6to4")    end
 if has_relay then p:value("relay", "Relay")   end
+if has_ahcp  then p:value("ahcp",  "AHCP")    end
 p:value("none", translate("none"))
 
 if not ( has_pppd and has_pppoe and has_pppoa and has_3g and has_pptp ) then
@@ -122,6 +125,7 @@ ifname_single:depends({ type = "", proto = "static" })
 ifname_single:depends({ type = "", proto = "dhcp"   })
 ifname_single:depends({ type = "", proto = "pppoe"  })
 ifname_single:depends({ type = "", proto = "pppoa"  })
+ifname_single:depends({ type = "", proto = "ahcp"   })
 ifname_single:depends({ type = "", proto = "none"   })
 
 function ifname_single.cfgvalue(self, s)
@@ -541,6 +545,64 @@ if has_relay then
        table:depends("proto", "relay")
 end
 
+if has_ahcp then
+       mca = s:taboption("ahcp", Value, "multicast_address", translate("Multicast address"))
+       mca.optional    = true
+       mca.placeholder = "ff02::cca6:c0f9:e182:5359"
+       mca.datatype    = "ip6addr"
+       mca:depends("proto", "ahcp")
+
+       port = s:taboption("ahcp", Value, "port", translate("Port"))
+       port.optional    = true
+       port.placeholder = 5359
+       port.datatype    = "port"
+       port:depends("proto", "ahcp")
+
+       fam = s:taboption("ahcp", ListValue, "_family", translate("Protocol family"))
+       fam:value("", translate("IPv4 and IPv6"))
+       fam:value("ipv4", translate("IPv4 only"))
+       fam:value("ipv6", translate("IPv6 only"))
+       fam:depends("proto", "ahcp")
+
+       function fam.cfgvalue(self, section)
+               local v4 = m.uci:get_bool("network", section, "ipv4_only")
+               local v6 = m.uci:get_bool("network", section, "ipv6_only")
+               if v4 then
+                       return "ipv4"
+               elseif v6 then
+                       return "ipv6"
+               end
+               return ""
+       end
+
+       function fam.write(self, section, value)
+               if value == "ipv4" then
+                       m.uci:set("network", section, "ipv4_only", "true")
+                       m.uci:delete("network", section, "ipv6_only")
+               elseif value == "ipv6" then
+                       m.uci:set("network", section, "ipv6_only", "true")
+                       m.uci:delete("network", section, "ipv4_only")
+               end
+       end
+
+       function fam.remove(self, section)
+               m.uci:delete("network", section, "ipv4_only")
+               m.uci:delete("network", section, "ipv6_only")
+       end
+
+       nodns = s:taboption("ahcp", Flag, "no_dns", translate("Disable DNS setup"))
+       nodns.optional = true
+       nodns.enabled  = "true"
+       nodns.disabled = "false"
+       nodns.default  = nodns.disabled
+       nodns:depends("proto", "ahcp")
+
+       ltime = s:taboption("ahcp", Value, "lease_time", translate("Lease validity time"))
+       ltime.optional    = true
+       ltime.placeholder = 3666
+       ltime.datatype    = "uinteger"
+       ltime:depends("proto", "ahcp")
+end
 
 if net:proto() ~= "relay" then
        s2 = m:section(TypedSection, "alias", translate("IP-Aliases"))