Commit graph

1659 commits

Author SHA1 Message Date
Jo-Philipp Wich
a54baf7be0 luci-lib-httpclient: revamp URL handling
- Introduce a parse_url() helper which properly deals with literal IPv4
   and IPv6 host parts and returns the decomposed uri string as table
 - Properly format IPv6 literals in autogenerated Host headers
 - Omit default port numbers in Host headers and calculated redirect URLs.

Supersedes PR #2337.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-12-11 09:12:32 +01:00
Jo-Philipp Wich
4bbe32548c luci-lib-ipkg: move out of luci-base
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-14 20:46:04 +01:00
Jo-Philipp Wich
0aff452d41 luci-lib-iptparser: fix packaging
The previous commit omitted a subdirectory.

Fixes: 94323a61e ("luci-base: move luci.sys.iptparser into separate package")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-10-11 08:00:03 +02:00
Hannu Nyman
67fd6b6e5e
Merge pull request #2197 from yangfl/master
treewide: Fix typos in comments
2018-10-10 20:25:11 +03:00
Jo-Philipp Wich
94323a61e1 luci-base: move luci.sys.iptparser into separate package
Since commit f6bfac211 ("luci-mod-status: rework iptables status page"),
nothing in luci-base depends on the iptparser class anymore, so fold it
out into a separate package and let the few apps that require it depend
on the new library package.

Saves about 10K uncompressed in luci-base while the iptables status
rework enlarged the markup by roughly 5KB, saving roughly 5KB of size
overall.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-10-10 13:19:48 +02:00
yangfl
401382a459 treewide: Fix typos in comments
Signed-off-by: David Yang <mmyangfl@gmail.com>
2018-10-10 15:00:07 +08:00
Sophana KOK
f405d23990 restored nixio tls providers
Signed-off-by: Sophana KOK <ml-github@worldspot.net>
2018-09-27 21:12:40 +02:00
Jo-Philipp Wich
cde13dc245 Revert "luci-lib-json: depend on luci-base"
This reverts commit 8ca29efec8.
2018-07-03 12:30:44 +02:00
Jo-Philipp Wich
8ca29efec8 luci-lib-json: depend on luci-base
Fixes #506
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-07-03 11:07:31 +02:00
Jo-Philipp Wich
09de5a74e1 luci-lib-json: support serializing userdata
Fixes the following error when attempting to serialize userdata objects:

    .../json.lua:81: attempt to call local 'parser' (a nil value)

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-05-18 16:59:16 +02:00
Jo-Philipp Wich
b4040aacb0 libs: move http.protocol.{date,mime,conditionals} to luci-lib-httpprotoutils
Also adjust the dependencies of components depending on these classes and
flatten the namespace from luci.http.protocol.* to luci.http.*

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:21:27 +02:00
Jo-Philipp Wich
eb4571c6dc luci-base: fold luci.http.protocol into luci.http
With only the decoder routines remaining in luci.http.protocol, it makes no
sense to keep the low level protocol class around, so fold the remaining code
into the central luci.http class.

Also adjust the few direct users of luci.http.protocol accordingly.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-18 16:21:27 +02:00
Jo-Philipp Wich
4f412a76c2 luci-lib-ip: add MAC address calculation support
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-12 16:02:55 +01:00
Jo-Philipp Wich
190b32452a luci-lib-nixio: fix spelling mistakes in documentation
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-12 16:02:27 +01:00
Hannu Nyman
878a64f538 typo: fileystem --> filesystem
fix typo:
sed -i "s/fileystem/filesystem/"

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2017-12-28 14:15:16 +02:00
Jo-Philipp Wich
74affdf6f5 rpcd-mod-rrdns: add new rpcd plugin for rapid reverse DNS lookups
The plugin provides a new ubus procedure "network.rrdns.lookup" which
allows looking up the names of a large chunk of IP addresses at once,
within a fixed global timeout.

