Commit Graph

1068 Commits

Author SHA1 Message Date
rofl0r
960972865c print linenumber from all conf-emitted warnings 2020-09-30 05:21:26 +01:00
rofl0r
f55c46eb39 log: print timestamps with millisecond precision
this allows easier time measurements for benchmarks.
2020-09-30 05:20:09 +01:00
rofl0r
10494cab8c change loglevel of "Not running as root" message to INFO
there's no reason to display this as warning.
2020-09-30 05:19:16 +01:00
rofl0r
4f1a1663ff conf: remove bogus support for hex literals
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-30 05:14:57 +01:00
rofl0r
35c8edcf73 speed up build by only including regex.h where needed 2020-09-30 05:13:45 +01:00
rofl0r
8594e9b8cc add conf-tokens.gperf to EXTRA_DIST
otherwise it will be missing in `make dist`-generated tarballs.
2020-09-27 15:55:23 +01:00
rofl0r
c74fe57262 transparent: workaround old glibc bug on RHEL7
it's been reported[0] that RHEL7 fails to properly set the length
parameter of the getsockname() call to the length of the required
struct sockaddr type, and always returns the length passed if it
is big enough.

the SOCKADDR_UNION_* macros originate from my microsocks[1] project,
and facilitate handling of the sockaddr mess without nasty casts.

[0]: https://github.com/tinyproxy/tinyproxy/issues/45#issuecomment-694594990
[1]: https://github.com/rofl0r/microsocks
2020-09-18 12:12:14 +01:00
rofl0r
d4ef2cfa62 child_kill_children(): use method that actually works
it turned out that close()ing an fd behind the back of a thread
doesn't actually cause blocking operations to get a read/write event,
because the fd will stay valid to in-progress operations.
2020-09-17 21:24:45 +01:00
rofl0r
da1bc1425d tune error messages to show select or poll depending on what is used 2020-09-17 21:03:51 +01:00
rofl0r
22e4898519 add autoconf test and fallback code for systems without gperf 2020-09-16 23:04:12 +01:00
rofl0r
45b238fc6f main: print error when config_init() fails 2020-09-16 21:01:02 +01:00
rofl0r
45323584a0 speed up big config parsing by 2x using gperf 2020-09-16 21:01:02 +01:00
rofl0r
caeab31fca conf.c: simplify the huge IPV6 regex
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-16 21:01:02 +01:00
rofl0r
0ad8904b40 acl.c: detect invalid ipv6 string 2020-09-16 21:00:50 +01:00
rofl0r
99ed66cbc4 conf.c: warn when encountering invalid address 2020-09-16 21:00:50 +01:00
rofl0r
880a8b0ab6 conf: use cpp stringification for STDCONF macro 2020-09-16 21:00:04 +01:00
rofl0r
551e914d24 conf: merge upstream/upstream_none into single regex/handler 2020-09-16 21:00:04 +01:00
rofl0r
bad36cd9cd move config reload message to reload_config()
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-16 21:00:04 +01:00
rofl0r
683a354196 remove vector remains 2020-09-16 02:39:09 +01:00
rofl0r
06c96761d5 log_message_storage: use sblist 2020-09-16 02:39:09 +01:00
rofl0r
e843519fb8 listen_addrs: use sblist 2020-09-16 02:39:09 +01:00
rofl0r
a5381223df basicauth: use sblist 2020-09-16 02:39:09 +01:00
rofl0r
487f2aba47 connect_ports: use sblist 2020-09-16 02:39:09 +01:00
rofl0r
e929e81a55 add_header: use sblist
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-16 02:39:09 +01:00
rofl0r
7d33fc8e8a listen_fds: use sblist 2020-09-16 01:05:58 +01:00
rofl0r
2037bc64f5 free a mem leak by statically allocating global statsbuf 2020-09-15 23:28:33 +01:00
rofl0r
d453a4c2a4 main: include loop header 2020-09-15 23:20:14 +01:00
rofl0r
192f8194e1 free() loop records too 2020-09-15 23:12:00 +01:00
rofl0r
bd92446184 use poll() where available 2020-09-15 23:12:00 +01:00
rofl0r
10cdee3bc5 prepare transition to poll()
usage of select() is inefficient (because a huge fd_set array has to
be initialized on each call) and insecure (because an fd >= FD_SETSIZE
will cause out-of-bounds accesses using the FD_*SET macros, and a system
can be set up to allow more than that number of fds using ulimit).
for the moment we prepared a poll-like wrapper that still runs select()
to test for regressions, and so we have fallback code for systems without
poll().
2020-09-15 23:12:00 +01:00
rofl0r
0c8275a90e refactor conns.[ch], put conn_s into child struct
this allows to access the conn member from the main thread handling
the childs, plus simplifies the code.
2020-09-15 23:12:00 +01:00
rofl0r
5779ba8697 hsearch: add seed to prevent another CVE-2012-3505 instance 2020-09-15 23:12:00 +01:00
rofl0r
155bfbbe87 replace leftover users of hashmap with htab
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-15 23:12:00 +01:00
rofl0r
34a8b28414 save headers in an ordered dictionary
due to the usage of a hashmap to store headers, when relaying them
to the other side the order was not prevented.
even though correct from a standards point-of-view, this caused
issues with various programs, and it allows to fingerprint the use
of tinyproxy.

