summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/model
AgeCommit message (Collapse)Author
2019-09-13WIP from 2018-11-28multiplipv6prefixesMikael Magnusson
2018-11-14Merge pull request #2259 from pmelange/luci-app-olsr-new-json-libJo-Philipp Wich
update luci-app-olsr to the new jsoninfo library
2018-11-14luci-lib-ipkg: move out of luci-baseJo-Philipp Wich
Move the old luci.model.ipkg utility class into a separate package and let the components using it depend on the new library package. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-07luci-base: network.lua add ipv6-prefix-assignment support to ↵pmelange
get_status_by_address Signed-off-by: pmelange <isprotejesvalkata@gmail.com>
2018-11-05luci-base: validate DHCP clientid as hexstringJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-10-10treewide: Fix typos in commentsyangfl
Signed-off-by: David Yang <mmyangfl@gmail.com>
2018-09-19luci-base: Show multiple upstream interfaceKristian Evensen
Several devices have multiple upstream interfaces, for example a fixed and a mobile broadband connection. Currently, only one upstream interface is shown per address family in Luci. So in my example, one of the interfaces would not appear on the Status-page. This PR introduces support for showing multiple upstream interfaces on the Status-page. The code is not very complicated. get_status_by_route() has been extended to return a list of all routes, and get_wannet()/get_wan6net() now returns all upstream interfaces. I could not find any other (active) users of these three functions than calls triggered from the Status-page, so changing the default behavior should be fine. get_wandev()/get_wan6dev() called get_status_by_route(), but I could not find any place where those functions were called. I removed the dev-functions instead of keeping the old get_status_by_route(). On the status page, the wan/wan6-variables have been replaced with arrays. When populating the html, we now iterate through these arrays and create one element for each interface. I have tested the code with different interface types, v4, v6, as well as disconnecting and connecting interfaces. The status is updated and the correct interfaces (or sometimes none at all) are shown. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-08-13treewide: rework uci change displayJo-Philipp Wich
- Use native rpcd uci changes format instead of incompletely converting back and forth between the old and the new format - Rework uci changelog template to print the equivalent uci commands for the various changes - Rework theme headers to properly count the uncomitted changes - Rework theme CSS to properly style new changelog Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-27treewide: rework rollback/apply workflowJo-Philipp Wich
Rework the apply confirmation mechanism to be session agnostic in order to circumvent cross domain restrictions which prevent the JS code from issuing apply confirm requests in some cases, e.g. when changing the LAN IP. Confirmation calls may now be done from unauthenticated pages, as long as a matching confirmation token is sent along with the request. The reasoning behind this is that there is little security impact in confirming pending apply sessions, especially since those sessions can only be initiated while being authenticated. After this change, LuCI will now launch a confirmation process on every rendered page when a rollback is pending. The confirmation will happen regardless of whether the user is logged in or not, or if the current page is a CBI form or static template. A confirmation request now also requires a random one-time token which is rendered along with the confirmation JavaScript code in order to succeed. This token is not meant to provide security but to ensure that the confirm was triggered from an interactive browser session and not some background HTTP requests that happened to end up in the admin ui. As a consequence, the different apply/confirm/rollback code paths in CBI maps and the UCI change/revert pages have been consolidated into one common implementation residing in the common global theme agnostic footer template. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-15luci-base: luci.model.network: recognize alias interfacesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-12luci-base: add error reporting and basic support for dynamic interfacesJo-Philipp Wich
This allows exposing virtual ubus-based network interfaces in LuCI. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-06-06luci-base: fix some minor luci.model.uci issuesJo-Philipp Wich
- Properly serialize option delete changelogs - Do not perform a section create if a nil value is passed to set() Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-19luci-base: handle potential crash in luci.model.network.interface.get_i18n()Jo-Philipp Wich
Should prevent the crash mentioned in #1779. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-19luci-base: break circular luci.config <> luci.model.uci dependencyJo-Philipp Wich
On certain environments, mainly with the embedded uhttpd interpreter, the luci.config class cannot be loaded due to a circular dependency with the luci.model.uci class. Break up the dependency by deferring the loading of luci.config in luci.model.uci until it is actually needed. Fixes #1803, FS#1553. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-18Merge pull request #1769 from jow-/masterJo-Philipp Wich
UCI apply/rollback workflow
2018-05-05treewide: rework uci apply workflowJo-Philipp Wich
Switch to rpcd based uci apply/rollback workflow which helps to avoid soft- bricking devices by requiring an explicit confirmation call after config apply. When a user now clicks "Save & Apply", LuCI first issues a call to uci apply which commits and reloads configuration, then goes into a polling countdown mode where it repeatedly attempts to call uci confirm. If the committed configuration is sane, the confirm call will go through and cancel rpcd's pending rollback timer. If the configuration change leads to a loss of connectivity (e.g. due to bad firewall rules or similar), the rollback mechanism will kick in after the timeout and revert configuration files and pending changes to the pre-apply state. In order to cover such rare cases where a lost of connectivity is expected and desired, the user is offered an "unchecked" apply option after timing out, which allows committing and applying the changes anyway, without the extra safety checks. As a consequence of this change, the luci-reload mechanism is now completely unsused since rpcd uses ubus config reload signals to reload affected services, which means that only procd-enabled services will receive proper reload treatment with the new workflow. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-05luci-base: show wifi chip identification on overviewHannu Nyman
Show the correct wifi chip identification in case iwinfo recognises the chip. So far the wifidev.get_i18n function has practically always returned just "Generic", but use iwinfo.hardware_name to fetch the name. In case iwinfo returns the default "Generic MAC80211", there is a double 80211 in the final string, which is a cosmetic bug. Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-04-19luci-base: implement session handling in luci.model.uciJo-Philipp Wich
Introduce luci.model.uci.set_session_id() and luci.model.uci.get_session_id() to set and get the effective session ID respectively. When a session ID is set, it is sent as `ubus_rpc_session` attribute to rpcd, causing it to use per-session change directories, isolating LuCI changes from the global system uci state. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-07luci-base: fix luci.model.uci.get_first()Jo-Philipp Wich
Properly propagate the config parameter to the foreach iterator in order to fix get_first() lookups. Fixes #1734. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-06luci-base: implement luci.model.uci.get_state()Jo-Philipp Wich
Introduce a get_state() function which can be used to access legacy uci state variables. This is usually not needed anymore but some packages (mainly mwan3) still rely on this. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-05Merge pull request #1709 from dibdot/get_interface-fixJo-Philipp Wich
luci-base/network.lua: fix get_interface function
2018-04-05treewide: filter shell arguments through shellquote() where applicableJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-04luci-base: switch to ubus uci operationsJo-Philipp Wich
Switch luci.model.uci to use ubus uci calls instead of driving libuci-lua directly. This prepares support for more advanced features such as per-session change isolation and configuration rollback on errors. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-31luci-base/network.lua: fix get_interface functionDirk Brenken
* fix wrong private function call to handle section id as parameter (fix for #1687) Signed-off-by: Dirk Brenken <dev@brenken.org>
2018-03-12treewide: unify mac address handlingJo-Philipp Wich
Use the new luci.ip MAC address facilities to parse and verify MAC addresses in a common way, instead of relying on various ad-hoc solutions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-02luci-base: properly handle undefined IPv6 local-address informationJo-Philipp Wich
If IPv6 prefix assignment is disabled, the "local-address" structure might exist, but be empty which causes the adress formatting in the network model class to bail out. Verify the completeness of the "local-address" structure before using it in order to avoid runtime errors. Fixes #1657. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-02luci-base, luci-mod-admin-full: store backup vars in luci configurationJo-Philipp Wich
Keep the ifname and bridge state backup variables in /etc/config/luci to not pollute /etc/config/network. Fixes #1655. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-02-16luci-base: do not assume a fixed host address in delegated prefix (#1484)Jo-Philipp Wich
OpenWrt/LEDE introduced the "local-address" field a while back to expose the effective local host address of the delegated prefix, so use that information instead of assuming `[prefix]:1`. Fixes #1484. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-01-02luci-base: reorder private functionsJo-Philipp Wich
The _wifi_sid_by_ifname() function depends on _wifi_state_by_ifname() so reorder the private helper functions accordingly to avoid nil value call attempts. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-01-02luci-base: rework wireless state handling (#1179)Jo-Philipp Wich
- fix mapping of ubus wireless state to uci declared vifs - fix leaking foreign vif info into per-phy iwinfo stats Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-10-17luci-base: gracefully handle broken firewall forwarding sectionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-05-21luci-base: support ip6ifaceid option for proto_staticHannu Nyman
Add support for 'ip6ifaceid' option for proto_static in LuCI. Information about the option: The option is optional and defaults to '::1'. Allowed values: 'eui64', 'random', fixed value like '::1' or '::1:2' When IPv6 prefix (like 'a:b:c:d::') is received from a delegating server, the ip6ifaceid suffix (like '::1') is used to form the IPv6 address ('a:b:c:d::1') for the interface. Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2017-02-28treewide: cleanup references to madwifi from LuCIHannu Nyman
Remove the code related to the deprecated madwifi driver. Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2017-01-28mod-admin-full: Add IPv6 Prefix Delegation information to Status PagesCody R. Brown
The Overview page and Network>Interfaces page currently do not give much information about IPv6, particularly with Prefix Delegated setups. In these setups, ISP will delegate a prefix to the router. Currently LuCI doesn't display this Prefix Delegation from the ISP anywhere. A number of changes was added to this commit: 1) self:_ubus("ipv6-prefix") was extracted and put into protocol.ip6prefix. 2) Network>Interfaces page, if a .ip6prefix is present, show it under Status. (IPv6-PD). 3) On the Overview page, "Type" and "Prefix Delegated" has been added to the IPv6 Network Overview Status: - Type will display the .proto, similar to the IPv4 case. If a .ip6prefix is present, it'll display a "-pd" at the end of the Type: i.e. dhcpv6-pd vs. dhcpv6. - If no .ip6prefix is present, it'll do what it does currently, and just show Address, or :: if no address is present. - If .ip6prefix is present, it'll show the "Prefix Delegated", it'll also hide "Address" if no address is present, else it'll show ifc6.ip6addr as well. Signed-off-by: Cody R. Brown <dev@codybrown.ca>
2016-08-15luci-base: support reading switch topology from /etc/board.jsonJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-08-04luci-base: fix handling of monitor ifacesJo-Philipp Wich
Wireless monitor interfaces usually have no SSID set in their config and various network model utility functions did not handle this case properly, mainly while trying to incorperate the SSID string into various description labels. Fall back to the internal network id (radioX.networkY) in cases where neither the SSID nor the BSSID are available. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-04-26luci-base: fix syntax error in luci.model.networkJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-04-26luci-base: add more ignore patterns to luci.model.networkJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-04-26luci-base: fix luci.model.network.ignore_interface()Jo-Philipp Wich
Fix the underlying _iface_ignore() function to not ignore virtual interfaces, in order to let ignore_interface() return true for PPP and similar devices. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2016-04-01Update network.luaOskari Rauta
Fix display of WAN status when WAN is provided by using WWAN device or similar with other similar similar methods. Explanation: Before this, protocol was fetched from /etc/config/network for interface which often is wan_4 - but protocol is configured in file as wan, and therefore protocol is always none, since configuration is made for wan and then setup as wan_4 and possibly wan_6 if ipv6 is being used. This commit uses ubus to get used active protocol. For example, in case of qmi, it displays protocol as dhcp since even if I configured wan to use qmi, dhcp was used as a protocol for getting IP address.
2015-12-17Merge pull request #464 from remakeelectric/pulls/list-operationsJo-Philipp Wich
get/set list operations and documentation
2015-11-21luci-base: use board.json to infer switch netdevJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-11-17luci-base: eliminate use of uci state vars in luci.model.networkJo-Philipp Wich
Also implement :ipaddrs() and :ip6addrs() helper for network instances. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-11-16luci-base: fix uci documentation issue (#538)Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-10-20luci-base: filter invalid opkg status linesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-09-16Luci opkg/packages: Show package size in list of available packagesHannu Nyman
Add package *.ipk size information to package listing in Luci, as opkg was today extended to support listing also the size information. Visible fields are now: name, version, size, description That will help users considering installation of a certain package to assess its size impact on flash. Note: Opkg data includes the size of the .ipk file, not the expanded size. Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2015-09-02uci:get_list: always return a table, no matter what.Karl Palsson
Previously, get_list("fake", "non-existent", "notreal") would still return a table, just empty. This is nice, as you can always iterate the returned table, without having to check it first. However, if you happened to pass a nil for any of the parameters, you would actually get a nil in return. This was inconsistent. The documentation is updated to clarify the behaviour of this function. Signed-off-by: Karl Palsson <karlp@remake.is>
2015-09-02uci:set_list: Delete option if the list is emptyKarl Palsson
Allows lists fetched with get_list to be modified and simply passed back to set_list. Explicitly calling set_list() with an empty list is clearly requesting that there be zero list items, ie, deletion of the option altogether. Signed-off-by: Karl Palsson <karlp@remake.is>
2015-09-01Luci opkg/packages: Limit version string display to 26 charsHannu Nyman
Many packages currently include a git commit hash in version string. That makes versions string very long and the version column takes much space when listing available/installed packages in Luci. Longest version string is 58 characters (micropython). 85 packages have at least 50 chars and 150 packages at least 40 chars. Adjust Luci to display max. 26 characters (= luci's own version string). Longer version strings are cut to: "first 21c" + ".." + "last 3c" The last 3 chars are used to preserve the possible PKG_REVISION string. E.g. 'opkg' has only hash+PKG_REVISION, so using only start of the string might not be optimal. Examples: 1.3.10-20150302-f2a889564b3a215902622b040a1247af38cb8203-1 1.3.10-20150302-f2a88..3-1 0.1-20150302-654c7d288603f7dae09eb09b57fb67b38c7ac6c3-1 0.1-20150302-654c7d28..3-1 9c97d5ecd795709c8584e972bfdf3aee3a5b846d-7 9c97d5ecd795709c8584e..d-7 Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2015-09-01Fix module lines in several luadoc filesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>