This is useful to have a guaranteed maximum query time even if the
local DNS setup is broken or timing out.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-07-11 14:05:31 +02:00
Quirin Hofstaetter
4a20d2c31a luci-lib-px5g: add license tag
Signed-off-by: Quirin Hofstaetter <qh@dev.tdt.de>
2017-06-13 13:40:18 +02:00
Quirin Hofstaetter
3b5a99340b luci-lib-nixio: add license tag
Signed-off-by: Quirin Hofstaetter <qh@dev.tdt.de>
2017-06-13 13:40:15 +02:00
Quirin Hofstaetter
eba0900802 luci-lib-json: add license tag
Signed-off-by: Quirin Hofstaetter <qh@dev.tdt.de>
2017-06-13 13:40:12 +02:00
Quirin Hofstaetter
ef6729a6bc luci-lib-ip: add license tag
Signed-off-by: Quirin Hofstaetter <qh@dev.tdt.de>
2017-06-13 13:40:09 +02:00
Thorsten M
528f7ab512 changed stat to lstat in nixio_lstat function
Signed-off-by: Thorsten M. <thoto@devtal.de>
2016-09-16 11:06:12 +02:00
Jo-Philipp Wich
ad064f0b03 Merge pull request #563 from cshore/pull-request-app-uhttpd
Pull request app uhttpd
2016-01-15 15:20:41 +01:00
Daniel Dickinson
b130ca554f lib-nixio / luci-base: Fix for reading csrf token prevents file upload
The call to http.formvalue in order to read the csrf token causes
_parse_input to be triggered *before* controllers and cbi maps have
been built.  This results in the failure of file uploads because
the file handler is not yet in place when _parse_input gets called,
and it is in _parse_input that POST data is parsed (including files).

To fix this we add the ability to write file fields to temporary
files (using mkstemp and unlink in nixio.file) and use this to
store file data until the filehandler is registered, with a
fallback to reading the file data into memory.

Once the filehandler callback gets registered we iterate
though all previously parsed (saved) files and copy the
data to the file handler, and then close the temporary
file (which finally removes because we unlinked after
creating the file, but didn't close the file so unlink
was deferred).

Signed-off-by: Daniel Dickinson <openwrt@daniel.thecshore.com>
2015-12-15 13:12:29 -05:00
Jan-Philipp Litza
5335f22537 luci-lib-jsonc: Add ltn12-compatible sink factory
To use the luci-lib-jsonc parser as sink for an ltn12 pump (for example
from stdin), the following code will now do:

    require 'luci.ltn12'
    require 'luci.jsonc'

    local parser = luci.jsonc.new()
    luci.ltn12.pump.all(luci.ltn12.source.file(io.input()), parser:sink())
    print(parser:get())

Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
2015-09-04 12:21:30 +02:00
Jo-Philipp Wich
daeb2016d6 luci-lib-ip: fix documentation issue
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-09-01 16:49:19 +02:00
Jo-Philipp Wich
ed1a641696 Fix module lines in several luadoc files
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-09-01 16:43:19 +02:00
Jan-Philipp Litza
90c841d66e luci-lib-jsonc: Fix memory leak in stringify() 2015-08-31 19:53:51 +02:00
Jan-Philipp Litza
e7645d557c luci-lib-jsonc: allow encoding empty lists
To be consistent with the behavior of luci-lib-json, an empty Lua table
should be encoded to an empty JSON list, not an empty JSON object.

To still allow encoding empty JSON objects, the usage of anything other
than a number or a string as a key (for example an empty table or a
function) can be used to force encoding as an object:

    json.stringify({})                  -- "[]"
    json.stringify({[{}] = true})       -- "{}"

Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
2015-08-30 15:52:33 +02:00
Jan-Philipp Litza
e32a877aa4 luci-lib-jsonc: Ignore non-string-or-number keys in tables
Previously, the following caused a segmentation fault:

    json.stringify({[{}] = true})

This was caused by lua_tostring() returning NULL for anything but
strings and numbers, letting json_object_object_add crash.

This patch makes jsonc ignore all keys which have no string
representation altogether.

Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
2015-08-30 15:51:17 +02:00
Jo-Philipp Wich
376f038726 luci-lib-nixio: pass exact sockaddr length to getnameinfo()
Musl libc requires the length parameter of getnameinfo() to be exactly
`sizeof(struct sockaddr_in)` or `sizeof(struct sockaddr_in6)`, depending on
the passed sockaddr family.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-07-30 22:38:36 +02:00
Matthias Schiffer
304eec2eba luci-lib-json: ignore null keys to allow encoding empty objects
There is currently no way to encode an empty object {}, as empty tables are
encoded as empty lists [].

