Commit Graph

44 Commits (master)

Author SHA1 Message Date
rofl0r 77cd87efef print error message if errorfile is configured but can't be opened
also, don't use fopen(NULL) if usage of errorfiles is not configured.
2022-05-27 12:48:41 +00:00
rofl0r a869e71ac3 add support for outgoing connections with HTTP/1.1
since there are numerous changes in HTTP/1.1, the proxyserver will
stick to using HTTP/1.0 for internal usage, however when a connection
is requested with HTTP/1.x from now on we will duplicate the minor revision
the client requested, because apparently some servers refuse to accept
HTTP/1.0

addresses #152.
2021-04-16 14:51:01 +01:00
rofl0r 48860bbe26 refactor html-error so send_http_headers() can take extra arg
we already required an extra argument inside the headers sent
for 401 and 407 error responses, move those to sent_http_error_message()
and refactor send_http_headers() to always take the extra argument.
in calling sites where the extra arg isn't needed, use "".
2021-03-28 20:24:23 +01:00
rofl0r 732bdd0f56 replace usage of non-threadsafe gmtime() with gmtime_r()
the latter is a standard POSIX function too.
2020-10-19 20:21:26 +01:00
rofl0r cc0a7eb9a2 html-error: move common.h inclusion back to top
this seems to cause an implicit declaration of snprintf() thanks to
feature test macro hell.
2020-10-19 20:08:31 +01:00
rofl0r 35c8edcf73 speed up build by only including regex.h where needed 2020-09-30 05:13:45 +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 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 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
rofl0r 0d71223a1d send_html_file(): also set empty variables to "(unknown)" 2020-09-06 20:06:59 +01: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 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 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
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
rofl0r bd04ed00d8 Basic Auth: send correct response codes and headers acc. to rfc7235
as reported by @natedogith1
2018-02-06 16:57:02 +00:00
Greg fdb1aae3a9 Move lookup_variable into hashmap.c / hashmap.h 2016-12-27 12:23:51 -05:00
Greg 540069551d Change signature for lookup_variable to take map instead of connptr 2016-12-27 12:18:16 -05:00
rofl0r ee83293285 update URL 2016-01-03 21:16:21 +00:00
Mukund Sivaraman 5ad24ba99d Update URLs of Tinyproxy 2011-02-28 12:36:05 +05:30
Mukund Sivaraman 34088e2175 Revert "Update Tinyproxy website URLs"
This reverts commit b108162dfb.
2010-03-28 10:27:40 +05:30
Mukund Sivaraman b108162dfb Update Tinyproxy website URLs 2010-03-27 08:22:51 +05:30
Mukund Sivaraman 9434b27cc1 Remove bogus static qualifiers for these auto variables 2010-01-25 23:40:03 +05:30
Mukund Sivaraman bf820013df Use HTTPS link in URLs to Tinyproxy websites 2010-01-16 10:22:22 +05:30
Michael Adam 7290691142 Move definition of "struct config_s" from main.h to conf.h
Michael
2009-12-07 22:33:27 +01:00
Mukund Sivaraman 323a4d0147 Clean up html_send_file ()
- Make function return from one place
 - Move inbuf to the heap
2009-10-02 13:01:32 +05:30
Mukund Sivaraman 7b9234f394 Indent code to Tinyproxy coding style
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-09-15 01:11:25 +05:30
Michael Adam 02e7bc7545 send_html_file(): remove a discards qualifyer warning
and untangle assignment from check.

 Michael
2009-08-07 08:56:46 +02:00
Michael Adam 3adec81872 html-error: make read only argument const in lookup_variable().
Michael
2009-08-07 08:53:26 +02:00
Michael Adam 76dadf47d3 make a const string const in send_http_error_message().
Michael
2009-08-07 08:51:35 +02:00
Michael Adam 1c3c268b50 make a const string const in send_http_headers().
Michael
2009-08-07 08:49:21 +02:00
Michael Adam c8ee85702e make message argument of indicate_http_error() const.
Michael
2009-08-07 08:48:51 +02:00
Michael Adam 20b606b6f5 make message argument to send_http_headers() constant.
Michael
2009-08-07 08:44:47 +02:00
Michael Adam 251a975126 add_error_variable(): make key and data arguments const
Michael
2009-08-07 08:41:36 +02:00
Mukund Sivaraman a21cd7e3ed Rename tinyproxy.[ch] to main.[ch] 2009-08-07 03:42:53 +05:30
Mukund Sivaraman 024b317de0 Convert tabs to spaces 2008-12-08 13:39:44 +00:00
Mukund Sivaraman 6e6f992f8c Update Tinyproxy website URL 2008-12-08 12:41:44 +00:00
Mukund Sivaraman 4c1ede779e Break at 80 columns 2008-12-08 12:26:08 +00:00
Mukund Sivaraman a257703e59 Reformat code to GNU coding style
This is a commit which simply ran all C source code files
through GNU indent. No other modifications were made.
2008-12-01 15:01:11 +00:00
Mukund Sivaraman 7e5ac7c58a Fix a regression where empty error variables caused strlen() to crash
This fixes a regression (bug #16) introduced in
95c1f39f60, where a NULL check was
removed. This caused NULL error variable values to be sent to
add_error_variable() in which strlen() segfaulted.

With this fix, custom stats pages should be displayed properly.

X-Banu-Bugzilla-Ids: 16
2008-07-14 17:13:06 +05:30
Mukund Sivaraman 7bdd47d030 Make the embedded error message display valid XHTML too
Also fix the information that is displayed.
2008-07-14 15:47:00 +05:30
Mukund Sivaraman 7f12f71f94 Add error number as a template parameter for error pages 2008-07-14 15:31:14 +05:30
Mukund Sivaraman 74f5c3e417 Spruce up error page footers a bit 2008-07-14 15:02:41 +05:30
Mukund Sivaraman 95c1f39f60 Don't check the value to be inserted as it's already checked
This change primarily avoids a gcc warning where timebuf
is never non-NULL. There is no need to check the value to be
inserted as it's checked inside hashmap_insert().

This changeset also lets error return values from hashmap_insert()
propogate instead of clamping them to -1 (not that these are
currently used anyway).
2008-06-10 09:51:23 +05:30
Mukund Sivaraman b0a3568de0 Renamed htmlerror.[ch] to html-error.[ch] 2008-05-24 13:47:14 +05:30