summaryrefslogtreecommitdiffhomepage
path: root/src/transparent-proxy.c
AgeCommit message (Collapse)Author
2020-09-18transparent: workaround old glibc bug on RHEL7rofl0r
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-16listen_addrs: use sblistrofl0r
2020-09-15save headers in an ordered dictionaryrofl0r
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-06transparent: remove usage of inet_ntoa(), make IPv6 readyrofl0r
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-03-18transparent: fix invalid memory accessrofl0r
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.
2018-02-25fix possible memory leakbertliao
2013-11-23transparent: make transparent support compile after introduction of multi ListenMichael Adam
I seem to have forgotten to compile with transparent support enabled... This belongs to the fix for bug BB#63. Signed-off-by: Michael Adam <obnox@samba.org>
2010-12-01[BB#95] remove two comments that have become wrong by the fix.Michael Adam
2010-12-01[BB#95] Fix FilterURLs with transparent proxy support.Daniel Egger
Pass a pointer to a char pointer to do_transparent_proxy so the reassembled URL will actually end up back in the caller where it is needed for filtering decisions. This fixes the problem that a tinyproxy configured with the transparent proxy functionality and "FilterURLs Yes" would filter on everything but the domain. Signed-off-by: daniel.egger@sphairon.com Signed-off-by: Michael Adam <obnox@samba.org>
2009-12-07Fix the build with --enable-transaparent after conf changes.Michael Adam
Michael
2009-10-02url variable modified in do_transparent_proxy() is not the url variable in ↵Mukund Sivaraman
the caller
2009-10-02Use safer string functionsMukund Sivaraman
2009-09-27Add explicit casts for c++ mode in transparent-proxy.cMukund Sivaraman
2009-09-15Indent code to Tinyproxy coding styleMukund Sivaraman
The modified files were indented with GNU indent using the following command: indent -npro -kr -i8 -ts8 -sob -l80 -ss -cs -cp1 -bs -nlps -nprs -pcs \ -saf -sai -saw -sc -cdw -ce -nut -il0 No other changes of any sort were made.
2009-08-07Rename tinyproxy.[ch] to main.[ch]Mukund Sivaraman
2008-12-08Convert tabs to spacesMukund Sivaraman
2008-12-08Break at 80 columnsMukund Sivaraman
2008-12-01Reformat code to GNU coding styleMukund Sivaraman
This is a commit which simply ran all C source code files through GNU indent. No other modifications were made.
2008-06-09Moved transparent proxy code into its own fileRobert James Kaes
Extracted the transparent proxy logic from reqs.c and placed it into a separate file. Signed-off-by: Robert James Kaes <rjk@wormbytes.ca>