diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/computer.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/computer.png index 4598c7cb6..26887f089 100644 Binary files a/luci-app-openmptcprouter/htdocs/luci-static/resources/computer.png and b/luci-app-openmptcprouter/htdocs/luci-static/resources/computer.png differ diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/modem.svg b/luci-app-openmptcprouter/htdocs/luci-static/resources/modem.svg index 338d44192..d77391698 100644 --- a/luci-app-openmptcprouter/htdocs/luci-static/resources/modem.svg +++ b/luci-app-openmptcprouter/htdocs/luci-static/resources/modem.svg @@ -1,52 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/overthebox.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/overthebox.png index 7b578c01f..e0579a0f7 100644 Binary files a/luci-app-openmptcprouter/htdocs/luci-static/resources/overthebox.png and b/luci-app-openmptcprouter/htdocs/luci-static/resources/overthebox.png differ diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/server.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/server.png index 78f61d672..4ab67624b 100644 Binary files a/luci-app-openmptcprouter/htdocs/luci-static/resources/server.png and b/luci-app-openmptcprouter/htdocs/luci-static/resources/server.png differ diff --git a/luci-app-status/Makefile b/luci-app-status/Makefile new file mode 100644 index 000000000..debb5b67f --- /dev/null +++ b/luci-app-status/Makefile @@ -0,0 +1,14 @@ +# +# Copyright (C) 2020 Ycarus (Yannick Chabanois) +# +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=Aggregation status +LUCI_DEPENDS:=+luci-lib-json +luci-app-openmptcprouter +PKG_LICENSE:=GPLv3 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-status/htdocs/luci-static/resources/status/css/wanstatus.css b/luci-app-status/htdocs/luci-static/resources/status/css/wanstatus.css new file mode 100644 index 000000000..ac2a241d6 --- /dev/null +++ b/luci-app-status/htdocs/luci-static/resources/status/css/wanstatus.css @@ -0,0 +1,335 @@ +.container { + /* container for entire page. fixes bootstrap theme's ridiculously small page width */ + max-width: 1044px; +} +#interface_field { + padding: 12px 20px 20px 20px; +} +#mwan_status_text { + display: table; + font-size: 14px; + margin: auto; + max-width: 1044px; + min-width: 246px; + width: 100%; +} +.wanon { + background-color: #1cc82c; +} +.wanoff { + background-color: #e55712; +} +.wanon, +.wanoff { + border-radius: 60px; + box-shadow: 0px 2px 5px -3px; + float: left; + margin: 8px 3px 0px 3px; + min-height: 30px; + min-width: 235px; + padding: 5px 10px 8px 10px; + text-align: center; +} +/* Mwan3 ligthed CSS */ +.container { + /* container for entire page. fixes bootstrap theme's ridiculously small page width */ + max-width: 1044px; +} +#interface_field { + padding: 0px; +} +#interface_field td { + padding: 0px; +} +#interface_status_text { + display: table; + font-size: 14px; + margin: auto; + max-width: 1044px; + min-width: 246px; + width: 100%; +} +ul { + margin: 0px; +} +/*Now the CSS*/ +.tree ul { + position: relative; + float: left; + transition: all 0.5s; + -webkit-transition: all 0.5s; + -moz-transition: all 0.5s; +} +.tree li { + float: left; + text-align: left; + list-style-type: none; + position: relative; + padding: 5px 0px 5px 85px; + transition: all 0.5s; + -webkit-transition: all 0.5s; + -moz-transition: all 0.5s; +} +.tree ul ul { + padding-left: 85px; + position: relative; +} +.tree > ul > li:first-child { + position: relative; + padding-left: 0px; +} +.tree > ul > li#first-child > a { + position: relative; + top: 50%; +} +/*We will use ::before and ::after to draw the connectors + Before: Bottom part of the element + After: Top part of the element +*/ +.tree ul ul li::before, +.tree ul ul li::after { + content: ''; + position: absolute; + top: 50%; + left: 0; + border-left: 2px solid black; + width: 85px; + height: 50%; + float: left; + /*z-index: -10;*/ + /* + position: absolute; + top: 0; + right: 50%; + border-top: 2px solid black; + width: 50%; + height: 20px; + background-color: red; +*/ +} +.tree ul ul li::after { + top: auto; + bottom: 50%; + border-left: 2px solid black; + border-bottom: 2px solid black; +} +.tree li:first-child { + position: relative; + top: 50%; +} +/*We need to remove first top and the last bottom border */ +.tree li:only-child::after { + display: none; +} +/*Remove space from the top of single children*/ +.tree li:only-child { + padding-top: 0; +} +/*Remove left connector from first child and +right connector from last child*/ +.tree li:first-child::after, +.tree li:last-child::before { + border-left: 0px; +} +/*Adding back the vertical connector to the last nodes*/ +/* +.tree li:last-child::before{ + //border-top: 2px solid black; + border-radius: 0 5px 0 0; + -webkit-border-radius: 0 5px 0 0; + -moz-border-radius: 0 5px 0 0; +} +.tree li:first-child::after{ + border-radius: 5px 0 0 0; + -webkit-border-radius: 5px 0 0 0; + -moz-border-radius: 5px 0 0 0; +} +*/ +/*Time to add right connectors from parents*/ +.tree ul ul::before { + content: ''; + position: absolute; + top: 50%; + left: 0; + border-top: 2px solid black; + width: 85px; + height: 100%; +} +.tree li a { + display: inline-block; + background-color: #f3f3f3; + text-decoration: none; + /* + border: 1px solid @color-bg-gray; + padding: 5px 10px; + + font-family: arial, verdana, tahoma; + font-size: 11px; + + border-radius: 5px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + + transition: all 0.5s; + -webkit-transition: all 0.5s; + -moz-transition: all 0.5s; + */ +} +/*Exception*/ +.tree li.remote-from-lease { + padding-bottom: 0px; +} +.tree li.remote-from-lease::before, +.tree li#networkRootNode::before { + display: none; +} +.tree li#networkRootNode::after { + border: none; +} +.tree li.remote-from-lease::after { + content: ''; + position: absolute; + left: 50%; + top: 83px; + border-left: 2px solid black; + border-bottom: none; + width: 2px; + height: 30px; + z-index: -10; +} +.remote-from-lease a { + height: 90px; +} +.tree li#networkRootNode { + padding: 25px 0 0 0; +} +.tree li.subnode-only-child::before { + content: ''; + position: absolute; + top: 50%; + left: 0; + border-top: 2px solid black; + width: 85px; + height: 0; +} +.tree ul li#networkRootNode:not(:first-child) tr.spaceline td { + content: ''; + position: absolute; + /*top: 0; + top: 75px;*/ + border-left: 2px solid black; + border-bottom: none; + width: 2px; + /*height: 50%;*/ + height: 55px; + left: 200px; + /* z-index: -10;*/ +} +/*Time for some hover effects*/ +/*We will apply the hover effect the the lineage of the element also*/ +/* +.tree li a:hover, .tree li a:hover+ul li a { + background: #c8e4f8; color: #000; border: 1px solid #94a0b4; +} +.tree li a:hover+ul li::after, +.tree li a:hover+ul li::before, +.tree li a:hover+ul::before, +.tree li a:hover+ul ul::before{ + border-color: #94a0b4; +} +*/ +/*Thats all. I hope you enjoyed it. +Thanks :)*/ +.network-node { + position: relative; + background-color: #f3f3f3; + padding: 12px; + width: 400px; + max-width: 400px; + box-sizing: border-box; + height: 170px; +} +.network-node .equipment-icon { + position: relative; + float: left; + width: 64px; + max-width: 64px; + box-sizing: border-box; +} +.network-node .equipment-icon emded, +.network-node .equipment-icon img { + width: 64px; + max-width: 64px; +} +.network-node .equipment-icon img { + position: relative; + top: 10px; +} +.network-node .status-icon { + position: relative; + float: left; + width: 30px; + max-width: 30px; + margin-left: 24px; + margin-rigth: 8px; + top: 20px; + box-sizing: border-box; +} +.network-node .status-icon img { + max-width: 30px; + width: 30px; +} +.network-node .info { + position: relative; + float: right; + width: 250px; + text-align: left; + font-size: 12px; + color: #757575; +} +.network-node .info .title { + display: block; + font-size: 17px; + font-weight: 700; + color: #333333; +} + +.network-node .info .title i { + font-weight: lighter; + font-size: 8px; + text-transform: uppercase; +} + +.network-node .info .status-message { + display: block; +} +.network-node .info .status-message.error { + color: #e55712; +} +.network-node .info .status-message.warning { + color: #eb9e10; +} +.network-node .info .content { + display: block; +} +#networkRootNode table td { + border-top: 0px; +} +.vertdash { + width:5px; + border-right:2px dotted black; + height:70px; + padding-right: 195px; +} +#omr { + height: 190px; +} +#omr-vps { + height: 160px; +} +.space { + height: 55px; +} +.spaceline { + height: 55px; +} diff --git a/luci-app-status/htdocs/luci-static/resources/status/images/status-doing.png b/luci-app-status/htdocs/luci-static/resources/status/images/status-doing.png new file mode 100644 index 000000000..e71747272 Binary files /dev/null and b/luci-app-status/htdocs/luci-static/resources/status/images/status-doing.png differ diff --git a/luci-app-status/htdocs/luci-static/resources/status/images/status-done.png b/luci-app-status/htdocs/luci-static/resources/status/images/status-done.png new file mode 100644 index 000000000..bb6265c98 Binary files /dev/null and b/luci-app-status/htdocs/luci-static/resources/status/images/status-done.png differ diff --git a/luci-app-status/htdocs/luci-static/resources/status/images/status-error.png b/luci-app-status/htdocs/luci-static/resources/status/images/status-error.png new file mode 100644 index 000000000..4d2cf17ea Binary files /dev/null and b/luci-app-status/htdocs/luci-static/resources/status/images/status-error.png differ diff --git a/luci-app-status/htdocs/luci-static/resources/status/images/status-todo.png b/luci-app-status/htdocs/luci-static/resources/status/images/status-todo.png new file mode 100644 index 000000000..e71747272 Binary files /dev/null and b/luci-app-status/htdocs/luci-static/resources/status/images/status-todo.png differ diff --git a/luci-app-status/htdocs/luci-static/resources/status/images/status-warn.png b/luci-app-status/htdocs/luci-static/resources/status/images/status-warn.png new file mode 100644 index 000000000..9194825fb Binary files /dev/null and b/luci-app-status/htdocs/luci-static/resources/status/images/status-warn.png differ diff --git a/luci-app-status/htdocs/luci-static/resources/status/images/statusError.png b/luci-app-status/htdocs/luci-static/resources/status/images/statusError.png new file mode 100644 index 000000000..d22c0de55 Binary files /dev/null and b/luci-app-status/htdocs/luci-static/resources/status/images/statusError.png differ diff --git a/luci-app-status/htdocs/luci-static/resources/status/images/statusOK.png b/luci-app-status/htdocs/luci-static/resources/status/images/statusOK.png new file mode 100644 index 000000000..7a40c9758 Binary files /dev/null and b/luci-app-status/htdocs/luci-static/resources/status/images/statusOK.png differ diff --git a/luci-app-status/htdocs/luci-static/resources/status/images/statusWarning.png b/luci-app-status/htdocs/luci-static/resources/status/images/statusWarning.png new file mode 100644 index 000000000..29ee04f01 Binary files /dev/null and b/luci-app-status/htdocs/luci-static/resources/status/images/statusWarning.png differ diff --git a/luci-app-status/luasrc/controller/status.lua b/luci-app-status/luasrc/controller/status.lua new file mode 100644 index 000000000..551385277 --- /dev/null +++ b/luci-app-status/luasrc/controller/status.lua @@ -0,0 +1,313 @@ +local math = require "math" +local sys = require "luci.sys" +local json = require("luci.json") +local fs = require("nixio.fs") +local net = require "luci.model.network".init() +local ucic = luci.model.uci.cursor() +local ipc = require "luci.ip" +module("luci.controller.status", package.seeall) + +function index() + entry({"admin", "system", "status"}, alias("admin", "system", "status", "server"), _("Settings"), 1) + entry({"admin", "system", "status","server"}, template("status/server"),_('Settings'),1).leaf = true + entry({"admin", "system", "status","status"}, template("status/wanstatus"),_('Status'),2).leaf = true + entry({"admin", "system", "status","server_add"}, post("server_add")) + entry({"admin", "system", "status", "interfaces_status"}, call("interfaces_status")).leaf = true + entry({"admin", "system", "status", "multipath_bandwidth"}, call("multipath_bandwidth")).leaf = true + entry({"admin", "system", "status", "interface_bandwidth"}, call("interface_bandwidth")).leaf = true +end + +function server_add() + local serversnb = 0 + local servers = luci.http.formvaluetable("server") + for server, _ in pairs(servers) do + local server_ip = luci.http.formvalue("%s.server_ip" % server) or "" + local master = luci.http.formvalue("master") or "" + + -- OpenMPTCProuter VPS + local openmptcprouter_vps_key = luci.http.formvalue("%s.openmptcprouter_vps_key" % server) or "" + local openmptcprouter_vps_username = luci.http.formvalue("%s.openmptcprouter_vps_username" % server) or "" + ucic:set("openmptcprouter",server,"server") + ucic:set("openmptcprouter",server,"username",openmptcprouter_vps_username) + ucic:set("openmptcprouter",server,"password",openmptcprouter_vps_key) + if master == server or (master == "" and serversnb == 0) then + ucic:set("openmptcprouter",server,"get_config","1") + ucic:set("openmptcprouter",server,"master","1") + ucic:set("openmptcprouter",server,"backup","0") + else + ucic:set("openmptcprouter",server,"get_config","0") + ucic:set("openmptcprouter",server,"master","0") + ucic:set("openmptcprouter",server,"backup","1") + end + if server_ip ~= "" then + serversnb = serversnb + 1 + end + ucic:set("openmptcprouter",server,"disabled",openmptcprouter_vps_disabled) + ucic:set("openmptcprouter",server,"ip",server_ip) + ucic:set("openmptcprouter",server,"port","65500") + ucic:save("openmptcprouter") + end + + local ss_servers_nginx = {} + local ss_servers_ha = {} + local vpn_servers = {} + local k = 0 + local ss_ip + + for server, _ in pairs(servers) do + local master = luci.http.formvalue("master") or "" + local server_ip = luci.http.formvalue("%s.server_ip" % server) or "" + -- We have an IP, so set it everywhere + if server_ip ~= "" and luci.http.formvalue("%s.openmptcprouter_vps_disabled" % server) ~= "1" then + -- Check if we have more than one IP, in this case use Nginx HA + if serversnb > 1 then + if master == server then + ss_ip=server_ip + ucic:set("shadowsocks-libev","sss0","server",server_ip) + ucic:set("glorytun","vpn","host",server_ip) + ucic:set("dsvpn","vpn","host",server_ip) + ucic:set("mlvpn","general","host",server_ip) + ucic:set("ubond","general","host",server_ip) + luci.sys.call("uci -q del openvpn.omr.remote") + luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip) + ucic:set("qos","serverin","srchost",server_ip) + ucic:set("qos","serverout","dsthost",server_ip) + end + k = k + 1 + ucic:set("nginx-ha","ShadowSocks","enable","0") + ucic:set("nginx-ha","VPN","enable","0") + ucic:set("haproxy-tcp","general","enable","0") + ucic:set("openmptcprouter","settings","ha","1") + else + ucic:set("openmptcprouter","settings","ha","0") + ucic:set("nginx-ha","ShadowSocks","enable","0") + ucic:set("nginx-ha","VPN","enable","0") + ucic:set("shadowsocks-libev","sss0","server",server_ip) + ucic:set("glorytun","vpn","host",server_ip) + ucic:set("dsvpn","vpn","host",server_ip) + ucic:set("mlvpn","general","host",server_ip) + ucic:set("ubond","general","host",server_ip) + luci.sys.call("uci -q del openvpn.omr.remote") + luci.sys.call("uci -q add_list openvpn.omr.remote=" .. server_ip) + ucic:set("qos","serverin","srchost",server_ip) + ucic:set("qos","serverout","dsthost",server_ip) + end + end + end + ucic:save("qos") + ucic:commit("qos") + ucic:save("nginx-ha") + ucic:commit("nginx-ha") + ucic:save("openvpn") + ucic:commit("openvpn") + ucic:save("mlvpn") + ucic:save("ubond") + ucic:commit("mlvpn") + ucic:save("dsvpn") + ucic:commit("dsvpn") + ucic:save("glorytun") + ucic:commit("glorytun") + ucic:save("shadowsocks-libev") + ucic:commit("shadowsocks-libev") + luci.sys.call("(env -i /bin/ubus call network reload) >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/omr-tracker stop >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/mptcp restart >/dev/null 2>/dev/null") + if openmptcprouter_vps_key ~= "" then + luci.sys.call("/etc/init.d/openmptcprouter-vps restart >/dev/null 2>/dev/null") + os.execute("sleep 2") + end + luci.sys.call("/etc/init.d/shadowsocks-libev restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/glorytun restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/glorytun-udp restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/mlvpn restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/ubond restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/openvpn restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/dsvpn restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/omr-tracker start >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/omr-6in4 restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/mptcpovervpn restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/vnstat restart >/dev/null 2>/dev/null") + luci.http.redirect(luci.dispatcher.build_url("admin/system/status/status")) +end + + +function interfaces_status() + local ut = require "luci.util" + local mArray = ut.ubus("openmptcprouter", "status", {}) or {_=0} + if mArray ~= nil and mArray.openmptcprouter ~= nil then + mArray.openmptcprouter["remote_addr"] = luci.http.getenv("REMOTE_ADDR") or "" + mArray.openmptcprouter["remote_from_lease"] = false + -- local leases=dhcp_leases_common(4) + -- for _, value in pairs(leases) do + -- if value["ipaddr"] == mArray.openmptcprouter["remote_addr"] then + -- mArray.openmptcprouter["remote_from_lease"] = true + -- mArray.openmptcprouter["remote_hostname"] = value["hostname"] + -- end + -- end + end + + luci.http.prepare_content("application/json") + luci.http.write_json(mArray) +end + +-- This function come from modules/luci-bbase/luasrc/tools/status.lua from old OpenWrt +-- Copyright 2011 Jo-Philipp Wich +-- Licensed to the public under the Apache License 2.0. +local function dhcp_leases_common(family) + local rv = { } + local nfs = require "nixio.fs" + local sys = require "luci.sys" + local leasefile = "/tmp/dhcp.leases" + + ucic:foreach("dhcp", "dnsmasq", + function(s) + if s.leasefile and nfs.access(s.leasefile) then + leasefile = s.leasefile + return false + end + end) + + local fd = io.open(leasefile, "r") + if fd then + while true do + local ln = fd:read("*l") + if not ln then + break + else + local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)") + local expire = tonumber(ts) or 0 + if ts and mac and ip and name and duid then + if family == 4 and not ip:match(":") then + rv[#rv+1] = { + expires = (expire ~= 0) and os.difftime(expire, os.time()), + macaddr = ipc.checkmac(mac) or "00:00:00:00:00:00", + ipaddr = ip, + hostname = (name ~= "*") and name + } + elseif family == 6 and ip:match(":") then + rv[#rv+1] = { + expires = (expire ~= 0) and os.difftime(expire, os.time()), + ip6addr = ip, + duid = (duid ~= "*") and duid, + hostname = (name ~= "*") and name + } + end + end + end + end + fd:close() + end + + local lease6file = "/tmp/hosts/odhcpd" + ucic:foreach("dhcp", "odhcpd", + function(t) + if t.leasefile and nfs.access(t.leasefile) then + lease6file = t.leasefile + return false + end + end) + local fd = io.open(lease6file, "r") + if fd then + while true do + local ln = fd:read("*l") + if not ln then + break + else + local iface, duid, iaid, name, ts, id, length, ip = ln:match("^# (%S+) (%S+) (%S+) (%S+) (-?%d+) (%S+) (%S+) (.*)") + local expire = tonumber(ts) or 0 + if ip and iaid ~= "ipv4" and family == 6 then + rv[#rv+1] = { + expires = (expire >= 0) and os.difftime(expire, os.time()), + duid = duid, + ip6addr = ip, + hostname = (name ~= "-") and name + } + elseif ip and iaid == "ipv4" and family == 4 then + rv[#rv+1] = { + expires = (expire >= 0) and os.difftime(expire, os.time()), + macaddr = sys.net.duid_to_mac(duid) or "00:00:00:00:00:00", + ipaddr = ip, + hostname = (name ~= "-") and name + } + end + end + end + fd:close() + end + + if family == 6 then + local _, lease + local hosts = sys.net.host_hints() + for _, lease in ipairs(rv) do + local mac = sys.net.duid_to_mac(lease.duid) + local host = mac and hosts[mac] + if host then + if not lease.name then + lease.host_hint = host.name or host.ipv4 or host.ipv6 + elseif host.name and lease.hostname ~= host.name then + lease.host_hint = host.name + end + end + end + end + + return rv +end + +function interface_bandwidth(iface) + luci.http.prepare_content("application/json") + local bwc = io.popen("luci-bwc -i %q 2>/dev/null" % iface) + if bwc then + luci.http.write("[") + while true do + local ln = bwc:read("*l") + if not ln then break end + luci.http.write(ln) + end + luci.http.write("]") + bwc:close() + end +end + +function multipath_bandwidth() + local result = { }; + local uci = luci.model.uci.cursor() + + uci:foreach("network", "interface", function(s) + local intname = s[".name"] + local dev = get_device(intname) + if dev == "" then + dev = get_device(s["ifname"]) + end + local multipath = s["multipath"] or "" + if dev ~= "lo" and dev ~= "" then + if multipath == "" then + multipath = uci:get("openmptcprouter", intname, "multipath") or "" + end + if multipath == "" then + multipath = "off" + end + if multipath == "on" or multipath == "master" or multipath == "backup" or multipath == "handover" then + local bwc = luci.sys.exec("luci-bwc -i %q 2>/dev/null" % dev) or "" + if bwc ~= nil then + --result[dev] = "[" .. string.gsub(bwc, '[\r\n]', '') .. "]" + result[intname] = "[" .. string.gsub(bwc, '[\r\n]', '') .. "]" + else + result[dev] = "[]" + end + end + end + end) + + luci.http.prepare_content("application/json") + luci.http.write_json(result) +end + +function get_device(interface) + local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {}) + if dump ~= nil then + return dump['l3_device'] + else + return "" + end +end \ No newline at end of file diff --git a/luci-app-status/luasrc/view/status/server.htm b/luci-app-status/luasrc/view/status/server.htm new file mode 100644 index 000000000..b7b367fce --- /dev/null +++ b/luci-app-status/luasrc/view/status/server.htm @@ -0,0 +1,94 @@ +<%+header%> + +<% + local uci = require("luci.model.uci").cursor() + local net = require "luci.model.network".init() + local fs = require "nixio.fs" + local sys = require "luci.sys" + local ut = require "luci.util" + local ifaces = sys.net:devices() + local servers_ip = {} + local server_ip = uci:get("shadowsocks-libev","sss0","server") + if server_ip == '127.0.0.1' then + local upstreams = uci:get("nginx-ha","ShadowSocks","upstreams") + for _, up in pairs(upstreams) do + local a = up:match("^([^:]+):") + table.insert(servers_ip,a) + end + else + table.insert(servers_ip,server_ip) + end +%> + + + +<% if stderr and #stderr > 0 then %>
<%=pcdata(stderr)%>
<% end %> +
+
+

