Merge pull request #2968 from dibdot/banIP
authorDirk Brenken <dev@brenken.org>
Wed, 7 Aug 2019 03:45:28 +0000 (05:45 +0200)
committerGitHub <noreply@github.com>
Wed, 7 Aug 2019 03:45:28 +0000 (05:45 +0200)
luci-app-banip: sync with 0.1.5

12 files changed:
applications/luci-app-openvpn/luasrc/model/cbi/openvpn-advanced.lua
applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_add.lua
applications/luci-app-travelmate/luasrc/model/cbi/travelmate/wifi_edit.lua
applications/luci-app-travelmate/luasrc/view/travelmate/stations.htm
applications/luci-app-travelmate/luasrc/view/travelmate/wifi_scan.htm
libs/luci-lib-ip/src/ip.c
libs/luci-lib-ip/src/ip.luadoc
modules/luci-base/po/ja/base.po
protocols/luci-proto-3g/luasrc/model/network/proto_3g.lua
protocols/luci-proto-ipv6/luasrc/model/network/proto_4x6.lua
protocols/luci-proto-ipv6/luasrc/model/network/proto_6x4.lua
themes/luci-theme-rosy/htdocs/luci-static/rosy/cascade.css

index 2bf36cb27877997a7a3040865fa68388561a79e0..18b106c32ed231e2a81d2eae388024f67d12b72d 100644 (file)
@@ -676,13 +676,37 @@ local knownParams = {
                        "key_method",
                        { 1, 2 },
                        translate("Enable TLS and assume client role") },