to implement this, i imported the MIT-licensed hsearch.[ch] from
https://github.com/rofl0r/htab which was originally taken from
musl libc. it's a simple and efficient hashtable implementation
with far better performance characteristic than the one previously
used by tinyproxy. additionally it has an API much more well-suited
for this purpose.

orderedmap.[ch] was implemented from scratch to address this issue.
behind the scenes it uses an sblist to store string values, and a htab
to store keys and the indices into the sblist.
this allows us to iterate linearly over the sblist and then find the
corresponding key in the hash table, so the headers can be reproduced
in the order they were received.

closes #73
2020-09-15 23:11:59 +01:00
rofl0r
9d5ee85c3e fix free()ing of config items
- 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-15 23:11:59 +01:00
rofl0r
372d7ff824 shutdown: free children from right place 2020-09-15 22:32:42 +01:00
rofl0r
2f3a3828ac Revert "childs.c: fix minor memory leak"
This reverts commit 6dd3806f7d.
2020-09-15 22:25:53 +01:00
rofl0r
6dd3806f7d childs.c: fix minor memory leak
this would leak only once on program termination, so it's no big
deal apart from having spurious reachable memory in valgrind logs.
2020-09-15 20:02:12 +01:00
rofl0r
7eb6600aeb main: orderly shutdown on SIGINT too
the appropriate code in the signal handler was already set up,
but for some reason the signal itself not being handled.
2020-09-14 20:59:02 +01:00
rofl0r
ff23f3249b conf.c: include common.h 2020-09-14 17:02:36 +01:00
rofl0r
c64ac9edbe fix get_request_entity()
get_request_entity()'s purpose is to drain remaining unread bytes
in the request read pipe before handing out an error page,
and kinda surprisingly, also when connection to the stathost is
done.

in the stathost case tinyproxy just skipped proper processing and
jumped to the error handler code, and remembering whether a
connection to the stathost was desired in a variable, then doing
things a bit differently depending on whether it's set.

i tried to fix issues with get_request_entity in
88153e944f (which is basically the
right fix for the issue it tried to solve, but incomplete),
and resulting from there in 78cc5b72b1.
the latter fix wasn't quite right since we're not supposed to check
whether the socket is ready for writing, and having a return value
of 2 instead of 1 got resulted in some of the if statements not
kicking in when they should have.
this also resulted in the stathost page no longer working.

