summaryrefslogtreecommitdiffhomepage
path: root/src/conf.c
AgeCommit message (Collapse)Author
2020-11-10WIP: BindIPv6MappedMikael Magnusson
2020-11-07WIP: BindIPv4MappedMikael Magnusson
2020-10-19Allow multiple Bind directives.Anton Khirnov
Try all the addresses specified with Bind in order. This is necessary e.g. for maintaining IPv4+6 connectivity while still being restricted to one interface.
2020-10-01conf: move inclusion of common.h back to the startrofl0r
otherwise the feature-test-macros won't kick in as they should. should fix #329
2020-09-30conf: only treat space and tab as whitespacerofl0r
other characters in the [[:space:]] set can't possibly be encountered, and this speeds up parsing by approximately 10%.
2020-09-30conf: use [0-9] instead of [[:digit:]] for shorter re stringsrofl0r
2020-09-30print linenumber from all conf-emitted warningsrofl0r
2020-09-30conf: remove bogus support for hex literalsrofl0r
the INT regex macro supported a 0x prefix (used e.g. for port numbers), however following that, only digits were accepted, and not the full range of hexdigits. it's unlikely this was used, so remove it. note that the () expression is kept, so we don't have to adjust match number indices all over the place.
2020-09-30speed up build by only including regex.h where neededrofl0r
2020-09-16speed up big config parsing by 2x using gperfrofl0r
2020-09-16conf.c: simplify the huge IPV6 regexrofl0r
even though the existing IPV6 regex caught (almost?) all invalid ipv6 addresses, it did so with a huge performance penalty. parsing a file with 32K allow or deny statement took 30 secs in a test setup, after this change less than 3. the new regex is sufficient to recognize all valid ipv6 addresses, and hands down the responsibility to detect corner cases to the system's inet_pton() function, which is e.g. called from insert_acl(), which now causes a warning to be printed in the log if a seemingly valid address is in fact invalid. the new regex has been tested with 486 testcases from http://download.dartware.com/thirdparty/test-ipv6-regex.pl and accepts all valid ones and rejects most of the invalid ones. note that the IPV4 regex already did a similar thing and checked only whether the ip looks like [0-9]+.[0-9]+.[0-9]+.[0-9]+ without pedantry.
2020-09-16conf.c: warn when encountering invalid addressrofl0r
2020-09-16conf: use cpp stringification for STDCONF macrorofl0r
2020-09-16conf: merge upstream/upstream_none into single regex/handlerrofl0r
2020-09-16move config reload message to reload_config()rofl0r
move it to before disabling logging, so a message with the correct timestamp is printed if logging was already enabled. also add a message when loading finished, so one can see from the timestamp how long it took. note that this only works on a real config reload triggered by SIGHUP/SIGUSR1, because on startup we don't know yet where to log to.
2020-09-16listen_addrs: use sblistrofl0r
2020-09-16basicauth: use sblistrofl0r
2020-09-16add_header: use sblistrofl0r
note that the old code inserted added headers at the beginning of the list, reasoning unknown. this seems counter-intuitive as the headers would end up in the request in the reverse order they were added, but this was irrelevant, as the headers were originally first put into the hashmap hashofheaders before sending it to the client. since the hashmap didn't preserve ordering, the headers would appear in random order anyway.
2020-09-15replace leftover users of hashmap with htabrofl0r
also fixes a bug where the ErrorFile directive would create a new hashmap on every added item, effectively allowing only the use of the last specified errornumber, and producing memory leaks on each config reload.
2020-09-15fix free()ing of config itemsrofl0r
- we need to free the config after it has been succesfully loaded, not unconditionally before reloading. - we also need to free them before exiting from the main program to have clean valgrind output.
2020-09-14conf.c: include common.hrofl0r
2020-09-12add_new_errorpage(): fix segfault accessing global configrofl0r
another fallout of the config refactoring finished by 2e02dce0c3de4a231f74b44c34647406de507768. apparently no one using the ErrorFile directive used git master during the last months, as there have been no reports about this issue.
2020-09-07change loglevel of start/stop/reload messages to NOTICErofl0r
this allows to see them when the verbose INFO loglevel is not desired. closes #78
2020-09-07config parser: increase possible line length limitrofl0r
let's use POSIX LINE_MAX (usually 4KB) instead of 1KB. closes #226
2020-03-16anonymous: fix segfault loading config itemrofl0r
unlike other functions called from the config parser code, anonymous_insert() accesses the global config variable rather than passing it as an argument. however the global variable is only set after successful loading of the entire config. we fix this by adding a conf argument to each anonymous_* function, passing the global pointer in calls done from outside the config parser. fixes #292
2020-01-15conf: fix loading of default valuesrofl0r
previously, default values were stored once into a static struct, then on each reload item by item copied manually into a "new" config struct. this has proven to be errorprone, as additions in one of the 2 locations were not propagated to the second one, apart from being simply a lot of gratuitous code. we now simply load the default values directly into the config struct to be used on each reload. closes #283
2020-01-15remove config file name item from conf structrofl0r
since this is set via command line, we can deal with it easily from where it is actually needed.
2020-01-15remove godaemon member from config structurerofl0r
since this option can't be set via config file, it makes sense to factor it out and use it only where strictly needed, e.g. in startup code.
2020-01-15move initialize_config_defaults to conf.crofl0r
2019-12-21conf.c: merely warn on encountering recently obsoleted config itemsrofl0r
if we don't handle these gracefully, pretty much every existing config file will fail with an error, which is probably not very friendly. the obsoleted config items can be made hard errors after the next release.
2019-12-21conf.c: pass lineno to handler funcsrofl0r
2019-12-21simplify codebase by using one thread/conn, instead of preforked procsrofl0r
the existing codebase used an elaborate and complex approach for its parallelism: 5 different config file options, namely - MaxClients - MinSpareServers - MaxSpareServers - StartServers - MaxRequestsPerChild were used to steer how (and how many) parallel processes tinyproxy would spin up at start, how many processes at each point needed to be idle, etc. it seems all preforked processes would listen on the server port and compete with each other about who would get assigned the new incoming connections. since some data needs to be shared across those processes, a half- baked "shared memory" implementation was provided for this purpose. that implementation used to use files in the filesystem, and since it had a big FIXME comment, the author was well aware of how hackish that approach was. this entire complexity is now removed. the main thread enters a loop which polls on the listening fds, then spins up a new thread per connection, until the maximum number of connections (MaxClients) is hit. this is the only of the 5 config options left after this cleanup. since threads share the same address space, the code necessary for shared memory access has been removed. this means that the other 4 mentioned config option will now produce a parse error, when encountered. currently each thread uses a hardcoded default of 256KB per thread for the thread stack size, which is quite lavish and should be sufficient for even the worst C libraries, but people may want to tweak this value to the bare minimum, thus we may provide a new config option for this purpose in the future. i suspect that on heavily optimized C libraries such a musl, a stack size of 8-16 KB per thread could be sufficient. since the existing list implementation in vector.c did not provide a way to remove a single item from an existing list, i added my own list implementation from my libulz library which offers this functionality, rather than trying to add an ad-hoc, and perhaps buggy implementation to the vector_t list code. the sblist code is contained in an 80 line C file and as simple as it can get, while offering good performance and is proven bugfree due to years of use in other projects.
2018-11-23Basic Auth: allow almost all possible characters for user/passVasily
previously was restricted to alphanumeric chars only.
2018-02-27make bind option usable with transparent proxy toorofl0r
closes #15 for real. the previous patch that was merged[0] was halfbaked and only removed the warning part of the original patch from openwrt[1], but didn't actually activate bind support. further it invoked UB by removing the return value from the function, if transparent proxy support was compiled in. [0]: d97d486d53ce214ae952378308292f333b8c7a36 [1]: https://gitlab.labs.nic.cz/turris/openwrt-packages/commit/7c01da4a72e6f0b7613a86529547659ea4007eba
2018-02-25config: unify upstream syntax for http,socks4,socks5 and nonerofl0r
closes #50
2018-02-25rename members of proxy_type enum to have a common prefixrofl0r
and add a NONE member.
2018-02-25implement HTTP basic auth for upstream proxiesrofl0r
loosely based on @valenbg1's code from PR #38 closes #38 closes #96
2018-02-23Remove #ifdef for HAVE_SYSLOG_HJohn Weldon
- syslog.h is a standard posix header, this #ifdef is an artifact accidentally left in.
2018-02-06add support for basic HTTP authenticationrofl0r
using the "BasicAuth" keyword in tinyproxy.conf. base64 code was written by myself and taken from my own library "libulz". for this purpose it is relicensed under the usual terms of the tinyproxy license.
2018-02-06add SOCKS upstream proxy support (socks4/socks5)Gonzalo Tornaria
original patch submitted in 2006 to debian mailing list: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=392848%29#12 this version was rebased to git and updated by Russ Dill <russ.dill@gmail.com> in 2015 (the original patch used a different config file format). as discussed in #40. commit message by @rofl0r.
2017-11-16Issue 15 fix. PRPablo Panero
2013-11-22conf: Fix CID 1130973 - resource leak.Michael Adam
Found by coverity. Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09[BB#63] conf: Allow multiple Listen statements in the config.Michael Adam
This introduces a list (vector) of addresses instead of having just one address string. Signed-off-by: Michael Adam <obnox@samba.org>
2011-03-04Validate port number specified in Port directiveMukund Sivaraman
This was asked in bug #90 comment #8.
2010-08-24[BB#91] Fix upstream proxy support.Michael Adam
Patch by Jordi Mallach.
2010-06-01[BB#89] Don't recompile regular expressionsJohn van der Kamp
This is a modification of a patch originally written by John van der Kamp <john@kirika.demon.nl> at <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579427#12> The modification was done by the committer.
2010-01-25Fix compiler warning about dereferencing type-punned pointersMukund Sivaraman
2010-01-16conf: reduce indentation in load_config_file()Michael Adam
This replaces a do { ... } while (0) with break statements ba gotos. Imho, this is much clearer. Michael
2010-01-16Fix leak of file handle in load_config_file()Mukund Sivaraman
2010-01-08[BB#17] Add custom HTTP request headers to outgoing HTTP requestsMukund Sivaraman