-               { Value,
+               { DynamicList,
                        "tls_cipher",
-                       "DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:AES128-SHA:RC4-SHA:RC4-MD5:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC4-MD5",
+                       {
+                               "DHE-RSA-AES256-SHA",
+                               "DHE-DSS-AES256-SHA",
+                               "AES256-SHA",
+                               "EDH-RSA-DES-CBC3-SHA",
+                               "EDH-DSS-DES-CBC3-SHA",
+                               "DES-CBC3-SHA",
+                               "DHE-RSA-AES128-SHA",
+                               "DHE-DSS-AES128-SHA",
+                               "AES128-SHA",
+                               "RC4-SHA",
+                               "RC4-MD5",
+                               "EDH-RSA-DES-CBC-SHA",
+                               "EDH-DSS-DES-CBC-SHA",
+                               "DES-CBC-SHA",
+                               "EXP-EDH-RSA-DES-CBC-SHA",
+                               "EXP-EDH-DSS-DES-CBC-SHA",
+                               "EXP-DES-CBC-SHA",
+                               "EXP-RC2-CBC-MD5",
+                               "EXP-RC4-MD5"
+                       },
                        translate("TLS cipher") },
-               { Value,
+               { DynamicList,
                        "tls_ciphersuites",
-                       "TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256",
+                       {
+                               "TLS_AES_256_GCM_SHA384",
+                               "TLS_AES_128_GCM_SHA256",
+                               "TLS_CHACHA20_POLY1305_SHA256"
+                       },
                        translate("TLS 1.3 or newer cipher") },
                { Value,
                        "tls_timeout",
index 83011e9dd5fcdbbedddadf30d92590f5b5747ec4..2c2625dbcaed65ce9901aa84488ffa1fcce7a967 100644 (file)
@@ -1,9 +1,11 @@
--- Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
+-- Copyright 2017-2019 Dirk Brenken (dev@brenken.org)
 -- This is free software, licensed under the Apache License, Version 2.0
 
 local fs       = require("nixio.fs")
 local uci      = require("luci.model.uci").cursor()
 local http     = require("luci.http")
+local util     = require("luci.util")
+local scripts  = util.split(util.trim(util.exec("ls /etc/travelmate/*.login 2>/dev/null")), "\n", nil, true) or {}
 local trmiface = uci:get("travelmate", "global", "trm_iface") or "trm_wwan"
 local encr_psk = {"psk", "psk2", "psk-mixed"}
 local encr_wpa = {"wpa", "wpa2", "wpa-mixed"}
@@ -135,6 +137,17 @@ elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then
        end
 end
 
+local login_section = (m.hidden.ssid or "") .. (m.hidden.bssid or "")
+login_section = login_section.lower(login_section:gsub("[^%w_]", "_"))
+local cmd = uci:get("travelmate", login_section, "command")
+cmd_list = m:field(ListValue, "cmdlist", translate("Auto Login Script"),
+       translate("External script reference which will be called for automated captive portal logins."))
+cmd_list:value("none")
+for _, z in ipairs(scripts) do
+       cmd_list:value(z)
+end
+cmd_list.default = cmd or "none"
+
 function wssid.write(self, section, value)
        newsection = uci:section("wireless", "wifi-iface", nil, {
                mode     = "sta",
@@ -174,6 +187,16 @@ function wssid.write(self, section, value)
        else
                uci:set("wireless", newsection, "encryption", "none")
        end
+       local login_section = (wssid:formvalue(section) or "") .. (bssid:formvalue(section) or "")
+       login_section = login_section.lower(login_section:gsub("[^%w_]", "_"))
+       if not uci:get("travelmate", login_section) and cmd_list:formvalue(section) ~= "none" then
+               uci:set("travelmate", login_section, "login")
+       end
+       if uci:get("travelmate", login_section) then
+               uci:set("travelmate", login_section, "command", cmd_list:formvalue(section))
+               uci:save("travelmate")
+               uci:commit("travelmate")
+       end
        uci:save("wireless")
        uci:commit("wireless")
        luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>&1")
index dae358ae034b5c51e42c4518a130d0e1bf481ab2..c2c809cbccb45096792ba19b66e8bb104e7079f4 100644 (file)
@@ -1,9 +1,11 @@
 -- Copyright 2017-2019 Dirk Brenken (dev@brenken.org)
 -- This is free software, licensed under the Apache License, Version 2.0
 
-local fs   = require("nixio.fs")
-local uci  = require("luci.model.uci").cursor()
-local http = require("luci.http")
+local fs      = require("nixio.fs")
+local uci     = require("luci.model.uci").cursor()
+local http    = require("luci.http")
+local util    = require("luci.util")
+local scripts = util.split(util.trim(util.exec("ls /etc/travelmate/*.login 2>/dev/null")), "\n", nil, true) or {}
 
 m = SimpleForm("edit", translate("Edit Wireless Uplink Configuration"))
 m.submit = translate("Save")
@@ -19,6 +21,7 @@ m.hidden = {
 }
 
 local s = uci:get_all("wireless", m.hidden.cfg)
+
 if s ~= nil then
        wssid = m:field(Value, "ssid", translate("SSID"))
        wssid.datatype = "rangelength(1,32)"
@@ -126,6 +129,17 @@ if s ~= nil then
                wkey.password = true
                wkey.default = s.key or s.password
        end
+
+       local login_section = (s.ssid or "") .. (s.bssid or "")
+       login_section = login_section.lower(login_section:gsub("[^%w_]", "_"))
+       local cmd = uci:get("travelmate", login_section, "command")
+       cmd_list = m:field(ListValue, "cmdlist", translate("Auto Login Script"),
+               translate("External script reference which will be called for automated captive portal logins."))
+       cmd_list:value("none")
+       for _, z in ipairs(scripts) do
+               cmd_list:value(z)
+       end
+       cmd_list.default = cmd or "none"
 else
        m.on_cancel()
 end
@@ -160,6 +174,16 @@ function wssid.write(self, section, value)
                        uci:set("wireless", m.hidden.cfg, "priv_key_pwd", privkeypwd:formvalue(section) or "")
                end
        end
+       local login_section = (wssid:formvalue(section) or "") .. (bssid:formvalue(section) or "")
+       login_section = login_section.lower(login_section:gsub("[^%w_]", "_"))
+       if not uci:get("travelmate", login_section) and cmd_list:formvalue(section) ~= "none" then
+               uci:set("travelmate", login_section, "login")
+       end
+       if uci:get("travelmate", login_section) then
+               uci:set("travelmate", login_section, "command", cmd_list:formvalue(section))
+               uci:save("travelmate")
+               uci:commit("travelmate")
+       end
        uci:save("wireless")
        uci:commit("wireless")
        luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>&1")
index 0e78803d0641ca0e56f9073c2abdf9b15811a7b7..5c28966339e1e821d76a2d3bb062e2d449cb318e 100644 (file)
@@ -34,7 +34,7 @@ This is free software, licensed under the Apache License, Version 2.0
                                        if (view)
                                        {
                                                view.setAttribute("name", "station_nok");
-                                               view.setAttribute("style", "color: #a22; font-weight: bold");
+                                               view.setAttribute("style", "text-align: left !important; color: #a22; font-weight: bold");
                                        }
                                }
                        }
@@ -59,7 +59,7 @@ This is free software, licensed under the Apache License, Version 2.0
                                view   = document.getElementById(search);
                                if (view)
                                {
-                                       view.setAttribute("style", "color: #37c; font-weight: bold");
+                                       view.setAttribute("style", "text-align: left !important; color: #37c; font-weight: bold");
                                }
                        }
                }
@@ -122,10 +122,10 @@ This is free software, licensed under the Apache License, Version 2.0
                                                local encr    = s.encryption or "-"
                        -%>
                        <div class="tr cbi-section-table-row cbi-rowstyle-1" name="station_ok" id="1_<%=device%>/<%=ssid%>/<%=bssid%>">
-                               <div class="td left" name="station_ok" id="2_<%=device%>/<%=ssid%>/<%=bssid%>"><%=device%></div>
-                               <div class="td left" name="station_ok" id="3_<%=device%>/<%=ssid%>/<%=bssid%>"><%=ssid%></div>
-                               <div class="td left" name="station_ok" id="4_<%=device%>/<%=ssid%>/<%=bssid%>"><%=bssid%></div>
-                               <div class="td left" name="station_ok" id="5_<%=device%>/<%=ssid%>/<%=bssid%>"><%=encr%></div>
+                               <div class="td left" style="text-align: left !important" name="station_ok" id="2_<%=device%>/<%=ssid%>/<%=bssid%>"><%=device%></div>
+                               <div class="td left" style="text-align: left !important" name="station_ok" id="3_<%=device%>/<%=ssid%>/<%=bssid%>"><%=ssid%></div>
+                               <div class="td left" style="text-align: left !important" name="station_ok" id="4_<%=device%>/<%=ssid%>/<%=bssid%>"><%=bssid%></div>
+                               <div class="td left" style="text-align: left !important" name="station_ok" id="5_<%=device%>/<%=ssid%>/<%=bssid%>"><%=encr%></div>
                                <div class="td middle cbi-section-actions">
                                        <div>
                                                <input class="cbi-button cbi-button-up" type="button" value="<%:Up%>" onclick="location.href='<%=luci.dispatcher.build_url('admin/services/travelmate/wifiorder')%>?cfg=<%=section%>&amp;dir=up'" alt="<%:Move up%>" title="<%:Move up%>" />
index 67568f179e19887248da00a1b5d9f50f7eb08abf..86846a57104f10d88d9d161460a37a3ea89ed248 100644 (file)
@@ -52,16 +52,16 @@ This is free software, licensed under the Apache License, Version 2.0
                        </div>
                        <%- for i, net in ipairs(iw.scanlist or { }) do -%>
                        <div class="tr cbi-section-table-row cbi-rowstyle-1">
-                               <div class="td left">
+                               <div class="td left" style="text-align: left !important">
                                        <%=net.ssid and utl.pcdata(net.ssid) or "<em>%s</em>" % translate("hidden")%>
                                </div>
-                               <div class="td left">
+                               <div class="td left" style="text-align: left !important">
                                        <%=net.bssid and utl.pcdata(net.bssid)%>
                                </div>
-                               <div class="td left">
+                               <div class="td left" style="text-align: left !important">
                                        <%=format_wifi_encryption(net.encryption)%>
                                </div>
-                               <div class="td left">
+                               <div class="td left" style="text-align: left !important">
                                        <%=percent_wifi_signal(net)%> %
                                </div>
                                <div class="td cbi-section-actions">
index 854a0c09c2e646323ae77456191adad7e7324d23..188a70f144847be4cfa348d78d5373dc959401e2 100644 (file)
@@ -1075,22 +1075,24 @@ static int cb_dump_route(struct nl_msg *msg, void *arg)
 
        bitlen = AF_BITS(rt->rtm_family);
 
-       if ((f->type   && rt->rtm_type     != f->type)   ||
-           (f->family && rt->rtm_family   != f->family) ||
-           (f->proto  && rt->rtm_protocol != f->proto)  ||
-           (f->scope  && rt->rtm_scope    != f->scope)  ||
-               (f->iif    && iif              != f->iif)    ||
-               (f->oif    && oif              != f->oif)    ||
-               (f->table  && table            != f->table)  ||
-           diff_prefix(rt->rtm_family, from, rt->rtm_src_len,
-                       f->from_exact, &f->from)         ||
-           diff_prefix(rt->rtm_family, dst,  rt->rtm_dst_len,
-                       f->dst_exact, &f->dst)           ||
-           diff_prefix(rt->rtm_family, gw,   bitlen,
-                       false, &f->gw)                   ||
-           diff_prefix(rt->rtm_family, src,  bitlen,
-                       false, &f->src))
-               goto out;
+       if (!f->get) {
+               if ((f->type   && rt->rtm_type     != f->type)   ||
+                   (f->family && rt->rtm_family   != f->family) ||
+                   (f->proto  && rt->rtm_protocol != f->proto)  ||
+                   (f->scope  && rt->rtm_scope    != f->scope)  ||
+                   (f->iif    && iif              != f->iif)    ||
+                   (f->oif    && oif              != f->oif)    ||
+                   (f->table  && table            != f->table)  ||
+                   diff_prefix(rt->rtm_family, from, rt->rtm_src_len,
+                               f->from_exact, &f->from)         ||
+                   diff_prefix(rt->rtm_family, dst,  rt->rtm_dst_len,
+                               f->dst_exact, &f->dst)           ||
+                   diff_prefix(rt->rtm_family, gw,   bitlen,
+                               false, &f->gw)                   ||
+                   diff_prefix(rt->rtm_family, src,  bitlen,
+                               false, &f->src))
+                       goto out;
+       }
 
        if (s->callback)
                lua_pushvalue(s->L, 2);
@@ -1216,10 +1218,15 @@ static int _route_dump(lua_State *L, struct dump_filter *filter)
 
        nlmsg_append(msg, &rtm, sizeof(rtm), 0);
 
-       if (filter->get)
+       if (filter->get) {
                nla_put(msg, RTA_DST, AF_BYTES(filter->dst.family),
                        &filter->dst.addr.v6);
 
+               if (filter->src.family)
+                       nla_put(msg, RTA_SRC, AF_BYTES(filter->src.family),
+                               &filter->src.addr.v6);
+       }
+
        nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, cb_dump_route, &s);
        nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, cb_done, &s);
        nl_cb_err(cb, NL_CB_CUSTOM, cb_error, &s);