after in-depth study of the issue i realized that we only need to
call get_request_entity() when the headers aren't completely read,
additional to setting the proper connection timeout as
88153e944f already implemented.
the changes of 78cc5b72b1 have been
reverted.
2020-09-13 00:37:19 +01:00
rofl0r
4847d8cdb3 add_new_errorpage(): fix segfault accessing global config
another fallout of the config refactoring finished by
2e02dce0c3.

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-12 21:38:04 +01:00
rofl0r
df9074db6e vector.h: missing include <unistd.h> for ssize_t 2020-09-12 15:56:36 +01:00
rofl0r
9e40f8311f handle_connection(): print process_*_headers errno information 2020-09-10 21:13:31 +01:00
rofl0r
f1bd259e6e handle_connection: replace "goto fail" with func call
this allows to see in a backtrace from where the error was
triggered.
2020-09-10 14:48:39 +01:00
rofl0r
e94cbdb3a5 handle_connection(): factor out failure code
this allows us in a next step to replace goto fail with a call to that
function, so we can see in a backtrace from where the failure was
triggered.
2020-09-10 14:37:56 +01:00
rofl0r
b549ba5af3 remove bogus custom timeout handling code
in networking, hitting a timeout requires that *nothing* happens during the
interval. whenever anything happens, the timeout is reset.
there's no need to do custom time calculations, it's perfectly fine to let
the kernel handle it using the select() syscall.

additionally the code added in 0b9a74c290
assures that read and write syscalls() don't block indefinitely and return
on the timeout too, so there's no need to switch sockets back and forth
between blocking/nonblocking.
2020-09-09 12:37:23 +01:00
rofl0r
b4e3f1a896 fix negative timeout resulting in select() EINVAL 2020-09-09 11:59:40 +01:00
rofl0r
78cc5b72b1 get_request_entity: fix regression w/ CONNECT method
introduced in 88153e944f.
when connect method is used (HTTPS), and e.g. a filtered domain requested,
there's no data on readfds, only on writefds.

this caused the response from the connection to hang until the timeout was
hit. in the past in such scenario always a "no entity" response
was produced in tinyproxy logs.
2020-09-08 14:45:24 +01:00
rofl0r
58cfaf2659 make acl lookup 450x faster by using sblist
tested with 32K acl rules, generated by

    for x in `seq 128` ; do for y in `seq 255` ; do \
    echo "Deny 10.$x.$y.0/24" ; done ; done

after loading the config (which is dogslow too), tinyproxy
required 9.5 seconds for the acl check on every request.
after switching the list implementation to sblist, a request
with the full acl check now takes only 0.025 seconds.
the time spent for loading the config file is identical for both
list implementations, roughly 30 seconds.

(in a previous test, 65K acl rules were generated, but every
connection required almost 2 minutes to crunch through the list...)
2020-09-07 22:09:35 +01:00
rofl0r
ebc7f15ec7 acl: typedef access_list to acl_list_t
this allows to switch the underlying implementation easily.
2020-09-07 21:53:14 +01:00
rofl0r
efa5892011 check_acl: do full_inet_pton() only once per ip
if there's a long list of acl's, doing full_inet_pton() over
and over with the same IP isn't really efficient.
2020-09-07 20:57:16 +01:00
rofl0r
88153e944f get_request_entity: respect user-set timeout
get_request_entity() is only called on error, for example if a client
doesn't pass a check_acl() check. in such a case it's possible that
the client fd isn't yet ready to read from.
using select() with a timeout timeval of {0,0} causes it to return
immediately and return 0 if there's no data ready to be read.
this resulted in immediate connection termination rather than returning
the 403 access denied error page to the client and a confusing
"no entity" message displayed in the proxy log.
2020-09-07 20:49:07 +01:00
rofl0r
487a062fcc change loglevel of start/stop/reload messages to NOTICE
this allows to see them when the verbose INFO loglevel is not desired.

closes #78
2020-09-07 16:59:37 +01:00
rofl0r
23b0c84653 upstream: fix ip/mask calculation for types other than none
the code wrongly processed the site_spec (here: domain) parameter
only when PT_TYPE == PT_NONE.
re-arranged code to process it correctly whenever passed.
additionally the mask is now also applied to the passed subnet/ip,
so a site_spec like 127.0.0.1/8 is converted into 127.0.0.0/8.
also the case where inet_aton fails now produces a proper error
message.

