Commit Graph

35 Commits (master)

Author SHA1 Message Date
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 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 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
Mukund Sivaraman ec4b4d979f Use NULL for pointers 2009-11-17 02:40:03 +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 181b03d729 Fix an implicit cast warning in initialize_conn().
Michael
2009-08-07 09:12:42 +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 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 249d4b7f33 Updated copyright, license notices in source code
The notices have been changed to a more GNU look. Documentation
comments have been separated from the copyright header. I've tried to
keep all copyright notices intact. Some author contact details have
been updated.
2008-05-24 13:35:49 +05:30
Robert James Kaes c0299e1868 * [Indent] Ran Source Through indent
I re-indented the source code using indent with the following options:

indent -kr -bad -bap -nut -i8 -l80 -psl -sob -ss -ncs

There are now _no_ tabs in the source files, and all indentation is
eight spaces.  Lines are 80 characters long, and the procedure type is
on it's own line.  Read the indent manual for more information about
what each option means.
2005-08-15 03:54:31 +00:00
Robert James Kaes a59117c7ca * Updated Copyright Email Addresses
Updated the copyright email addresses for Robert James Kaes.  The
users.sourceforge.net address should always exist.
2005-07-12 17:39:44 +00:00
Robert James Kaes badc7673d0 Merged in changes from 1.6.3 2004-08-10 21:24:24 +00:00
Robert James Kaes 18df4910a4 Added the "BindSame" configure directive from Oswald Buddenhagen.
This allows tinyproxy to respond to a request bound to the same
interface that the request came in on.  As Oswald explains:

  "attached is a patch that adds the BindSame option. it causes
  binding an outgoing connection to the ip address of the respective
  incoming connection. that way one can simulate an entire proxy farm
  with a single instance of tinyproxy on a multi-homed machine."

Cool.
2004-04-27 18:53:14 +00:00
Robert James Kaes aee5a63849 Removed unnecessary casts (mostly dealing with memory allocation.) I
should never have added them in the first place.  They don't really
buy anything, and they can hide bugs.
2004-02-13 21:27:42 +00:00
Robert James Kaes 0a8e4e4d8d Added reverse proxy support from Kim Holviala. His comments regarding
this addition follow:

  The patch implements a simple reverse proxy (with one funky extra
  feature). It has all the regular features: mapping remote servers to local
  namespace (ReversePath), disabling forward proxying (ReverseOnly) and HTTP
  redirect rewriting (ReverseBaseURL).

  The funky feature is this: You map Google to /google/ and the Google front
  page opens up fine. Type in stuff and click "Google Search" and you'll get
  an error from tinyproxy. Reason for this is that Google's form submits to
  "/search" which unfortunately bypasses our /google/ mapping (if they'd
  submit to "search" without the slash it would have worked ok). Turn on
  ReverseMagic and it starts working....

  ReverseMagic "hijacks" one cookie which it sends to the client browser.
  This cookie contains the current reverse proxy path mapping (in the above
  case /google/) so that even if the site uses absolute links the reverse
  proxy still knows where to map the request.

  And yes, it works. No, I've never seen this done before - I couldn't find
  _any_ working OSS reverse proxies, and the commercial ones I've seen try
  to parse the page and fix all links (in the above case changing "/search"
  to "/google/search"). The problem with modifying the html is that it might
  not be parsable (very common) or it might be encoded so that the proxy
  can't read it (mod_gzip or likes).

  Hope you like that patch. One caveat - I haven't coded with C in like
  three years so my code might be a bit messy.... There shouldn't be any
  security problems thou, but you never know. I did all the stuff out of my
  memory without reading any RFC's, but I tested everything with Moz, Konq,
  IE6, Links and Lynx and they all worked fine.
2004-01-26 19:11:52 +00:00
Robert James Kaes a117ed9cb0 Included patches from Steven Young to use the hashmap functionality to
manage the HTML error pages.  It simplifies the source, and also make
the object file smaller.  Nice.  Also added any casting from (void*)
to ensure that the code compiles using a C++ compiler.
2003-08-01 00:14:34 +00:00
Robert James Kaes 6aaa863432 Added appropriate casts from (void*) so that the code will compile
cleanly with a C++ compiler.  (Tested using GCC 3.3)
2003-07-31 23:38:28 +00:00
Robert James Kaes 77ca1c8ce0 # Changed all the for calls to use the != test rather than < test.
The change was recommended in the C/C++ User Journal magazine.
2003-05-31 23:02:21 +00:00
Robert James Kaes ac88af1f71 Fixed a bug that would kill a child process because of an invalid
safefree() call.  Basically, destroy_conn() was trying to free memory
not allocated by malloc.  [Fix by David T. Pierson]
2003-05-04 04:35:10 +00:00
Robert James Kaes 6ff4192069 Removed the remote_content_length field in the "conn" structure and
replaced it with a smaller structure containing both the remote/server
and the local/client content-length fields if they're present in the
HTTP response headers.
2003-04-16 16:37:59 +00:00
Robert James Kaes 056bbf84bd # Added variables to keep track of the variables to be substituted in
.html files displayed to the client [Steven Young]
2003-03-13 21:27:29 +00:00
Robert James Kaes a1e24ac839 (destroy_conn): Added code to log any error messages when the sockets
are closed.
2002-11-13 17:47:40 +00:00
Robert James Kaes 391a408eee Fixed a tonne of spelling mistakes. 2002-05-24 04:45:32 +00:00
Robert James Kaes 09b1b9b925 Added the peer's socket information to the connection structure. The
information is passed along during the initialization of the structure.
2002-05-23 18:23:29 +00:00
Robert James Kaes 60f0a86c75 The stats now wait until after the client has finished sending all its
headers before sending the HTTP response back.  This should be more
standards compliant.
2002-04-18 21:43:53 +00:00
Robert James Kaes a5d3212751 Changed the error boolean flag into a pointer to an error string and an
error code.  We're storing this information because tinyproxy doesn't
output the error information until _after_ the client has sent it's
information.
2002-04-15 02:07:27 +00:00
Robert James Kaes ce06f27a35 Added the remote_content_length variable to store the number of bytes the
remote server is supposed to be transmiting to the client.
2002-04-11 20:27:51 +00:00
Robert James Kaes 97a72783f5 Cleaned up some of the code to handle errors better. Also, a little bit
easier to read in the variable department.
2002-04-07 21:32:01 +00:00
Robert James Kaes 5e17d0736e Removed some of the members of the structures and renamed a few others. 2001-11-25 22:06:20 +00:00
Robert James Kaes 787ece6c01 Reformated text. 2001-11-22 00:31:10 +00:00
Robert James Kaes bc8c3ff399 Include the protocol variables in the conn_s structure. 2001-11-21 01:00:09 +00:00
Robert James Kaes f8ad0dced3 Moved the connection creation/destruction and definition into it's own
files.
2001-10-25 16:58:09 +00:00
Robert James Kaes 2d9d164034 These files are no longer used within tinyproxy. 2000-09-11 23:24:59 +00:00
Steven Young 37e63909c0 This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches.
2000-02-16 17:32:49 +00:00