@@ -1236,17 +1243,32 @@ static int _route_dump(lua_State *L, struct dump_filter *filter)
 
 out:
        nl_cb_put(cb);
-       return (s.callback == 0);
+
+       if (s.callback)
+               return 0;
+
+       if (!filter->get)
+               return 1;
+
+       return (s.index > 0);
 }
 
 static int route_get(lua_State *L)
 {
        struct dump_filter filter = { .get = true };
        const char *dest = luaL_checkstring(L, 1);
+       const char *from = luaL_optstring(L, 2, NULL);
 
        if (!parse_cidr(dest, &filter.dst))
                return _error(L, -1, "Invalid destination");
 
+       if (from && !parse_cidr(from, &filter.src))
+               return _error(L, -1, "Invalid source");
+
+       if (filter.src.family != 0 &&
+           filter.src.family != filter.dst.family)
+               return _error(L, -1, "Different source/destination family");
+
        filter.family = filter.dst.family;
 
        return _route_dump(L, &filter);
index a2df96cdb5c6c1fbbe161b40bcd683c4d7594cae..afd171bebf6d00179733054bce9a86b3e0cd6515 100644 (file)
@@ -178,6 +178,8 @@ Determine the route leading to the given destination.
 @name route
 @param address A `luci.ip.cidr` instance or a string containing
 a valid IPv4 or IPv6 range as specified by `luci.ip.new()`.
+@param source   A `luci.ip.cidr` instance or a string containing
+the preferred source address for route selection (optional).
 @return <p>Table containing the fields described below.</p>
 <table id="routetable">
 <tr><th>Field</th><th>Description</th></tr>
index 24c13abd2d7bb21b5be0241d5ae85df9af69075a..8460642c520e5be5d26ee60b78ab4b86b802c6b9 100644 (file)
@@ -3,7 +3,7 @@ msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2009-06-10 03:40+0200\n"
-"PO-Revision-Date: 2019-07-13 18:28+0900\n"
+"PO-Revision-Date: 2019-08-06 02:52+0900\n"
 "Last-Translator: INAGAKI Hiroshi <musashino.open@gmail.com>\n"
 "Language-Team: \n"
 "Language: ja\n"
@@ -320,7 +320,7 @@ msgstr ""
 #: modules/luci-base/htdocs/luci-static/resources/tools/widgets.js:495
 #: modules/luci-base/htdocs/luci-static/resources/tools/widgets.js:499
 msgid "Absent Interface"
-msgstr ""
+msgstr "存在しないインターフェース"
 
 #: protocols/luci-proto-ppp/luasrc/model/cbi/admin_network/proto_pppoe.lua:19
 msgid "Access Concentrator"
@@ -1443,7 +1443,7 @@ msgstr "宛先"
 #: modules/luci-base/htdocs/luci-static/resources/tools/widgets.js:46
 #: modules/luci-base/htdocs/luci-static/resources/tools/widgets.js:151
 msgid "Destination zone"
-msgstr ""
+msgstr "宛先ゾーン"
 
 #: modules/luci-base/htdocs/luci-static/resources/tools/widgets.js:54
 #: modules/luci-base/htdocs/luci-static/resources/tools/widgets.js:177
@@ -2267,7 +2267,7 @@ msgstr ""
 
 #: protocols/luci-proto-ppp/luasrc/model/cbi/admin_network/proto_pppoe.lua:118
 msgid "Host-Uniq tag content"
-msgstr ""
+msgstr "Host-Uniq タグ"
 
 #: modules/luci-base/luasrc/view/lease_status.htm:71
 #: modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js:31
@@ -3465,7 +3465,7 @@ msgstr "ネットワーク名が設定されていません"
 
 #: modules/luci-mod-network/htdocs/luci-static/resources/view/network/wifi_join.js:147
 msgid "No networks in range"
-msgstr ""
+msgstr "範囲内にネットワークがありません"
 
 #: themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm:173
 #: themes/luci-theme-material/luasrc/view/themes/material/header.htm:211
@@ -3734,7 +3734,7 @@ msgstr "出力インターフェース"
 #: modules/luci-base/htdocs/luci-static/resources/tools/widgets.js:46
 #: modules/luci-base/htdocs/luci-static/resources/tools/widgets.js:151
 msgid "Output zone"
-msgstr ""
+msgstr "出力ゾーン"
 
 #: modules/luci-base/luasrc/model/cbi/admin_network/proto_dhcp.lua:63
 #: modules/luci-base/luasrc/model/cbi/admin_network/proto_static.lua:155
@@ -4219,6 +4219,8 @@ msgstr "Radius認証サーバー"
 #: protocols/luci-proto-ppp/luasrc/model/cbi/admin_network/proto_pppoe.lua:119
 msgid "Raw hex-encoded bytes. Leave empty unless your ISP require this"
 msgstr ""
+"16 進数でエンコードされた、生のバイト値です。 ISP がこれを必須としない場合、"
+"空欄のままにします。"
 
 #: modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js:83
 msgid ""
@@ -6220,7 +6222,7 @@ msgstr "なし"
 #: modules/luci-mod-system/luasrc/model/cbi/admin_system/fstab.lua:176
 #: modules/luci-mod-system/luasrc/model/cbi/admin_system/fstab.lua:186
 msgid "not present"
-msgstr ""
+msgstr "存在しません"
 
 #: modules/luci-mod-network/luasrc/model/cbi/admin_network/vlan.lua:363
 #: themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/header.htm:163
index b2454838f90803b72b97105d9901fae2e9ce1444..60d8e2ebae20b38ce38931e29885c339d2bf99b4 100644 (file)
@@ -38,7 +38,7 @@ function proto.get_interfaces(self)
        return nil
 end
 
-function proto.contains_interface(self, ifname)
+function proto.contains_interface(self, ifc)
        if self:is_floating() then
                return (netmod:ifnameof(ifc) == self:ifname())
        else
index 7508e0d4b00cb622df8a4e8c769df78a7872b2a5..0b329d8a92bb08dc387a4cce705e3194140abcc9 100644 (file)
@@ -49,7 +49,7 @@ for _, p in ipairs({"dslite", "map", "464xlat"}) do
                return nil
        end
 
-       function proto.contains_interface(self, ifname)
+       function proto.contains_interface(self, ifc)
                return (netmod:ifnameof(ifc) == self:ifname())
        end
 end
index 9a4396c5be431d33cfadd60789040c7fe0bc7547..2fd0b119578a7466f24da38a0a3c6141a2aca040 100644 (file)
@@ -42,7 +42,7 @@ for _, p in ipairs({"6in4", "6to4", "6rd"}) do
                return nil
        end
 
-       function proto.contains_interface(self, ifname)
+       function proto.contains_interface(self, ifc)
                return (netmod:ifnameof(ifc) == self:ifname())
        end
 
index d6460532fa09fea09110b9e96f10e53ccfccddf8..fca731cadd393905e0c6cb52313ab4c38b2fbf92 100644 (file)
@@ -55,6 +55,8 @@
        line-height: normal;
        display: table-cell;
        padding: .5em;
+       word-break: break-all;
+       word-wrap: break-word;
        text-align: center;
        vertical-align: middle;
 }
 
 .col-10 {
        flex: 10 10 300px !important;
+       width: 60%;
 }
 
 /* dom 元素 */