note that the code still doesn't process ipv6 addresses and mask.
to support it, we should use the existing code in acl.c and refactor
it so it can be used from both call sites.

closes #83
closes #165
2020-09-07 16:11:51 +01:00
rofl0r
a8848d4bd8 html-error: substitute template variables via a regex
previously, in order to detect and insert {variables} into error/stats
templates, tinyproxy iterated char-by-char over the input file, and would
try to parse anything inside {} pairs and treat it like a variable name.
this breaks CSS, and additionally it's dog slow as tinyproxy wrote every
single character to the client via a write syscall.
now we process line-by-line, and inspect all matches of the regex
\{[a-z]{1,32}\}. if the contents of the regex are a known variable name,
substitution is taking place. if not, the contents are passed as-is to
the client. also the chunks before and after matches are written in
a single syscall.

closes #108
2020-09-07 04:32:13 +01:00
[anp/hsw]
17ae1b512c Do not give error while storing invalid header 2020-09-07 01:12:50 +01:00
rofl0r
d0fae11760 config parser: increase possible line length limit
let's use POSIX LINE_MAX (usually 4KB) instead of 1KB.

closes #226
2020-09-07 01:07:00 +01:00
rofl0r
8c86e8b3ae allow SIGUSR1 to be used as an alternative to SIGHUP
this allows a tinyproxy session in terminal foreground mode to reload
its configuration without dropping active connections.
2020-09-06 23:11:22 +01:00
rofl0r
95b1a8ea06 main.c: remove set_signal_handler code duplication 2020-09-06 23:08:10 +01:00
rofl0r
8ba0ac4e86 do not catch SIGHUP in foreground-mode
it's quite unexpected for an application running foreground in a
terminal to keep running when the terminal is closed.
also in such a case (if file logging is disabled) there's no way to
see what's happening to the proxy.
2020-09-06 22:46:26 +01:00
rofl0r
0d71223a1d send_html_file(): also set empty variables to "(unknown)" 2020-09-06 20:06:59 +01:00
rofl0r
36c9b93cfe transparent: remove usage of inet_ntoa(), make IPv6 ready
inet_ntoa() uses a static buffer and is therefore not threadsafe.
additionally it has been deprecated by POSIX.

by using inet_ntop() instead the code has been made ipv6 aware.

note that this codepath was only entered in the unlikely event that
no hosts header was being passed to the proxy, i.e. pre-HTTP/1.1.
2020-09-06 16:22:11 +01:00
rofl0r
233ce6de3b filter: reduce memory usage, fix OOM crashes
* check return values of memory allocation and abort gracefully
  in out-of-memory situations

* use sblist (linear dynamic array) instead of linked list
  - this removes one pointer per filter rule
  - removes need to manually allocate/free every single list item
    (instead block allocation is used)
  - simplifies code

* remove storage of (unused) input rule
  - removes one char* pointer per filter rule
  - removes storage of the raw bytes of each filter rule

* add line number to display on out-of-memory/invalid regex situation

* replace duplicate filter_domain()/filter_host() code with a single
  function filter_run()
  - reduces code size and management effort

with these improvements, >1 million regex rules can be loaded with
4 GB of RAM, whereas previously it crashed with about 950K.

the list for testing was assembled from
http://www.shallalist.de/Downloads/shallalist.tar.gz

closes #20
2020-09-05 19:42:34 +01:00
Nicolai Søborg
281488a729 Change loglevel for "Maximum number of connections reached"
I was hit by this, and did not see anything in the log, connections was just hanging.
Think warning is a better log level
2020-09-01 15:07:03 +01:00
rofl0r
335477b16e upstream: allow port 0 to be specified
this is useful to use upstream directive to null-route a specific target
domain.

e.g.
upstream http 0.0.0.0:0 ".adserver.com"
2020-08-19 12:01:20 +01:00
rofl0r
0b9a74c290 enforce socket timeout on new sockets via setsockopt()
the timeout option set by the config file wasn't respected at all
so it could happen that connections became stale and were never released,
which eventually caused tinyproxy to hit the limit of open connections and
never accepting new ones.