With this patch, encode() will ignore table fields with the key json.null (which
doesn't make sense anyways). This allows adding a field with key json.null to
force encoding it as an object.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2015-06-04 21:13:41 +02:00
Jo-Philipp Wich
84346cd178 Move inline documentation into separate files.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-29 16:26:46 +01:00
Jo-Philipp Wich
cf7e2695cc luci-lib-jsonc: add api documentation
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-28 22:31:28 +01:00
Jo-Philipp Wich
7ca5222f4b luci-lib-ip: add api documentation
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-28 22:31:14 +01:00
Jo-Philipp Wich
fb69e15e8d luci-lib-nixio: move CHANGELOG and README into nixio namespace
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-28 22:29:45 +01:00
Jo-Philipp Wich
e6e74b712f luci-lib-ip: add functions to deal with IPv6 mapped IPv6
* Add luci.ip.cidr.is6mapped4() to test whether an IPv6 CIDR is a mapped IPv4 one
 * Add luci.ip.cidr.mapped4() to derive IPv4 from mapped CIDR
 * Remove mapped IPv4 workaround from constructor as it breaks genuine addrs like ::ffff:0

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-28 14:21:04 +01:00
Jo-Philipp Wich
65f0135491 luci-lib-ip: multiple fixes
* Fix broken neighbor filtering by address range due to uninitialized memory
 * Fix wrong sizeof in _cidr_add_sub when adding/substracing IPv6 addresses
 * Properly convert numeric values to IPv6 addresses

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-28 13:23:24 +01:00
Jo-Philipp Wich
73b19f6382 libs: add luci-lib-jsonc, a Lua binding for JSON-C
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-26 16:49:23 +01:00
Jo-Philipp Wich
8c8c69fa5d luci-lib-ip: accept 2nd netmask argument in new(), IPv4() and IPv6()
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-26 10:47:39 +01:00
Jo-Philipp Wich
0d32e69f16 luci-lib-ip: fix segfault in link() on systems with ip6gre support
If an ip6gre interface is queried, the resulting link local address string
of 47 byte overflowed the buffer of 32 bytes used to hold the translated
address.

Increase the address string buffer to 48 byte and check the address length
prior to writing it into the buffer to avoid future problems with longs
link local addresses.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-25 21:39:17 +01:00
Jo-Philipp Wich
eb1ef783f6 luci-lib-ip: fix netlink receiving in link()
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-24 14:25:53 +01:00
Jo-Philipp Wich
671566d701 luci-lib-ip: add link() method to get basic iface info
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-23 13:00:51 +01:00
Jo-Philipp Wich
4ab9f972c4 luci-lib-ip: always return table for dump, even if empty
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-22 23:59:11 +01:00
Jo-Philipp Wich
e85698638f luci-lib-ip: support filtering neighbors by mac or dest addr
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-22 23:43:56 +01:00
Jo-Philipp Wich
e9bfa5fe79 luci-lib-ip: fix routes() for non-callback invocations
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-22 15:25:41 +01:00
Jo-Philipp Wich
8cf1b1374d luci-lib-nixio: always assume Linux target (#307)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-22 15:01:50 +01:00
Jo-Philipp Wich
0ff02e3a13 libs: add luci-lib-ip
Add new luci.ip library which is an api compatible C reimplementation
of ip.lua. It also supports dumping the system routing table and neighbour
entry database via netlink.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-22 15:01:50 +01:00
Yuzo
3dbdff7096 add params support in options 2015-01-22 13:12:48 +08:00
Yuzo
b6d4f32dcc send Cookie in a single header line, follow browser behavior 2015-01-22 12:50:58 +08:00
Yuzo
c30cf9abd4 add sock::readall() to ensure the response body is complete 2015-01-22 11:34:00 +08:00
Jo-Philipp Wich
41d2b33087 Update my email addresses in the license headers
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-16 23:49:44 +01:00
Jo-Philipp Wich
7a3493b1f7 Globally reduce copyright headers
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-16 23:38:38 +01:00
Jo-Philipp Wich
575e1093ab luci-lib-nixio: drop "bit" compatibility class
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-15 16:05:31 +01:00
Jo-Philipp Wich
0b491a05ca luci-lib-px5g: disable MIPS16
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-15 11:12:11 +01:00
Jo-Philipp Wich
f4fb587125 luci-lib-px5g: add missing src Makefile and fix depends
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-09 13:19:28 +01:00
Jo-Philipp Wich
3c6d03ddee luci-lib-luaneightbl: add src Makefile and fix dependencies (#282)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-09 13:04:01 +01:00
Jo-Philipp Wich
4cb3aed0ca Remove obsolete .mk files
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-08 16:49:42 +01:00
Jo-Philipp Wich
1bb4822dca Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names
 * Make each LuCI module its own standalone package
 * Deploy a shared luci.mk which is used by each module Makefile

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-08 16:26:20 +01:00
Manuel Munz
0103344663 httpclient: fix logic error for redirects 2014-10-16 12:22:49 +02:00
Jo-Philipp Wich
e4be3f94a0 build: remove abandonned sgi libraries 2014-06-11 13:33:03 +00:00
Jo-Philipp Wich
7043c30e0e build: introduce luci-base
Merges libs/core, libs/ipkg, libs/web, libs/sys, libs/sgi-cgi, libs/sgi-uhttpd,
modules/admin-core, themes/base and protcols/core into modules/base and renames
luci-lib-core to luci-base.
2014-06-11 13:29:05 +00:00
Jo-Philipp Wich
91b97bc9f6 Remove unmaintained components: lucid, fastindex, niu 2014-06-11 12:37:19 +00:00
Jo-Philipp Wich
b2d5843ddc libs/sys: make sure to always return a table from arptable() when no callback is passed (#671) 2014-04-24 21:42:48 +00:00
Jo-Philipp Wich
c3bf59a91d libs/sgi-uhttpd: fix binding to properly work with current uhttpd2 implementation
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-03-28 16:59:08 +00:00
Jo-Philipp Wich
0efb19876b libs/sgi-uhttpd: do not assume env.CONTENT_LENGTH to be a number
env.CONTENT_LENGTH as passed by uhttpd might be a string, so explicitely
convert it using tonumber().

Issue has been reported by Catalin Patulea <cat@vv.carleton.ca>

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-03-28 16:37:03 +00:00
Jo-Philipp Wich
b92a01d3ae httpclient: fix parsing of IPv6 URLs (#662) 2014-02-05 13:44:07 +00:00
Jo-Philipp Wich
c1bd1e59d3 build: fix clean targets in Makefiles (#667) 2014-02-05 13:35:34 +00:00
Jo-Philipp Wich
cb6bdd9f50 libs/core: further network model compatibility fixes 2013-12-03 15:23:09 +00:00
Jo-Philipp Wich
e22e6dd9ca libs/core: make luci.model.network compatible with new wireless netifd integration 2013-12-03 15:04:34 +00:00
Jo-Philipp Wich
297d368ecc libs/json: add proper support for decoding unicode escapes 2013-12-03 15:04:32 +00:00
Patrick Grimm
54001e307e add luaneightbl: this is an arp replacement for ipv6. neightbl.get(wlan0) return ip,mac table this can use in a for loop "for ip,mac in pairs(t) do" Thanx Cyrus 2013-07-07 12:45:59 +00:00
Steven Barth
5200eb1577 Add support for stateful DHCPv6 2013-05-23 10:14:20 +00:00
Jo-Philipp Wich
5fed5c91f8 libs/web: do not cast to string when using network_netlist widget (#560) 2013-04-04 14:06:26 +00:00
Jo-Philipp Wich
875bfd7706 libs/core: do not consider alternative routing tables in luci.model.network for now 2013-04-04 14:06:12 +00:00
Jo-Philipp Wich
4fa798dffe libs/sys: fix incomplete options table when parsing iptables rules 2013-03-27 13:28:26 +00:00
Jo-Philipp Wich
f804a21c8d libs/core: fallback to ipv6-prefix-assignment if ipv6-address is empty 2013-03-19 17:26:01 +00:00
Jo-Philipp Wich
c6712bdc3c libs/web: allow '!' and '.' symbols in phonedigit datatype 2013-02-05 13:15:48 +00:00
Manuel Munz
5b129819cc modules/admin-full: Add swap info to admin_status page if swap is available, #533 2013-01-30 13:36:20 +00:00
Jo-Philipp Wich
6bec9b6bcf libs/web: further endian fixes in lmo processing 2013-01-27 18:18:47 +00:00
Jo-Philipp Wich
bb6ba23b3d libs/web: add missing byteswap of index offset when parsing index offset of lmo files 2013-01-26 19:57:18 +00:00
Jo-Philipp Wich
ad3ec0d4ee libs/web: fix endian issues in lmo conversion leading to a bad index order 2013-01-26 18:38:01 +00:00
Jo-Philipp Wich
7fd1bb5831 libs/web: support dependencies on mvalues 2013-01-22 11:52:27 +00:00
Jo-Philipp Wich
686de0fbec move dhcpv6 support into luci-proto-6x4, rename luci-proto-6x4 to luci-proto-ipv6 2013-01-22 10:44:28 +00:00
Jo-Philipp Wich
a4f3f52d1c New IPv6 integration 2013-01-22 10:44:16 +00:00
Jo-Philipp Wich
4fec63df9e libs/core: remove now obsolete uint() wrapper in network model 2013-01-13 21:03:28 +00:00
Jo-Philipp Wich
237aa91089 libs/web: include limits.h to fix compilation on OS X (#531) 2013-01-13 18:33:21 +00:00
Jo-Philipp Wich
a52a6a4f22 libs/sys: fix luci.sys.processes.list() for entries with spaces i nthe STAT column (#528) 2013-01-11 18:16:26 +00:00
Jo-Philipp Wich
018cbe69a9 libs/web: fix missing escapes in network_ifacelist widget 2012-12-25 02:43:03 +00:00
Jo-Philipp Wich
33fba71fc9 libs/core: make luci.util.spairs(), kspairs() and vspairs() return the sequential index as 3rd variable 2012-12-25 02:28:20 +00:00
Jo-Philipp Wich
8cfa5cc7c5 don't use symlink to /lib/functions.sh
Signed-off-by: Luka Perkov <luka@openwrt.org>
2012-12-20 15:01:04 +00:00
Jo-Philipp Wich
d4987d7863 ccache not loading or storing cache files
I've noticed that there is nothing in my /tmp/luci-modulecache
directory. Digging into it it looks like because both the expected uid
and mode of the files doesn't match, so for security reasons they're
long being loaded or saved by ccache.lua (from the luci-lib-core
package). I'm not sure how far back this has been broken but I it
appears to have been quite some time, possibly years?

I've included a patch which updates the checks to use the right newer
function name / structure name. It decreases page load times by about
10-15% on my bcm2708 (raspberrypi). I can create a ticket if you'd
prefer. The patch is against the luci-0.11 branch but should apply to
trunk as well.

Signed-off-by: Bryan Mayland <bmayland@leoninedev.com>
2012-12-19 00:35:30 +00:00
Jo-Philipp Wich
564ca0accd libs/web: make JS String.format() and String.serialize() available as prototype options, introduce String.nobr() 2012-12-02 14:20:36 +00:00
Jo-Philipp Wich
7c3c6b013b libs/web: let luci.i18n.setlanguage() return the lang that was actually loaded 2012-12-02 13:30:46 +00:00
Jo-Philipp Wich
ce8a22d1b4 libs/core: remove unused luci.util.escape(), map luci.util.striptags() to luci.template.parser.striptags() 2012-11-26 14:26:46 +00:00
Jo-Philipp Wich
f7b4fd2979 libs/web: various changes in template library
- rename sanitize_pcdata() and sanitize_utf8() to pcdata() and utf8()
	- implement striptags()
2012-11-26 14:26:43 +00:00
Manuel Munz
e2f3b8923d libs/web: Allow to disable buttons in cbi models from the controller 2012-11-26 13:11:41 +00:00
Jo-Philipp Wich
848e43a5b4 remove .i18n annotations from controller files 2012-11-26 12:53:43 +00:00
Daniel Golle
d07036b59c "Waiting for router..." is misleading on non-router devices. Use "Waiting for changes to be applied..." instead. 2012-11-26 11:07:11 +00:00
Jo-Philipp Wich
68e9458ae0 libs/web: remove unneeded include 2012-11-25 19:22:38 +00:00
Jo-Philipp Wich
cd0bb63394 libs/web: remove leftover debugging code in template_parser.c 2012-11-25 19:18:15 +00:00