Commit Graph

24 Commits (master)

Author SHA1 Message Date
rofl0r 79d0b0fa79 fix timeout not being applied to outgoing connections
the fix in 0b9a74c290 was incomplete, as it
applied the socket timeout only to the socket received from accept(), but
not to sockets created for outgoing connections.
2022-01-20 20:25:42 +00: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 7d33fc8e8a listen_fds: use sblist 2020-09-16 01:05:58 +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
rofl0r 82e10935d2 move sockaddr_union to sock.h 2019-12-21 00:43:45 +00:00
Michael Adam 2ebfd456ef child: use a list of listen_fds instead of one single listenfd.
This prepares listenting on multiple sockets, which will be ussed to
fix listening on the wildcard (listen on both ipv6 and ipv4) and
help add the support for multiple Listen statements in the config

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 2bd919f01e sock: add addr argument to listen_sock()
instead of using config.ipAddr internally.
This is in preparation to make it possible
to call it for multiple addresses.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01:00
Michael Adam 7eea1638bc sock/child: remove global variable addrlen.
This changes listen_sock() to not return the
addrlen of the used address from getaddrinfo call
to the caller, stored in global addrlen in child.c.

This was only used to be able to allocate enough space for the
arguments to the later accept call depending on whether
IPv4 or IPv6 is used.

This removes the need to pass this info by always allocating
sizeof(struct sockaddr_storage) instead, which is enough
to carry both sockaddr_in and sockaddr_in6.

Signed-off-by: Michael Adam <obnox@samba.org>
2013-11-09 13:34:33 +01: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 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 5ecd9157ce Converted the various socket functions to work with both IPv4 and IPv6
addresses.
2004-02-18 20:18:53 +00:00
Robert James Kaes 2f98fec1aa # Style clean up. 2003-01-27 18:45:25 +00:00
Robert James Kaes 478030c6ff Changed the lookup_domain() function to use the new "dnsserver" API.
Also moved safe_write(), safe_read(), readline(), and write_message()
functions into their own file.
2002-05-23 18:25:55 +00:00
Robert James Kaes b10221fa07 Added the write_message() function (from reqs.c) 2001-12-24 00:01:32 +00:00
Robert James Kaes b969ed4302 Changed safe_write() to fully send all the data in the buffer it was
passed. Also safe_write() and safe_read() now use char pointer buffers
rather than the void pointer style.
2001-12-15 20:04:04 +00:00
Robert James Kaes d08d088d4a Replaced the readline() function with a new version which has no
restrictions on the length of a line (unless you fill memory of course.)
Reformated the source.
2001-11-22 00:19:18 +00:00
Robert James Kaes 722a7d2142 Changed the included headers to be only the "tinyproxy.h" since it
contains all the code for properly bringing in the system headers (in the
correct order and with proper dependancies.)
2001-10-25 17:02:50 +00:00
Robert James Kaes b9c4c480d2 Moved the safe_write() and safe_read() functions here. 2001-09-16 20:11:07 +00:00
Robert James Kaes 0a5b82cd97 Fixed up the names of the DEFINES. 2001-06-02 02:07:34 +00:00
Robert James Kaes 42b09e5441 Removed the SA define.
Made the sock_mutex static since it's not referenced outside the file.
Changed the data types for some of the variables.
Cleaned up the readline function (changed data types and removed
variables.)
2001-05-27 02:31:20 +00:00
Robert James Kaes f6b7fe3f5c Needed locking in getpeer_string().
Added mutex locking around the dnscache() call.
Removed the global sockaddr and setup_fd variables.
Added the socket_blocking() and socket_nonblocking() functions.
Gutted the readling() function and replaced it with something similar to
the 1.0 version. :)
2000-09-11 23:56:32 +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