addresses #274
2020-07-15 09:59:25 +01:00
xiejianjun
db4bd162a3 fix check_acl compilation with --enable-debug
regression introduced in f6d4da5d81.
this has been overlooked due to the assert macro being optimized out in
non-debug builds.
2020-07-06 11:37:35 +01:00
rofl0r
d98aabf47f transparent: fix invalid memory access
getsockname() requires addrlen to be set to the size of the sockaddr struct
passed as the addr, and a check whether the returned addrlen exceeds the
initially passed size (to determine whether the address returned is truncated).

with a request like "GET /\r\n\r\n" where length is 0 this caused the code
to assume success and use the values of the uninitialized sockaddr struct.
2020-03-18 12:31:15 +00:00
rofl0r
3230ce0bc2 anonymous: fix segfault loading config item
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-03-16 13:19:39 +00:00
rofl0r
2e02dce0c3 conf: use 2 swappable conf slots, so old config can stay valid
... in case reloading of it after SIGHUP fails, the old config can
continue working.

(apart from the logging-related issue mentioned in 27d96df999 )
2020-01-15 17:03:47 +00:00
rofl0r
5dd514af93 conf: fix loading of default values
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-15 16:57:03 +00:00
rofl0r
27d96df999 remove duplicate code calling reload_config_file()
as a side effect of not updating the config pointer when loading
the config file fails, the "FIXME" level comment to take appropriate
action in that case has been removed. the only issue remaining
when receiving a SIGHUP and encountering a malformed config file would
now be the case that output to syslog/logfile won't be resumed, if
initially so configured.
2020-01-15 16:35:43 +00:00
rofl0r
c63d5d26b4 access config via a pointer, not a hardcoded struct address
this is required so we can elegantly swap out an old config for a
new one in the future and remove lots of boilerplate from config
initialization code.

unfortunately this is a quite intrusive change as the config struct
was accessed in numerous places, but frankly it should have been
done via a pointer right from the start.

right now, we simply point to a static struct in main.c, so there
shouldn't be any noticeable changes in behaviour.
2020-01-15 16:09:41 +00:00
rofl0r
bffa705005 remove config file name item from conf struct
since this is set via command line, we can deal with it easily
from where it is actually needed.
2020-01-15 15:42:24 +00:00
rofl0r
180c0664aa remove godaemon member from config structure
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-15 15:26:40 +00:00
rofl0r
eb2104e1ff log: remove special case code for daemonized mode without logfile
if daemon mode is used and neither logfile nor syslog options specified,
this is clearly a misconfiguration issue. don't try to be smart and work
around that, so less global state information is required.
also, this case is already checked for in main.c:334.
2020-01-15 15:22:43 +00:00
rofl0r
4fb2c14039 syslog: always use LOG_USER facility
LOG_DAEMON isn't specified in POSIX and the gratuitously different
treatment is in the way of a planned cleanup.
2020-01-15 15:09:37 +00:00
rofl0r
40afaeb637 move commandline parsing to main() 2020-01-15 14:45:23 +00:00
rofl0r
25205fd1f3 move initialize_config_defaults to conf.c 2020-01-15 14:17:13 +00:00
rofl0r
cd005a94ce implement detection and denial of endless connection loops
it is quite easy to bring down a proxy server by forcing it to make
connections to one of its own ports, because this will result in an endless
loop spawning more and more connections, until all available fds are exhausted.
since there's a potentially infinite number of potential DNS/ip addresses
resolving to the proxy, it is impossible to detect an endless loop by simply
looking at the destination ip address and port.

what *is* possible though is to record the ip/port tuples assigned to outgoing
connections, and then compare them against new incoming connections. if they
match, the sender was the proxy itself and therefore needs to reject that
connection.