<%:Wizard%>

+
+ <%:Server settings%> + <% + nbserver=0 + uci:foreach("openmptcprouter","server", function(s) + nbserver=nbserver+1 + end) + uci:foreach("openmptcprouter","server", function(s) + servername = s[".name"] + %> +
+ +
+

<%=servername%>

+
+
+ +
+ " data-optional="false"> +
+ <%:Server IP%> +
+
+
+
+
+ +
+ " data-optional="false"> +
+
+ <%:API username to retrieve personnalized settings from the server.%> +
+
+
+
+ +
+ " data-optional="false"> +
+
+ <%:Key to configure, retrieve others keys and settings from Server.%> +
+
+
+ <% + end) + %> +
+
+
+
+ + +
+
+ +<%+footer%> diff --git a/luci-app-status/luasrc/view/status/wanstatus.htm b/luci-app-status/luasrc/view/status/wanstatus.htm new file mode 100644 index 000000000..e3da853f5 --- /dev/null +++ b/luci-app-status/luasrc/view/status/wanstatus.htm @@ -0,0 +1,1662 @@ +<% +-- Copyright 2015 OVH (OverTheBox@ovh.net) +-- Simon Lelievre (simon.lelievre@corp.ovh.com) +-- Sebastien Duponcheel (sebastien.duponcheel@ovh.net) +-- +-- This file is part of OverTheBox for OpenWrt. +-- +-- OverTheBox is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- OverTheBox is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with OverTheBox. If not, see (http://www.gnu.org/licenses/) +-%> +<% +-- Copyright 2018 Ycarus (Yannick Chabanois) ycarus@zugaina.org +-- +-- Small changes to make this work with OpenMPTCProuter +-- New features: +-- * DNS detection +-- * IPv6 route received +-- * latest version available +-- * MPTCP server status +-- * Server status, errors,icon,... +-- * Many tests +-%> +<%- + local ntm = require "luci.model.network".init() + local uci = require "luci.model.uci".cursor() + + function get_device(interface) + local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {}) + if dump and dump['l3_device'] ~= "" then + return dump['l3_device'] + else + return interface + end + end + + local dev + local devices = { "all" } + for _, dev in ipairs(ntm:get_networks()) do + --if dev ~= "lo" and not ntm:ignore_interface(dev) then + local multipath = uci:get("network", dev:name(), "multipath") + if multipath == "on" or multipath == "master" or multipath == "backup" or multipath == "handover" then + devices[#devices+1] = dev:name() + end + --end + end + + local curifname = luci.http.formvalue("dev") or "all" +-%> +<%+header%> + + + + + + +

<%:Network overview%>

+
+ +
+
+
+
+

Settings

+
+
+ +
+ +
+
+
+
+
+ +

<%:Realtime Traffic%>

+ + + +<% if curifname == "all" then %> + +<%:Download:%> + +
-
+ +
+ +<%:Upload:%> + +
-
+ +
+
+ +<% else %> + + +
-
+
+ + + + + + + + + + + + + + + + + + + + + + +
<%:Inbound:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Average:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Peak:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Outbound:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Average:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Peak:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
+ +<% end %> +<%+footer%> \ No newline at end of file diff --git a/luci-app-status/po/templates/status.pot b/luci-app-status/po/templates/status.pot new file mode 100644 index 000000000..4e44d83b5 --- /dev/null +++ b/luci-app-status/po/templates/status.pot @@ -0,0 +1,152 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1395 +msgid "(%d minute window, %d second interval)" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:970 +#: luci-app-status/luasrc/view/status/wanstatus.htm:971 +msgid "(%d minutes window, %d seconds interval)" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:68 +msgid "API username to retrieve personnalized settings from the server." +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1027 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1030 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1066 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1561 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1571 +msgid "Average:" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1023 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1026 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1062 +msgid "Current:" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1537 +msgid "Download:" +msgstr "" + +#: luci-app-status/root/usr/share/rpcd/acl.d/luci-app-status.json:3 +msgid "Grant UCI access for luci-app-status" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1558 +msgid "Inbound:" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:78 +msgid "Key to configure, retrieve others keys and settings from Server." +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:823 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1306 +msgid "MB/s" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:832 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1315 +msgid "Mbit/s" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1505 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1507 +msgid "Network overview" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1568 +msgid "Outbound:" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1031 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1034 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1070 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1564 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1574 +msgid "Peak:" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1524 +msgid "Realtime Traffic" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:90 +msgid "Save & Apply" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:53 +#: luci-app-status/luasrc/view/status/server.htm:55 +#: luci-app-status/luasrc/view/status/server.htm:57 +msgid "Server IP" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:73 +#: luci-app-status/luasrc/view/status/server.htm:75 +msgid "Server key" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:38 +msgid "Server settings" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:63 +#: luci-app-status/luasrc/view/status/server.htm:65 +msgid "Server username" +msgstr "" + +#: luci-app-status/luasrc/controller/status.lua:11 +#: luci-app-status/luasrc/controller/status.lua:12 +msgid "Settings" +msgstr "" + +#: luci-app-status/luasrc/controller/status.lua:13 +#: luci-app-status/root/usr/share/luci/menu.d/luci-app-status.json:3 +msgid "Status" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1543 +msgid "Upload:" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:36 +msgid "Wizard" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:818 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1026 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1030 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1034 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1065 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1069 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1073 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1301 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1559 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1562 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1565 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1569 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1572 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1575 +msgid "kB/s" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:827 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1026 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1030 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1034 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1065 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1069 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1073 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1310 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1559 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1562 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1565 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1569 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1572 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1575 +msgid "kbit/s" +msgstr "" diff --git a/luci-app-status/po/zh_Hans/status.po b/luci-app-status/po/zh_Hans/status.po new file mode 100644 index 000000000..082cb7424 --- /dev/null +++ b/luci-app-status/po/zh_Hans/status.po @@ -0,0 +1,163 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.3.1\n" +"Last-Translator: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"Language: zh_CN\n" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1395 +msgid "(%d minute window, %d second interval)" +msgstr "最近%d分钟信息, 每%d秒刷新" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:970 +#: luci-app-status/luasrc/view/status/wanstatus.htm:971 +msgid "(%d minutes window, %d seconds interval)" +msgstr "最近%d分钟信息, 每%d秒刷新" + +#: luci-app-status/luasrc/view/status/server.htm:68 +msgid "API username to retrieve personnalized settings from the server." +msgstr "API用户名,用于从服务器检索个性化设置." + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1027 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1030 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1066 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1561 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1571 +msgid "Average:" +msgstr "平均:" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1023 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1026 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1062 +msgid "Current:" +msgstr "当前:" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1537 +msgid "Download:" +msgstr "下载:" + +#: luci-app-status/root/usr/share/rpcd/acl.d/luci-app-status.json:3 +msgid "Grant UCI access for luci-app-status" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1558 +msgid "Inbound:" +msgstr "入站:" + +#: luci-app-status/luasrc/view/status/server.htm:78 +msgid "Key to configure, retrieve others keys and settings from Server." +msgstr "用于配置的密钥,可从服务器检索其他密钥和设置." + +#: luci-app-status/luasrc/view/status/wanstatus.htm:823 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1306 +msgid "MB/s" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:832 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1315 +msgid "Mbit/s" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1505 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1507 +msgid "Network overview" +msgstr "网络概述" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1568 +msgid "Outbound:" +msgstr "出站:" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1031 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1034 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1070 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1564 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1574 +msgid "Peak:" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1524 +msgid "Realtime Traffic" +msgstr "实时流量" + +#: luci-app-status/luasrc/view/status/server.htm:90 +msgid "Save & Apply" +msgstr "保存&应用" + +#: luci-app-status/luasrc/view/status/server.htm:53 +#: luci-app-status/luasrc/view/status/server.htm:55 +#: luci-app-status/luasrc/view/status/server.htm:57 +msgid "Server IP" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:73 +#: luci-app-status/luasrc/view/status/server.htm:75 +msgid "Server key" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:38 +msgid "Server settings" +msgstr "" + +#: luci-app-status/luasrc/view/status/server.htm:63 +#: luci-app-status/luasrc/view/status/server.htm:65 +msgid "Server username" +msgstr "" + +#: luci-app-status/luasrc/controller/status.lua:11 +#: luci-app-status/luasrc/controller/status.lua:12 +msgid "Settings" +msgstr "设置" + +#: luci-app-status/luasrc/controller/status.lua:13 +#: luci-app-status/root/usr/share/luci/menu.d/luci-app-status.json:3 +msgid "Status" +msgstr "状态" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:1543 +msgid "Upload:" +msgstr "上传:" + +#: luci-app-status/luasrc/view/status/server.htm:36 +msgid "Wizard" +msgstr "蚂蚁聚合设置向导" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:818 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1026 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1030 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1034 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1065 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1069 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1073 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1301 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1559 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1562 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1565 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1569 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1572 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1575 +msgid "kB/s" +msgstr "" + +#: luci-app-status/luasrc/view/status/wanstatus.htm:827 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1026 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1030 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1034 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1065 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1069 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1073 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1310 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1559 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1562 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1565 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1569 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1572 +#: luci-app-status/luasrc/view/status/wanstatus.htm:1575 +msgid "kbit/s" +msgstr "" diff --git a/luci-app-status/root/usr/share/luci/menu.d/luci-app-status.json b/luci-app-status/root/usr/share/luci/menu.d/luci-app-status.json new file mode 100644 index 000000000..bddbb5483 --- /dev/null +++ b/luci-app-status/root/usr/share/luci/menu.d/luci-app-status.json @@ -0,0 +1,13 @@ +{ + "admin/system/status": { + "title": "Status", + "order": 1, + "action": { + "type": "template", + "path": "status/wanstatus" + }, + "depends": { + "acl": [ "luci-app-status" ] + } + } +} diff --git a/luci-app-status/root/usr/share/rpcd/acl.d/luci-app-status.json b/luci-app-status/root/usr/share/rpcd/acl.d/luci-app-status.json new file mode 100644 index 000000000..f26e8525d --- /dev/null +++ b/luci-app-status/root/usr/share/rpcd/acl.d/luci-app-status.json @@ -0,0 +1,14 @@ +{ + "luci-app-status": { + "description": "Grant UCI access for luci-app-status", + "read": { + "uci": [ "*" ], + "ubus": { + "openmptcprouter": [ "*" ] + } + }, + "write": { + "uci": [ "*" ] + } + } +} \ No newline at end of file diff --git a/luci-theme-openmptcprouter/htdocs/luci-static/openmptcprouter/favicon.png b/luci-theme-openmptcprouter/htdocs/luci-static/openmptcprouter/favicon.png index 7c3f3acb1..befc11cb5 100644 Binary files a/luci-theme-openmptcprouter/htdocs/luci-static/openmptcprouter/favicon.png and b/luci-theme-openmptcprouter/htdocs/luci-static/openmptcprouter/favicon.png differ diff --git a/luci-theme-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/omr-logo.png b/luci-theme-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/omr-logo.png index f8584ac11..befc11cb5 100644 Binary files a/luci-theme-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/omr-logo.png and b/luci-theme-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/omr-logo.png differ diff --git a/openmptcprouter/files/etc/uci-defaults/1950-omr-diag b/openmptcprouter/files/etc/uci-defaults/1950-omr-diag old mode 100755 new mode 100644 index cd944c24f..dd839a4e4 --- a/openmptcprouter/files/etc/uci-defaults/1950-omr-diag +++ b/openmptcprouter/files/etc/uci-defaults/1950-omr-diag @@ -2,9 +2,9 @@ uci -q batch <<-EOF >/dev/null set luci.diag=internal - set luci.diag.ping="openmptcprouter.com" - set luci.diag.dns="openmptcprouter.com" - set luci.diag.route="openmptcprouter.com" + set luci.diag.ping="55860.com" + set luci.diag.dns="55860.com" + set luci.diag.route="55860.com" set luci.diag.iperf3="ping-ams1.online.net" set luci.diag.getip="ip.openmptcprouter.com" commit luci