fixes #199.
2019-12-21 00:43:45 +00:00
rofl0r
f6d4da5d81 do hostname resolution only when it is absolutely necessary for ACL check
tinyproxy used to do a full hostname resolution whenever a new client
connection happened, which could cause very long delays (as reported in #198).

there's only a single place/scenario that actually requires a hostname, and
that is when an Allow/Deny rule exists for a hostname or domain, rather than
a raw IP address. since it is very likely this feature is not very widely used,
it makes absolute sense to only do the costly resolution when it is unavoidable.
2019-12-21 00:43:45 +00:00
rofl0r
82e10935d2 move sockaddr_union to sock.h 2019-12-21 00:43:45 +00:00
rofl0r
fa2ad0cf9a log.c: protect logging facility with a mutex
since the write syscall is used instead of stdio, accesses have been
safe already, but it's better to use a mutex anyway to prevent out-
of-order writes.
2019-12-21 00:43:45 +00:00
rofl0r
b09d8d927d conf.c: merely warn on encountering recently obsoleted config items
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-21 00:43:45 +00:00
rofl0r
1186c297b4 conf.c: pass lineno to handler funcs 2019-12-21 00:43:45 +00:00
rofl0r
b935dc85c3 simplify codebase by using one thread/conn, instead of preforked procs
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.
2019-12-21 00:43:45 +00:00
Martin Kutschker
69c86b987b Use gai_strerror() to report errors of getaddrinfo() and getnameinfo() 2019-11-27 20:31:48 +00:00
rofl0r
734ba1d970 fix usage of stathost in combination with basic auth
http protocol requires different treatment of proxy auth vs server auth.

fixes #246
2019-06-14 01:18:19 +01:00
Janosch Hoffmann
e666e4a35b filter file: Don't ignore lines with leading whitespace (#239)
The new code skips leading whitespaces before removing trailing
whitespaces and comments.
Without doing this, lines with leading whitespace are treated like empty
lines (i.e. they are ignored).
2019-05-05 19:13:38 +01:00
rofl0r
b131f45cbb
child.c: properly initialize fdset for each select() call (#216)
it was reported that because the fdset was only initialized once,
tinyproxy would fail to properly listen on more than one interface.

closes #214
closes #127
2018-12-15 17:09:04 +00:00
Vasily
dc41b35333 Basic Auth: allow almost all possible characters for user/pass
previously was restricted to alphanumeric chars only.
2018-11-23 14:59:03 +00:00
Michael Adam
a5e6d343d7 Remove unused authors.c/authors.h and generation mechanism.
Signed-off-by: Michael Adam <obnox@samba.org>
2018-09-01 04:06:59 +02:00
Michael Adam
56f30a4386 main: remove the "-l" switch to display the license and authors
Signed-off-by: Michael Adam <obnox@samba.org>
2018-09-01 04:06:59 +02:00
rofl0r
c651664720 fix socks5 upstream user/pass subnegotiation check
RFC 1929 specifies that the user/pass auth subnegotation repurposes the version
field for the version of that specification, which is 1, not 5.
however there's quite a good deal of software out there which got it wrong and
replies with version 5 to a successful authentication, so let's just accept both
forms - other socks5 client programs like curl do the same.

closes #172
2018-05-29 21:59:11 +02:00
rofl0r
0aad2f5b92 fix basicauth string comparison
closes #160
2018-03-29 00:40:18 +01:00
Michael Adam
ae0cbfe3f2 html-error: Make a switch fallthrough explicit
This silences a gcc v7 compile warning.

Signed-off-by: Michael Adam <obnox@samba.org>
2018-03-27 09:36:53 +02:00
Michael Adam
badb6435d6 upstream: Fix case of empty string domain.
Found by compiler note.

Signed-off-by: Michael Adam <obnox@samba.org>
2018-03-23 01:45:10 +01:00
rofl0r
8d0ea71486 install tinyproxy to bin/, not /sbin
sbin/ is meant for programs only usable by root, but in tinyproxy's
case, regular users can and *should* use tinyproxy; meaning it is
preferable from a security PoV to use tinyproxy as regular user.
2018-03-23 01:44:53 +01:00
rofl0r
09979629c0 make bind option usable with transparent proxy too
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]: d97d486d53
[1]: 7c01da4a72
2018-02-27 20:52:09 +00:00