Compare commits

..
56 Commits
Author SHA1 Message Date
Mukund Sivaraman 18db1675a0 Update NEWS 2011-08-16 17:56:04 +05:30
Mukund Sivaraman 4d979df636 Bump version to 1.8.3 2011-08-16 17:45:06 +05:30
Mukund Sivaraman fc354343f9 Minor whitespace fix 2011-08-16 17:43:59 +05:30
Mukund Sivaraman 1db982793d [BB#90]: Fix bug in ACL netmask generation
Thanks to John Horne who diagnosed this issue and found the problem.
2011-03-04 14:47:54 +05:30
Mukund Sivaraman 95a6f8259c Validate port number specified in Port directive
This was asked in bug #90 comment #8.
2011-03-04 14:10:11 +05:30
Mukund Sivaraman 8b76f1a939 Update URLs of Tinyproxy 2011-02-28 12:46:46 +05:30
Mukund Sivaraman 121a11d8e5 Surround IPv6 literals with [] in Host: headers 2011-02-07 18:01:03 +05:30
Mukund Sivaraman 736e052dc1 Handle IPv6 literals in URLs correctly 2011-02-04 21:03:12 +05:30
Michael Adam aa197d6dc8 [BB#95] remove two comments that have become wrong by the fix. 2010-12-01 22:21:11 +01:00
Daniel Egger d13d575d29 [BB#95] Fix FilterURLs with transparent proxy support.
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>
2010-12-01 22:18:08 +01:00
Michael Adam c4b187c8ab README: correctly list --enable-transparent
--enable-transparent-proxy was renamed to --enable-transparent
in August 2004... :-)
2010-12-01 21:44:32 +01:00
Michael Adam 5012ce690f [BB#91] Fix upstream proxy support.
Patch by Jordi Mallach.
2010-08-24 22:50:53 +02:00
Michael Adam 4b75b634d9 upstream: clarify debug messages
There are frequent questions "what does 'No proxy for ...' mean?"
on the mailing list and IRC. Be more specific. (No upstream proxy ...)
Correspondingly, log "Found upstream proxy ... for ..."
2010-08-24 22:50:48 +02:00
Mukund Sivaraman 4b64de4c31 Change wording in NEWS 2010-06-05 09:29:58 +05:30
Mukund Sivaraman 7fa544c3d8 Bump version in configure.ac 2010-06-02 10:40:23 +05:30
Mukund Sivaraman a5a3741291 Add BB#74 to NEWS 2010-06-02 10:39:56 +05:30
Mukund Sivaraman 784d458b82 [BB#74] Create log and pid files after we drop privs 2010-06-02 10:19:49 +05:30
Mukund Sivaraman 94edc4f4c5 Remove excessive code 2010-06-02 10:11:10 +05:30
Mukund Sivaraman be63d2ca19 Add BB#89 to NEWS 2010-06-02 05:05:30 +05:30
Mukund Sivaraman a905437242 Add NEWS for 1.8.2 2010-06-01 08:12:29 +05:30
John van der Kamp 3127e726d0 [BB#89] Don't recompile regular expressions
This is a modification of a patch originally written by
John van der Kamp <john@kirika.demon.nl> at
<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579427#12>

The modification was done by the committer.
2010-06-01 07:58:02 +05:30
Mukund Sivaraman 5bb184c54d Fix typo in manpage 2010-05-30 10:02:45 +05:30
Jordi Mallach 505ff803e9 [BB#83] Use output of id instead of $USER 2010-04-21 21:01:59 +05:30
Dmitry Semyonov d03e3a52e5 Fix crash in send_stored_logs() 2010-04-21 20:32:41 +05:30
Mukund Sivaraman fe9444d585 Fix compiler warning about dereferencing type-punned pointers
This is a backport of commit 19b9bff888
from the master branch.
2010-04-21 20:21:22 +05:30
Mukund Sivaraman b37135524d Revert "main: drop privileges right after reading the config"
This reverts commit 965664798c. It should
fix the issue in bug #87.
2010-04-21 20:09:20 +05:30
Mukund Sivaraman 7f053670c0 Just fix the support URLs
These should always point to the top-level Tinyproxy homepage.
2010-03-28 10:29:56 +05:30
Mukund Sivaraman b28e438cdf Revert "Update Tinyproxy website URLs"
This reverts commit e495bdf129.
2010-03-28 10:27:45 +05:30
Mukund Sivaraman e495bdf129 Update Tinyproxy website URLs 2010-03-27 08:19:53 +05:30
Mukund Sivaraman 287a7ae649 Revert "Revert "Pass address family when binding to outgoing socket""
This reverts commit 577ac16cf1. It looks
like bug #69 needs this fix after all.
2010-03-09 17:07:14 +05:30
Mukund Sivaraman 315e129f12 Pull BB#69 out of NEWS for 1.8.1 2010-03-09 06:58:24 +05:30
Mukund Sivaraman 7cb30dd9ee Separate different versions in NEWS with newlines 2010-03-09 06:55:25 +05:30
Mukund Sivaraman 9927d411bf Add the contributors section to 1.8.1 NEWS 2010-03-03 15:37:10 +05:30
Mukund Sivaraman 0f28221ec5 Minor grammatical change 2010-03-03 15:33:40 +05:30
Mukund Sivaraman 57d90c8bf7 Update NEWS for 1.8.1 2010-03-03 15:31:46 +05:30
Mukund Sivaraman 8de8634b8b Bump version to 1.8.1 2010-03-03 15:21:25 +05:30
Mukund Sivaraman ce149cc7a6 Use AI_PASSIVE flag to make tinyproxy listen on wildcard interface
Signed-off-by: Michael Adam <obnox@samba.org>
2010-03-03 09:27:22 +01:00
Michael Adam 410eaf107c Comment out the LogFile and PidFile options in the example tinyproxy.conf.
These are compiled in defaults now.

Michael
2010-03-03 01:06:25 +01:00
Michael Adam e6cbaf7b6e change the default pid file location to "@LOCALSTATEDIR@/run/tinyproxy/tinyproxy.pid"
I.e., add a tinyproxy subdirectory.
This is meant to ease running tinyproxy as non-root user.
The subdirectory can be used to give the tinyproxy user
write permission.

Michael
2010-03-03 01:06:25 +01:00
Michael Adam 2d0192b8a8 change the default log file location to "@LOCALSTATEDIR@/log/tinyproxy/tinyproxy.log"
i.e. add a tinyproxy subdirectory.
This is meant to ease running tinyproxy as non-root user
the subdirectory can be used to give the tinyproxy user
write permission.

Michael
2010-03-03 01:06:25 +01:00
Michael Adam 643d52ac5a main: some tabs->spaces 2010-03-03 01:06:25 +01:00
Michael Adam b92792fd8d main: move a log message. 2010-03-03 01:06:25 +01:00
Michael Adam 965664798c main: drop privileges right after reading the config
This is the second part of fixing bug #74.
I lets tinyproxy create its log and pid files as the
user as which it is running, so that later on at SIGHUP,
the log file can successfully be reopened.

Michael
2010-03-03 01:06:25 +01:00
Michael Adam 6d5709de38 main: separate loading of config and setup_logging at startup
This is the first part of a fix for bug #74
(making reloading of config work if running as non-privileged user)

Michael
2010-03-03 01:06:25 +01:00
Michael Adam 107f9117d0 tinyproxy.conf: fix LogFile to proper CamelCase for consistency 2010-03-03 01:06:24 +01:00
Michael Adam 1b3dd058d1 tests: fix bug #80: keep track of errors in return codes
Michael
(cherry picked from commit 3f1632603c)
2010-02-23 00:19:26 +01:00
Michael Adam 333d722d56 tests: fix a typo in run_tests.sh
(cherry picked from commit 7c15563430)
2010-02-23 00:19:23 +01:00
Michael Adam 6f0abb7339 test: add make target "make valgrind-test-wait"
(cherry picked from commit ee1f1e38f2)
2010-02-22 23:32:08 +01:00
Michael Adam a19f758743 tests: add a new make target "make test-wait"
(cherry picked from commit 752e4419a6)
2010-02-22 23:21:18 +01:00
Michael Adam f63730c77e tests: Fix bug #79. Finish "make test" without waiting for user input.
Old behaviour is preserved by passing in the environment variable
TINYPROXY_TESTS_WAIT=yes.

Michael
(cherry picked from commit d133eee36b)
2010-02-22 23:21:13 +01:00
Mukund Sivaraman ed3ada7c26 Use format string when logging messages 2010-02-19 21:08:00 +05:30
Mukund Sivaraman b9e6d9742d Fix pkgdatadir path in tinyproxy.conf 2010-02-19 21:07:58 +05:30
Mukund Sivaraman fbc434e26d Display upstream proxy support in usage message 2010-02-17 23:18:50 +05:30
Mukund Sivaraman cc74869e71 Fix typo in manpage 2010-01-25 19:35:41 +05:30
Mukund Sivaraman 577ac16cf1 Revert "Pass address family when binding to outgoing socket"
This reverts commit 65ef313cc4.
This patch could've been the reason for BB#69.
2010-01-24 11:18:27 +05:30
Mukund Sivaraman 810b9ae49a Remove completed items from TODO list 2010-01-18 16:01:16 +05:30
47 changed files with 3106 additions and 1421 deletions

No files matched your search

-1
View File
@@ -18,6 +18,5 @@ stamp-h1
autom4te.cache
cscope.files
cscope.out
compile
*~
tags
-18
View File
@@ -1,18 +0,0 @@
language: C
dist: trusty
sudo: true
before_install:
- sudo apt-get update -qq
- sudo apt-get install --assume-yes asciidoc valgrind
script:
- ./autogen.sh
- ./configure
- make
- make test
- ./configure --enable-debug --enable-transparent --enable-reverse
- make
- make test
- make valgrind-test
- make distcheck
+19 -39
View File
@@ -1,39 +1,19 @@
Andrew Stribblehill
bertliao
Bob Showalter
Brian Cain
cvs2svn
Daniel Egger
Daniel M. Drucker
David Shanks
Dmitry Semyonov
dmz-uk
Drew G. Wallace
Frank Morgner
gary-wzl77
Gaudenz Steinlin
goba62000374
Gonzalo Tornaria
Greg
Jeremy Hinegardner
John Spencer
John van der Kamp
John Weldon
Jordi
Jordi Mallach
Julien Hartmann
kikuchan
Mathew Mrosko
Matthew Dempsky
Michael Adam
Mike Mead
Mukund Sivaraman
Pablo Panero
Peter H. Froehlich
Robert James Kaes
rofl0r
Stephan Leemburg
Steven Conaway
Steven Young
Valen Blanco
Vladimir Belov
Early History
-------------
Steven Young is the original author and was the primary maintainer of
tinyproxy until version 1.1. He also maintained the project from
version 1.3.1 until 1.4.0.
Robert James Kaes is the current maintainer and lead programmer. He
also maintained the project between versions 1.2 and 1.3.0, and again
starting with version 1.4.0.
Major Additions/Improvements
----------------------------
James E. Flemer <jflemer@acm.jhu.edu> - URL/domain filtering
Kim Holviala <kim@holviala.com> - Reverse proxy support
Petr Lampa <lampa@fit.vutbr.cz> - Transparent proxy support
George Talusan <gstalusan@uwaterloo.ca> - URL/domain filtering
+2155 -1
View File
File diff suppressed because it is too large. Load diff
-8
View File
@@ -9,14 +9,6 @@ SUBDIRS = \
# tools want this on a single line
ACLOCAL_AMFLAGS = -I m4macros
all-local:
dist_doc_DATA = \
AUTHORS \
NEWS \
README \
README.md
EXTRA_DIST = \
autogen.sh \
tinyproxy-indent.sh \
+153 -1
View File
@@ -1 +1,153 @@
See git log for recent changes in Tinyproxy.
Tinyproxy NEWS
==============
Version 1.8.3
-------------
This release mostly fixes support for IPv6, and also some security
bugs. Fixes to messages, etc. were also made.
Bugs resolved since version 1.8.2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* BB#91: Fix upstream proxy support
* BB#95: Fix FilterURLs with transparent proxy support
* BB#90: Fix bug in ACL netmask generation
Contributors
~~~~~~~~~~~~
Daniel Egger, John Horne, Michael Adam, Mukund Sivaraman.
Version 1.8.2
-------------
* Minor formatting changes and typo fixes were made.
Bugs resolved since version 1.8.1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* BB#69: INET6 not available when configured to Listen and Bind in v4,
and vice versa
* BB#74: tinyproxy unable to reopen log files after receiving HUP
* BB#78: Warn if configuration results in an open proxy
* BB#82: https access not working
* BB#83: run_tests.sh relies on $USER
* BB#84: Unaligned access error on ia64 and alpha
* BB#87: Unable to listen on ports less than 1024 (regression in 1.8.1)
* BB#88: Crashes when reloading configuration
* BB#89: tinyproxy leaks memory over time
Contributors
~~~~~~~~~~~~
Dmitry Semyonov, John van der Kamp, Jordi Mallach, Michael Adam,
Mukund Sivaraman.
Version 1.8.1
-------------
* Tinyproxy now drops `root` user privileges more quickly.
* The log and pid files are now stored in a sub-directory in `/var/`.
* A format string vulnerability was fixed.
* Minor formatting changes and typo fixes were made.
Bugs fixed since version 1.8.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* BB#74: tinyproxy unable to reopen log files after receiving HUP
* BB#79: Make the testsuite uninteractive
* BB#80: Handle errors in testsuite
* BB#81: Listen directive doesn't work as expected
* BB#72: upstream support is not reported with tinyproxy -h
* BB#73: generated tinyproxy.conf has the wrong location for the html
file installation
Contributors
~~~~~~~~~~~~
Michael Adam, Mukund Sivaraman.
Version 1.8.0
-------------
* Tinyproxy now reloads its configuration upon SIGHUP signal.
* Tinyproxy reopens its log file (instead of truncation) upon SIGHUP
signal. This is to play more nicely with logrotate.
* File logging is now the default.
Syslog is chosen if and only if "SysLog Yes" is in the config,
i.e., a present "SysLog Yes" in the config file now overrides
any LogFile setting.
* The XTinyProxy option is now documented as a global boolean.
Before it was documented to build a list of sites to add a
X-Tinyproxy header for, but it was implemented as global boolean.
* A new config option AddHeader allows the user to configure a list of
custom headers to send in outgoing HTTP requests.
* A new config option DisableViaHeader allows the user to disable
sending of the "Via:" header.
* Tinyproxy is now IPv6 capable.
* The config option PidFile now has a compiled in default.
Bugs fixed since version 1.7.1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* BB#9: Add support for the IPv6 protocol
* BB#17: Add support for custom headers
* BB#55: Error message response omits body when request has a body
* BB#60: Add config option to disable Via header
* BB#61: SIGHUP does not refresh filter list
* BB#62: Make tinyproxy reload the config upon SIGHUP
* BB#64: Config parsing error with reverse proxy option
* BB#65: Format string compile warnings
* BB#67: ACL processing error with multiple Allow statements
Contributors
~~~~~~~~~~~~
David Shanks, Mathew Mrosko, Michael Adam, Mukund Sivaraman.
Version 1.7.1
-------------
* Fixed all warnings reported by GCC.
* The tinyproxy manpage has been extended and converted to asciidoc.
* There is a new tinyproxy.conf manpage that describes all the options.
* The build system has been considerably cleaned up.
* Various other bugs have been fixed.
Bugs fixed since version 1.7.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* BB#2: Fix Tinyproxy for requests like www.site.com:8001
* BB#5: Move templates from the doc directory to its own directory
* BB#8: Update README, INSTALL, NEWS and the manpage
* BB#10: Do not filter out transfer-encoding header
* BB#18: Fix pointer aliasing issues
* BB#53: Add a GPLv2 COPYING file
Contributors
~~~~~~~~~~~~
Andrew Stribblehill, Jeremy Hinegardner, Matthew Dempsky, Michael Adam,
Mukund Sivaraman, Robert James Kaes.
Version 1.7.0
-------------
* There is now support for reverse proxying.
* Tinyproxy does not bundle a vendor regular expressions library
anymore. It uses the system installed regular expressions library.
* The documentation has been updated.
* Tinyproxy now contains some code optimizations such as the use of a
hashmap internally for looking up error pages.
* Various other bugs have been fixed.
Contributors
~~~~~~~~~~~~
Kim Holviala, Marc Silver, Robert James Kaes, Steven Young.
+97 -1
View File
@@ -1 +1,97 @@
see README.md
Tinyproxy
=========
Tinyproxy is a small, efficient HTTP/SSL proxy daemon released under the
GNU General Public License. Tinyproxy is very useful in a small network
setting, where a larger proxy would either be too resource intensive, or
a security risk. One of the key features of Tinyproxy is the buffering
connection concept. In effect, Tinyproxy will buffer a high speed
response from a server, and then relay it to a client at the highest
speed the client will accept. This feature greatly reduces the problems
with sluggishness on the Internet. If you are sharing an Internet
connection with a small network, and you only want to allow HTTP
requests to be allowed, then Tinyproxy is a great tool for the network
administrator.
For more info, please visit:
https://banu.com/tinyproxy/
Installation
------------
To install this package under a UNIX derivative, read the INSTALL file.
Tinyproxy uses a standard GNU `configure` script. Basically you should
be able to do:
----
./configure
make
make install
----
in the top level directory to compile and install Tinyproxy. There are
additional command line arguments you can supply to `configure`. They
include:
--enable-debug If you would like to turn on full
debugging support
--enable-xtinyproxy Compile in support for the XTinyproxy
header, which is sent to any web
server in your domain.
--enable-filter Allows Tinyproxy to filter out certain
domains and URLs.
--enable-upstream Enable support for proxying connections
through another proxy server.
--enable-transparent
Allow Tinyproxy to be used as a
transparent proxy daemon
--enable-static Compile a static version of Tinyproxy
--with-stathost=HOST Set the default name of the stats host
Support
-------
If you are having problems with Tinyproxy, please submit a bug report
using Tinyproxy as the product at:
https://banu.com/bugzilla/
You may also wish to subscribe to the Tinyproxy mailing lists. To do so
please visit:
https://banu.com/mailman/listinfo/tinyproxy-announce-list
https://banu.com/mailman/listinfo/tinyproxy-users-list
https://banu.com/mailman/listinfo/tinyproxy-developers-list
for more information on how to subscribe and post messages to the lists.
Contributing
------------
If you would like to contribute a feature, or a bug fix to the Tinyproxy
source, please send a patch (preferably as a unified diff. i.e. `diff
-u` against the "master" branch of the Tinyproxy source code git
repository to tinyproxy-developers-list. Please include a description
of what your patch does.
Tinyproxy's git repository is git://banu.com/tinyproxy.git. The
following command creates a local copy:
----
git clone git://banu.com/tinyproxy.git
----
The easiest and preferred way to create a patch for submission is to
check in your changes locally and use `git format-patch` to generate a
mbox-style commit file that contains the diff along with the commit
message and author information. Such a format-patch file can be
integrated into the upstream repository, automatically keeping the
commit message and author information.
You can also meet developers and discuss development issues and patches
in the #tinyproxy IRC channel on Freenode (irc.freenode.net).
-89
View File
@@ -1,89 +0,0 @@
# Tinyproxy
Tinyproxy is a small, efficient HTTP/SSL proxy daemon released under the
GNU General Public License. Tinyproxy is very useful in a small network
setting, where a larger proxy would either be too resource intensive, or
a security risk. One of the key features of Tinyproxy is the buffering
connection concept. In effect, Tinyproxy will buffer a high speed
response from a server, and then relay it to a client at the highest
speed the client will accept. This feature greatly reduces the problems
with sluggishness on the Internet. If you are sharing an Internet
connection with a small network, and you only want to allow HTTP
requests to be allowed, then Tinyproxy is a great tool for the network
administrator.
For more info, please visit [the Tinyproxy web site](https://tinyproxy.github.io/).
## Installation
Tinyproxy uses a standard GNU `configure` script based on the automake
system. If compiling from a git checkout, you need to first run
```
./autogen.sh
```
from the top level directory to generate the `configure` script.
The release tarball contains the pre-created `configure` script,
so when building from a release, you can skip this step.
Then basically all you need to do is
```
./configure
make
make install
```
in the top level directory to compile and install Tinyproxy. There are
additional command line arguments you can supply to `configure`. They
include:
- `--enable-debug`:
If you would like to turn on full debugging support.
- `--enable-xtinyproxy`:
Compile in support for the XTinyproxy header, which is sent to any
web server in your domain.
- `--enable-filter`:
Allows Tinyproxy to filter out certain domains and URLs.
- `--enable-upstream`:
Enable support for proxying connections through another proxy server.
- `--enable-transparent`:
Allow Tinyproxy to be used as a transparent proxy daemon.
- `--enable-reverse`:
Enable reverse proxying.
- `--with-stathost=HOST`:
Set the default name of the stats host.
For more information about the build system, read the INSTALL file
that is generated by `autogen.sh` and comes with the release tar ball.
## Support
If you are having problems with Tinyproxy, please raise an
[issue on github](https://github.com/tinyproxy/tinyproxy/issues).
## Contributing
If you would like to contribute a feature, or a bug fix to the Tinyproxy
source, please clone the
[git repository from github](https://github.com/tinyproxy/tinyproxy.git)
and create a [pull request](https://github.com/tinyproxy/tinyproxy/pulls).
## Community
You can meet developers and users to discuss development,
patches and deployment issues in the `#tinyproxy` IRC channel on
Freenode (`irc.freenode.net`).
+1 -1
View File
@@ -38,7 +38,7 @@ against the current tree and I'll integrate it if possible.
* Include user authentication for accessing tinyproxy itself.
Administrators should be allowed to selectively allow certain users
access to tinyproxy via a user name/password pair. Check the
HTTP/1.1 RFC for more information.
HTTP/1.1 RFC for more information. [Suggested: Tyrone Tranmer]
==> https://www.banu.com/bugzilla/show_bug.cgi?id=13
+114 -55
View File
@@ -4,26 +4,44 @@
AC_PREREQ(2.54)
m4_define([tinyproxy_major_version], [1])
m4_define([tinyproxy_minor_version], [10])
m4_define([tinyproxy_micro_version], [0])
m4_define([tinyproxy_minor_version], [8])
m4_define([tinyproxy_micro_version], [3])
m4_define([tinyproxy_real_version],
[tinyproxy_major_version.tinyproxy_minor_version.tinyproxy_micro_version])
m4_define([tinyproxy_version], [tinyproxy_real_version])
# For overriding the version string. Comment out if not needed.
# m4_define([tinyproxy_version], [1.10.0])
# m4_define([tinyproxy_version], [1.8.2])
m4_define([tinyproxy_unstable],
m4_if(m4_eval(tinyproxy_minor_version % 2), [1], [yes], [no]))
m4_define([tinyproxy_stable],
m4_if(m4_eval(tinyproxy_minor_version % 2), [0], [yes], [no]))
AC_INIT([Tinyproxy], [tinyproxy_version],
[https://tinyproxy.github.io/],
[https://banu.com/tinyproxy/],
[tinyproxy])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([dist-bzip2 dist-xz])
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR([m4macros])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
TINYPROXY_MAJOR_VERSION=tinyproxy_major_version
TINYPROXY_MINOR_VERSION=tinyproxy_minor_version
TINYPROXY_MICRO_VERSION=tinyproxy_micro_version
TINYPROXY_REAL_VERSION=tinyproxy_real_version
TINYPROXY_VERSION=tinyproxy_version
TINYPROXY_UNSTABLE=tinyproxy_unstable
AC_SUBST(TINYPROXY_MAJOR_VERSION)
AC_SUBST(TINYPROXY_MINOR_VERSION)
AC_SUBST(TINYPROXY_MICRO_VERSION)
AC_SUBST(TINYPROXY_REAL_VERSION)
AC_SUBST(TINYPROXY_VERSION)
AC_SUBST(TINYPROXY_UNSTABLE)
dnl Temporarily defined here until we get tinyproxy-version.h
AC_DEFINE(TINYPROXY_VERSION, "tinyproxy_version", [Tinyproxy version number])
@@ -95,8 +113,8 @@ dnl Include support for reverse proxy?
AH_TEMPLATE([REVERSE_SUPPORT],
[Include support for reverse proxy.])
TP_ARG_ENABLE(reverse,
[Enable reverse proxying (default is YES)],
yes)
[Enable reverse proxying (default is NO)],
no)
if test x"$reverse_enabled" = x"yes"; then
ADDITIONAL_OBJECTS="$ADDITIONAL_OBJECTS reverse-proxy.o"
AC_DEFINE(REVERSE_SUPPORT)
@@ -106,13 +124,18 @@ dnl Include the transparent proxy support
AH_TEMPLATE([TRANSPARENT_PROXY],
[Include support for using tinyproxy as a transparent proxy.])
TP_ARG_ENABLE(transparent,
[Enable transparent proxying code (default is YES)],
yes)
[Enable transparent proxying code (default is NO)],
no)
if test x"$transparent_enabled" = x"yes"; then
ADDITIONAL_OBJECTS="$ADDITIONAL_OBJECTS transparent-proxy.o"
AC_DEFINE(TRANSPARENT_PROXY)
fi
dnl Check for broken regex library
TP_ARG_ENABLE(regexcheck,
[Check for working regex library (default is YES)],
yes)
# This is required to build test programs below
AC_PROG_CC
@@ -143,19 +166,48 @@ dnl
AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([sys/ioctl.h alloca.h memory.h malloc.h sysexits.h \
AC_CHECK_HEADERS([sys/ioctl.h sys/mman.h sys/resource.h \
sys/select.h sys/socket.h sys/time.h sys/uio.h \
sys/un.h arpa/inet.h netinet/in.h \
assert.h ctype.h errno.h fcntl.h grp.h io.h libintl.h \
netdb.h pwd.h regex.h signal.h stdarg.h stddef.h stdio.h \
sysexits.h syslog.h time.h wchar.h wctype.h \
values.h])
dnl OpenBSD machines don't like having malloc included (even if it's present)
dnl as they expect you to use stdlib.h
case "$target" in
*-openbsd*) ;;
*) AC_CHECK_HEADER(malloc.h);;
esac
dnl Checks for types
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_UNP_CHECK_TYPE(uint8_t, unsigned char)
AC_UNP_CHECK_TYPE(int16_t, short)
AC_UNP_CHECK_TYPE(uint16_t, unsigned short)
AC_UNP_CHECK_TYPE(int32_t, int)
AC_UNP_CHECK_TYPE(uint32_t, unsigned int)
AC_UNP_CHECK_TYPE(ssize_t, int)
AC_UNP_CHECK_TYPE(socklen_t, unsigned int)
AC_UNP_CHECK_TYPE(in_addr_t, uint32_t)
dnl Checks for libary functions
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([inet_ntoa strdup])
AC_CHECK_FUNCS([strlcpy strlcat setgroups])
AC_CHECK_FUNCS([gethostname inet_ntoa memchr memset select socket strcasecmp \
strchr strdup strerror strncasecmp strpbrk strstr strtol])
AC_CHECK_FUNCS([isascii memcpy setrlimit ftruncate regcomp regexec])
AC_CHECK_FUNCS([strlcpy strlcat])
dnl Enable extra warnings
DESIRED_FLAGS="-fdiagnostics-show-option -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wfloat-equal -Wundef -Wformat=2 -Wlogical-op -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Waggregate-return -Winit-self -Wpacked --std=c89 -ansi -Wno-overlength-strings -Wno-long-long -Wno-overlength-strings -Wdeclaration-after-statement -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-qual -Wcast-align -Wwrite-strings -Wp,-D_FORTIFY_SOURCE=2 -fno-common"
DESIRED_FLAGS="-fdiagnostics-show-option -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wfloat-equal -Wundef -Wformat=2 -Wlogical-op -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Waggregate-return -Winit-self -Wpacked --std=c89 -ansi -pedantic -Wc++-compat -Wno-long-long -Wno-overlength-strings -Wdeclaration-after-statement -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-qual -Wcast-align -Wwrite-strings -Wp,-D_FORTIFY_SOURCE=2 -fno-common"
if test -n "${MAINTAINER_MODE_FALSE}"; then
DESIRED_FLAGS="-Werror $DESIRED_FLAGS"
@@ -170,17 +222,57 @@ if test x"$debug_enabled" != x"yes" ; then
CFLAGS="-DNDEBUG $CFLAGS"
fi
AS_ECHO_N(["checking to see if linker understands -z,defs... "])
LDFLAGS_OLD="-Wl $LDFLAGS"
LDFLAGS="-Wl,-z,defs $LDFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
AS_ECHO("yes"),
AS_ECHO("no"); LDFLAGS="$LDFLAGS_OLD")
LDFLAGS="-Wl,-z,defs"
dnl
dnl Make sure we can actually handle the "--with-*" and "--enable-*" stuff.
dnl
dnl Handle the REGEX library
if test x"$ac_cv_func_regexec" != x"yes"; then
AC_MSG_ERROR([Could not locate the regexec() function])
else
if test x"$regexcheck_enabled" = x"yes" ; then
AC_MSG_CHECKING([whether the system's regex library is broken])
AC_CACHE_VAL(tinyproxy_cv_regex_broken,
[AC_TRY_RUN([
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#if HAVE_REGEX_H
# include <regex.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
int main(void)
{
regex_t blah;
if (regcomp(&blah, "foo.*bar", REG_NOSUB) != 0)
exit(1);
if (regexec(&blah, "foobar", 0, NULL, 0) != 0)
exit(1);
else
exit(0);
return 0;
}
],
tinyproxy_cv_regex_broken=no,
tinyproxy_cv_regex_broken=yes,
tinyproxy_cv_regex_broken=yes)])
AC_MSG_RESULT([$tinyproxy_cv_regex_broken])
if test x"$tinyproxy_cv_regex_broken" = x"yes" ; then
AC_MSG_ERROR([Your system's regexec() function is broken.])
fi
fi
fi
dnl
dnl Substitute the variables into the various Makefiles
dnl
@@ -190,28 +282,12 @@ AC_SUBST(CPPFLAGS)
AC_SUBST(LIBS)
AC_SUBST(ADDITIONAL_OBJECTS)
# Check for xml tools
AC_PATH_PROG(XSLTPROC, xsltproc, no)
AM_CONDITIONAL(HAVE_XSLTPROC, test "x$XSLTPROC" != "xno")
# Check for asciidoc
AC_PATH_PROG(A2X, a2x, no)
AM_CONDITIONAL(HAVE_A2X, test "x$A2X" != "xno")
# checking xmllint
AC_PATH_PROG(XMLLINT, xmllint, no)
if test "x$XMLLINT" != "xno"; then
AS_ECHO_N("testing xmllint... ")
echo "TEST" > conftest.txt
if $A2X -f docbook conftest.txt 2>/dev/null; then
AS_ECHO("ok")
else
AS_ECHO("failed")
XMLLINT="no"
if test x"$A2X" = x"no"; then
AC_MSG_ERROR([Test for asciidoc failed. See the file 'INSTALL' for help.])
fi
rm -f conftest.txt conftest.xml
fi
AM_CONDITIONAL(HAVE_XMLLINT, test "x$XMLLINT" != "xno")
AC_CONFIG_FILES([
Makefile
@@ -230,20 +306,3 @@ tests/scripts/Makefile
])
AC_OUTPUT
# the manpages are shipped in the release tarball and we don't want them to
# get regenerated if a2x is not available. the intermediate files from
# AC_CONFIG_FILES are created with config.status, which is created at configure
# runtime, so we need to touch them after config.status terminated to prevent
# make from rebuild them.
if test "x$A2X" = "xno"; then
touch docs/man5/tinyproxy.conf.txt
touch docs/man8/tinyproxy.txt
if test -e docs/man5/tinyproxy.conf.5 ; then
touch docs/man5/tinyproxy.conf.5
fi
if test -e docs/man8/tinyproxy.8 ; then
touch docs/man8/tinyproxy.8
fi
fi
+3 -8
View File
@@ -1,11 +1,9 @@
MAN5_FILES = \
tinyproxy.conf.txt
if HAVE_XMLLINT
A2X_ARGS = -d manpage -f manpage
else
A2X_ARGS = -d manpage -f manpage -L
endif
A2X_ARGS = \
-d manpage \
-f manpage
man_MANS = \
$(MAN5_FILES:.txt=.5)
@@ -20,6 +18,3 @@ endif
CLEANFILES = \
$(MAN5_FILES:.txt=.5) \
$(MAN5_FILES:.txt=.xml)
EXTRA_DIST = \
$(MAN5_FILES:.txt=.5)
+13 -14
View File
@@ -144,25 +144,21 @@ The possible keywords and their descriptions are as follows:
`X-Tinyproxy` containing the client's IP address to the request.
*Upstream*::
*No Upstream*::
This option allows you to set up a set of rules for deciding
whether an upstream proxy server is to be used, based on the
host or domain of the site being accessed. The rules are stored
in the order encountered in the configuration file and the
LAST matching rule wins. The following forms for specifying upstream
rules exist:
LAST matching rule wins. There are three possible forms for
specifying upstream rules:
* 'upstream type host:port' turns proxy upstream support on generally.
* 'upstream host:port' turns proxy upstream support on generally.
* 'upstream type user:pass@host:port' does the same, but uses the
supplied credentials for authentication.
* 'upstream host:port "site_spec"' turns on the upstream proxy for
the sites matching `site_spec`.
* 'upstream type host:port "site_spec"' turns on the upstream proxy
for the sites matching `site_spec`.
`type` can be one of `http`, `socks4`, `socks5`, `none`.
* 'upstream none "site_spec"' turns off upstream support for sites
* 'no upstream "site_spec"' turns off upstream support for sites
matching `site_spec`.
The site can be specified in various forms as a hostname, domain
@@ -347,7 +343,7 @@ BUGS
----
To report bugs in Tinyproxy, please visit
<https://tinyproxy.github.io/[https://tinyproxy.github.io/]>.
<https://www.banu.com/tinyproxy/[https://www.banu.com/tinyproxy/]>.
SEE ALSO
@@ -358,13 +354,16 @@ tinyproxy(8)
AUTHOR
------
This manpage was written by the Tinyproxy project team.
Written by the Tinyproxy project team.
COPYRIGHT
---------
Copyright (c) 1998-2018 the Tinyproxy authors.
Copyright (c) 1998-2000 Steven Young;
Copyright (c) 2000-2001 Robert James Kaes;
Copyright (c) 2009-2010 Mukund Sivaraman;
Copyright (c) 2009-2010 Michael Adam.
This program is distributed under the terms of the GNU General Public
License version 2 or above. See the COPYING file for additional
+3 -8
View File
@@ -1,11 +1,9 @@
MAN8_FILES = \
tinyproxy.txt
if HAVE_XMLLINT
A2X_ARGS = -d manpage -f manpage
else
A2X_ARGS = -d manpage -f manpage -L
endif
A2X_ARGS = \
-d manpage \
-f manpage
man_MANS = \
$(MAN8_FILES:.txt=.8)
@@ -20,6 +18,3 @@ endif
CLEANFILES = \
$(MAN8_FILES:.txt=.8) \
$(MAN8_FILES:.txt=.xml)
EXTRA_DIST= \
$(MAN8_FILES:.txt=.8)
+9 -3
View File
@@ -40,6 +40,9 @@ OPTIONS
*-h*::
Display a short help screen of command line arguments and exit.
*-l*::
Display the licensing agreement.
*-v*::
Display version information and exit.
@@ -133,7 +136,7 @@ BUGS
----
To report bugs in Tinyproxy, please visit
<https://tinyproxy.github.io/[https://tinyproxy.github.io/]>.
<https://www.banu.com/tinyproxy/[https://www.banu.com/tinyproxy/]>.
SEE ALSO
@@ -144,13 +147,16 @@ tinyproxy.conf(5)
AUTHOR
------
This manpage was written by the Tinyproxy project team.
Written by the Tinyproxy project team.
COPYRIGHT
---------
Copyright (c) 1998-2018 the Tinyproxy authors.
Copyright (c) 1998-2000 Steven Young;
Copyright (c) 2000-2001 Robert James Kaes;
Copyright (c) 2009-2010 Mukund Sivaraman;
Copyright (c) 2009-2010 Michael Adam.
This program is distributed under the terms of the GNU General Public
License version 2 or above. See the COPYING file for additional
+2 -4
View File
@@ -1,6 +1,4 @@
pkgsysconfdir = $(sysconfdir)/$(PACKAGE)
pkgsysconf_DATA = \
sysconf_DATA = \
tinyproxy.conf
EXTRA_DIST = \
@@ -10,7 +8,7 @@ edit = sed \
-e 's|@bindir[@]|$(bindir)|g' \
-e 's|@datadir[@]|$(datadir)|g' \
-e 's|@datarootdir[@]|$(datarootdir)|g' \
-e 's|@pkgsysconfdir[@]|$(pkgsysconfdir)|g' \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@localstatedir[@]|$(localstatedir)|g' \
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
-e 's|@prefix[@]|$(prefix)|g' \
+18 -37
View File
@@ -90,8 +90,7 @@ StatFile "@pkgdatadir@/stats.html"
# LogFile: Allows you to specify the location where information should
# be logged to. If you would prefer to log to syslog, then disable this
# and enable the Syslog directive. These directives are mutually
# exclusive. If neither Syslog nor LogFile are specified, output goes
# to stdout.
# exclusive.
#
#LogFile "@localstatedir@/log/tinyproxy/tinyproxy.log"
@@ -103,7 +102,7 @@ StatFile "@pkgdatadir@/stats.html"
#Syslog On
#
# LogLevel: Warning
# LogLevel:
#
# Set the logging level. Allowed settings are:
# Critical (least verbose)
@@ -122,7 +121,6 @@ LogLevel Info
#
# PidFile: Write the PID of the main tinyproxy thread to this file so it
# can be used for signalling purposes.
# If not specified, no pidfile will be written.
#
#PidFile "@localstatedir@/run/tinyproxy/tinyproxy.pid"
@@ -140,37 +138,25 @@ LogLevel Info
# The upstream rules allow you to selectively route upstream connections
# based on the host/domain of the site being accessed.
#
# Syntax: upstream type (user:pass@)ip:port ("domain")
# Or: upstream none "domain"
# The parts in parens are optional.
# Possible types are http, socks4, socks5, none
#
# For example:
# # connection to test domain goes through testproxy
# upstream http testproxy:8008 ".test.domain.invalid"
# upstream http testproxy:8008 ".our_testbed.example.com"
# upstream http testproxy:8008 "192.168.128.0/255.255.254.0"
#
# # upstream proxy using basic authentication
# upstream http user:pass@testproxy:8008 ".test.domain.invalid"
# upstream testproxy:8008 ".test.domain.invalid"
# upstream testproxy:8008 ".our_testbed.example.com"
# upstream testproxy:8008 "192.168.128.0/255.255.254.0"
#
# # no upstream proxy for internal websites and unqualified hosts
# upstream none ".internal.example.com"
# upstream none "www.example.com"
# upstream none "10.0.0.0/8"
# upstream none "192.168.0.0/255.255.254.0"
# upstream none "."
# no upstream ".internal.example.com"
# no upstream "www.example.com"
# no upstream "10.0.0.0/8"
# no upstream "192.168.0.0/255.255.254.0"
# no upstream "."
#
# # connection to these boxes go through their DMZ firewalls
# upstream http cust1_firewall:8008 "testbed_for_cust1"
# upstream http cust2_firewall:8008 "testbed_for_cust2"
# upstream cust1_firewall:8008 "testbed_for_cust1"
# upstream cust2_firewall:8008 "testbed_for_cust2"
#
# # default upstream is internet firewall
# upstream http firewall.internal.example.com:80
#
# You may also use SOCKS4/SOCKS5 upstream proxies:
# upstream socks4 127.0.0.1:9050
# upstream socks5 socksproxy:1080
# upstream firewall.internal.example.com:80
#
# The LAST matching rule wins the route decision. As you can see, you
# can use a host, or a domain:
@@ -180,7 +166,7 @@ LogLevel Info
# IP/bits matches network/mask
# IP/mask matches network/mask
#
#Upstream http some.remote.proxy:port
#Upstream some.remote.proxy:port
#
# MaxClients: This is the absolute highest number of threads which will
@@ -223,11 +209,6 @@ MaxRequestsPerChild 0
#
Allow 127.0.0.1
# BasicAuth: HTTP "Basic Authentication" for accessing the proxy.
# If there are any entries specified, access is only granted for authenticated
# users.
#BasicAuth user password
#
# AddHeader: Adds the specified headers to outgoing HTTP requests that
# Tinyproxy makes. Note that this option will not work for HTTPS
@@ -255,7 +236,7 @@ ViaProxyName "tinyproxy"
#
# Filter: This allows you to specify the location of the filter file.
#
#Filter "@pkgsysconfdir@/filter"
#Filter "@sysconfdir@/filter"
#
# FilterURLs: Filter based on URLs rather than domains.
@@ -302,12 +283,12 @@ ViaProxyName "tinyproxy"
# ConnectPort: This is a list of ports allowed by tinyproxy when the
# CONNECT method is used. To disable the CONNECT method altogether, set
# the value to 0. If no ConnectPort line is found, all ports are
# allowed.
# allowed (which is not very secure.)
#
# The following two ports are used by SSL.
#
#ConnectPort 443
#ConnectPort 563
ConnectPort 443
ConnectPort 563
#
# Configure one or more ReversePath directives to enable reverse proxy
+2 -1
View File
@@ -1,3 +1,4 @@
EXTRA_DIST = \
as-compiler-flag.m4 \
argenable.m4
argenable.m4 \
typecheck.m4
+103
View File
@@ -0,0 +1,103 @@
dnl Taken from Unix Network Programming, W. Richard Stevens
dnl ##################################################################
dnl We cannot use the AC_CHECK_TYPE macros becasue AC_CHECK_TYPE
dnl #includes only <sys/types.h>, <stdlib.h>, and <stddef.h>.
dnl Unfortunately, many implementations today hide typedefs in wierd
dnl locations: Solaris 2.5.1 has uint8_t and uint32_t in <pthread.h>.
dnl SunOS 4.1.x has int8_t in <sys/bittypes.h>.
dnl So we define our own macro AC_UNP_CHECK_TYPE that does the same
dnl #includes as "unp.h", and then looks for the typedef.
dnl
dnl This macro should be invoked after all the header checks have been
dnl performed, since we #include "confdefs.h" below, and then use the
dnl HAVE_foo_H values that is can #define.
dnl
AC_DEFUN([AC_UNP_CHECK_TYPE],
[AC_MSG_CHECKING(if $1 defined)
AC_CACHE_VAL(ac_cv_type_$1,
[AC_TRY_COMPILE(
[
#include "confdefs.h" /* the header built by configure so far */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
#ifdef HAVE_PTHREAD_H
# include <pthread.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
],
[ $1 foo ],
[ac_cv_type_$1=yes],
[ac_cv_type_$1=no])])
AC_MSG_RESULT([$ac_cv_type_$1])
if test $ac_cv_type_$1 = no ; then
AH_TEMPLATE([$1], [Defined with the proper type.])
AC_DEFINE($1, $2)
fi
])
-10
View File
@@ -1,10 +0,0 @@
#!/bin/sh
SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
BASE_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
AUTHORS_FILE="${BASE_DIR}/AUTHORS"
type git > /dev/null || exit
test -d "${BASE_DIR}/.git" || exit
git log --all --format='%aN' | sort -u > "${AUTHORS_FILE}"
+2 -6
View File
@@ -15,12 +15,10 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
pkgsysconfdir = $(sysconfdir)/$(PACKAGE)
bin_PROGRAMS = tinyproxy
sbin_PROGRAMS = tinyproxy
AM_CPPFLAGS = \
-DSYSCONFDIR=\"${pkgsysconfdir}\" \
-DSYSCONFDIR=\"${sysconfdir}\" \
-DLOCALSTATEDIR=\"${localstatedir}\"
tinyproxy_SOURCES = \
@@ -46,8 +44,6 @@ tinyproxy_SOURCES = \
utils.c utils.h \
vector.c vector.h \
upstream.c upstream.h \
basicauth.c basicauth.h \
base64.c base64.h \
connect-ports.c connect-ports.h
EXTRA_tinyproxy_SOURCES = filter.c filter.h \
+5 -11
View File
@@ -51,7 +51,7 @@ struct acl_s {
union {
char *string;
struct {
unsigned char network[IPV6_LEN];
unsigned char octet[IPV6_LEN];
unsigned char mask[IPV6_LEN];
} ip;
} address;
@@ -134,8 +134,7 @@ static int init_access_list(vector_t *access_list)
* -1 on failure
* 0 otherwise.
*/
int
insert_acl (char *location, acl_access_t access_type, vector_t *access_list)
int insert_acl (char *location, acl_access_t access_type, vector_t *access_list)
{
struct acl_s acl;
int ret;
@@ -159,11 +158,9 @@ insert_acl (char *location, acl_access_t access_type, vector_t *access_list)
*/
if (full_inet_pton (location, ip_dst) > 0) {
acl.type = ACL_NUMERIC;
memcpy (acl.address.ip.network, ip_dst, IPV6_LEN);
memcpy (acl.address.ip.octet, ip_dst, IPV6_LEN);
memset (acl.address.ip.mask, 0xff, IPV6_LEN);
} else {
int i;
/*
* At this point we're either a hostname or an
* IP address with a slash.
@@ -182,6 +179,7 @@ insert_acl (char *location, acl_access_t access_type, vector_t *access_list)
return -1;
acl.type = ACL_NUMERIC;
memcpy (acl.address.ip.octet, ip_dst, IPV6_LEN);
/* Check if the IP address before the netmask is
* an IPv6 address */
@@ -194,10 +192,6 @@ insert_acl (char *location, acl_access_t access_type, vector_t *access_list)
(p + 1, v6, &(acl.address.ip.mask[0]), IPV6_LEN)
< 0)
return -1;
for (i = 0; i < IPV6_LEN; i++)
acl.address.ip.network[i] = ip_dst[i] &
acl.address.ip.mask[i];
} else {
/* In all likelihood a string */
acl.type = ACL_STRING;
@@ -311,7 +305,7 @@ static int check_numeric_acl (const struct acl_s *acl, const char *ip)
for (i = 0; i != IPV6_LEN; ++i) {
x = addr[i] & acl->address.ip.mask[i];
y = acl->address.ip.network[i];
y = acl->address.ip.octet[i] & acl->address.ip.mask[i];
/* If x and y don't match, the IP addresses don't match */
if (x != y)
-57
View File
@@ -1,57 +0,0 @@
/* tinyproxy - A fast light-weight HTTP proxy
* this file Copyright (C) 2016-2018 rofl0r
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "base64.h"
static const char base64_tbl[64] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/*
rofl0r's base64 impl (taken from libulz)
takes count bytes from src, writing base64 encoded string into dst.
dst needs to be at least BASE64ENC_BYTES(count) + 1 bytes in size.
the string in dst will be zero-terminated.
*/
void base64enc(char *dst, const void* src, size_t count)
{
unsigned const char *s = src;
char* d = dst;
while(count) {
int i = 0, n = *s << 16;
s++;
count--;
if(count) {
n |= *s << 8;
s++;
count--;
i++;
}
if(count) {
n |= *s;
s++;
count--;
i++;
}
*d++ = base64_tbl[(n >> 18) & 0x3f];
*d++ = base64_tbl[(n >> 12) & 0x3f];
*d++ = i ? base64_tbl[(n >> 6) & 0x3f] : '=';
*d++ = i == 2 ? base64_tbl[n & 0x3f] : '=';
}
*d = 0;
}
-29
View File
@@ -1,29 +0,0 @@
/* tinyproxy - A fast light-weight HTTP proxy
* this file Copyright (C) 2016-2018 rofl0r
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef TINYPROXY_BASE64_H
#define TINYPROXY_BASE64_H
#include <stddef.h>
/* calculates number of bytes base64-encoded stream of N bytes will take. */
#define BASE64ENC_BYTES(N) (((N+2)/3)*4)
void base64enc(char *dst, const void* src, size_t count);
#endif
-98
View File
@@ -1,98 +0,0 @@
/* tinyproxy - A fast light-weight HTTP proxy
* This file: Copyright (C) 2016-2017 rofl0r
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "main.h"
#include "basicauth.h"
#include "conns.h"
#include "heap.h"
#include "html-error.h"
#include "log.h"
#include "conf.h"
#include "base64.h"
/*
* Create basic-auth token in buf.
* Returns strlen of token on success,
* -1 if user/pass missing
* 0 if user/pass too long
*/
ssize_t basicauth_string(const char *user, const char *pass,
char *buf, size_t bufsize)
{
char tmp[256+2];
int l;
if (!user || !pass) return -1;
l = snprintf(tmp, sizeof tmp, "%s:%s", user, pass);
if (l < 0 || l >= (ssize_t) sizeof tmp) return 0;
if (bufsize < (BASE64ENC_BYTES((unsigned)l) + 1)) return 0;
base64enc(buf, tmp, l);
return BASE64ENC_BYTES(l);
}
/*
* Add entry to the basicauth list
*/
void basicauth_add (vector_t authlist,
const char *user, const char *pass)
{
char b[BASE64ENC_BYTES((256+2)-1) + 1];
ssize_t ret;
ret = basicauth_string(user, pass, b, sizeof b);
if (ret == -1) {
log_message (LOG_WARNING,
"Illegal basicauth rule: missing user or pass");
return;
} else if (ret == 0) {
log_message (LOG_WARNING,
"User / pass in basicauth rule too long");
return;
}
if (vector_append(authlist, b, ret + 1) == -ENOMEM) {
log_message (LOG_ERR,
"Unable to allocate memory in basicauth_add()");
return;
}
log_message (LOG_INFO,
"Added basic auth user : %s", user);
}
/*
* Check if a user/password combination (encoded as base64)
* is in the basicauth list.
* return 1 on success, 0 on failure.
*/
int basicauth_check (vector_t authlist, const char *authstring)
{
ssize_t vl, i;
size_t el;
const char* entry;
vl = vector_length (authlist);
if (vl == -EINVAL) return 0;
for (i = 0; i < vl; i++) {
entry = vector_getentry (authlist, i, &el);
if (strcmp (authstring, entry) == 0)
return 1;
}
return 0;
}
-35
View File
@@ -1,35 +0,0 @@
/* tinyproxy - A fast light-weight HTTP proxy
* Copyright (C) 2005 Robert James Kaes <rjkaes@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* See 'basicauth.c' for detailed information. */
#ifndef TINYPROXY_BASICAUTH_H
#define TINYPROXY_BASICAUTH_H
#include <stddef.h>
#include "vector.h"
extern ssize_t basicauth_string(const char *user, const char *pass,
char *buf, size_t bufsize);
extern void basicauth_add (vector_t authlist,
const char *user, const char *pass);
extern int basicauth_check (vector_t authlist, const char *authstring);
#endif
+5 -3
View File
@@ -236,7 +236,8 @@ ssize_t read_buffer (int fd, struct buffer_s * buffptr)
"readbuff: add_to_buffer() error.");
bytesin = -1;
}
} else if (bytesin == 0) {
} else {
if (bytesin == 0) {
/* connection was closed by client */
bytesin = -1;
} else {
@@ -253,12 +254,13 @@ ssize_t read_buffer (int fd, struct buffer_s * buffptr)
break;
default:
log_message (LOG_ERR,
"read_buffer: read() failed on fd %d: %s",
fd, strerror(errno));
"readbuff: recv() error \"%s\" on file descriptor %d",
strerror (errno), fd);
bytesin = -1;
break;
}
}
}
safefree (buffer);
return bytesin;
+8 -136
View File
@@ -32,7 +32,8 @@
#include "utils.h"
#include "conf.h"
static vector_t listen_fds;
static int listenfd;
static socklen_t addrlen;
/*
* Stores the internal data needed for each child (connection)
@@ -186,13 +187,8 @@ static void child_main (struct child_s *ptr)
int connfd;
struct sockaddr *cliaddr;
socklen_t clilen;
fd_set rfds;
int maxfd = 0;
ssize_t i;
int ret;
cliaddr = (struct sockaddr *)
safemalloc (sizeof(struct sockaddr_storage));
cliaddr = (struct sockaddr *) safemalloc (addrlen);
if (!cliaddr) {
log_message (LOG_CRIT,
"Could not allocate memory for child address.");
@@ -200,82 +196,11 @@ static void child_main (struct child_s *ptr)
}
ptr->connects = 0;
srand(time(NULL));
/*
* We have to wait for connections on multiple fds,
* so use select.
*/
FD_ZERO(&rfds);
for (i = 0; i < vector_length(listen_fds); i++) {
int *fd = (int *) vector_getentry(listen_fds, i, NULL);
ret = socket_nonblocking(*fd);
if (ret != 0) {
log_message(LOG_ERR, "Failed to set the listening "
"socket %d to non-blocking: %s",
fd, strerror(errno));
exit(1);
}
FD_SET(*fd, &rfds);
maxfd = max(maxfd, *fd);
}
while (!config.quit) {
int listenfd = -1;
ptr->status = T_WAITING;
clilen = sizeof(struct sockaddr_storage);
ret = select(maxfd + 1, &rfds, NULL, NULL, NULL);
if (ret == -1) {
if (errno == EINTR) {
continue;
}
log_message (LOG_ERR, "error calling select: %s",
strerror(errno));
exit(1);
} else if (ret == 0) {
log_message (LOG_WARNING, "Strange: select returned 0 "
"but we did not specify a timeout...");
continue;
}
for (i = 0; i < vector_length(listen_fds); i++) {
int *fd = (int *) vector_getentry(listen_fds, i, NULL);
if (FD_ISSET(*fd, &rfds)) {
/*
* only accept the connection on the first
* fd that we find readable. - fair?
*/
listenfd = *fd;
break;
}
}
if (listenfd == -1) {
log_message(LOG_WARNING, "Strange: None of our listen "
"fds was readable after select");
continue;
}
ret = socket_blocking(listenfd);
if (ret != 0) {
log_message(LOG_ERR, "Failed to set listening "
"socket %d to blocking for accept: %s",
listenfd, strerror(errno));
exit(1);
}
/*
* We have a socket that is readable.
* Continue handling this connection.
*/
clilen = addrlen;
connfd = accept (listenfd, cliaddr, &clilen);
@@ -539,66 +464,13 @@ void child_kill_children (int sig)
}
}
/**
* Listen on the various configured interfaces
*/
int child_listening_sockets(vector_t listen_addrs, uint16_t port)
int child_listening_sock (uint16_t port)
{
int ret;
ssize_t i;
assert (port > 0);
if (listen_fds == NULL) {
listen_fds = vector_create();
if (listen_fds == NULL) {
log_message (LOG_ERR, "Could not create the list "
"of listening fds");
return -1;
}
}
if ((listen_addrs == NULL) ||
(vector_length(listen_addrs) == 0))
{
/*
* no Listen directive:
* listen on the wildcard address(es)
*/
ret = listen_sock(NULL, port, listen_fds);
return ret;
}
for (i = 0; i < vector_length(listen_addrs); i++) {
const char *addr;
addr = (char *)vector_getentry(listen_addrs, i, NULL);
if (addr == NULL) {
log_message(LOG_WARNING,
"got NULL from listen_addrs - skipping");
continue;
}
ret = listen_sock(addr, port, listen_fds);
if (ret != 0) {
return ret;
}
}
return 0;
listenfd = listen_sock (port, &addrlen);
return listenfd;
}
void child_close_sock (void)
{
ssize_t i;
for (i = 0; i < vector_length(listen_fds); i++) {
int *fd = (int *) vector_getentry(listen_fds, i, NULL);
close (*fd);
}
vector_delete(listen_fds);
listen_fds = NULL;
close (listenfd);
}
+1 -3
View File
@@ -21,8 +21,6 @@
#ifndef TINYPROXY_CHILD_H
#define TINYPROXY_CHILD_H
#include "vector.h"
typedef enum {
CHILD_MAXCLIENTS,
CHILD_MAXSPARESERVERS,
@@ -32,7 +30,7 @@ typedef enum {
} child_config_t;
extern short int child_pool_create (void);
extern int child_listening_sockets (vector_t listen_addrs, uint16_t port);
extern int child_listening_sock (uint16_t port);
extern void child_close_sock (void);
extern void child_main_loop (void);
extern void child_kill_children (int sig);
+108 -41
View File
@@ -32,68 +32,135 @@
/*
* Include standard headers which are used through-out tinyproxy
*/
/* standard C headers - we can safely assume they exist. */
#include <stddef.h>
#include <stdint.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/* standard POSIX headers - they need to be there as well. */
# include <errno.h>
# include <fcntl.h>
# include <netdb.h>
# include <signal.h>
# include <stdarg.h>
# include <strings.h>
# include <syslog.h>
# include <wchar.h>
# include <wctype.h>
# include <sys/mman.h>
# include <sys/select.h>
# include <sys/socket.h>
# include <sys/stat.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
# include <sys/wait.h>
# include <sys/uio.h>
# include <sys/un.h>
# include <sys/time.h>
# include <time.h>
# include <inttypes.h>
# include <sys/resource.h>
# include <netinet/in.h>
# include <assert.h>
# include <arpa/inet.h>
# include <grp.h>
# include <pwd.h>
# include <regex.h>
/* rest - some oddball headers */
#endif
#ifdef HAVE_VALUES_H
# include <values.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#endif
#ifdef HAVE_ASSERT_H
# include <assert.h>
#endif
#ifdef HAVE_CTYPE_H
# include <ctype.h>
#endif
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>
#endif
#ifdef HAVE_MEMORY_H
# include <memory.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_REGEX_H
# include <regex.h>
#endif
#ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
#ifdef HAVE_STDARG_H
# include <stdarg.h>
#endif
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#else
# ifdef HAVE_MALLOC_H
# include <malloc.h>
# endif
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_SYSEXITS_H
# include <sysexits.h>
#endif
#ifdef HAVE_SYSLOG_H
# include <syslog.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_WCHAR_H
# include <wchar.h>
#endif
#ifdef HAVE_WCTYPE_H
# include <wctype.h>
#endif
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
/*
* If MSG_NOSIGNAL is not defined, define it to be zero so that it doesn't
+37 -111
View File
@@ -36,7 +36,6 @@
#include "reverse-proxy.h"
#include "upstream.h"
#include "connect-ports.h"
#include "basicauth.h"
/*
* The configuration directives are defined in the structure below. Each
@@ -117,7 +116,6 @@ static HANDLE_FUNC (handle_nop)
} /* do nothing function */
static HANDLE_FUNC (handle_allow);
static HANDLE_FUNC (handle_basicauth);
static HANDLE_FUNC (handle_anonymous);
static HANDLE_FUNC (handle_bind);
static HANDLE_FUNC (handle_bindsame);
@@ -232,7 +230,6 @@ struct {
handle_deny),
STDCONF ("bind", "(" IP "|" IPV6 ")", handle_bind),
/* other */
STDCONF ("basicauth", ALNUM WS ALNUM, handle_basicauth),
STDCONF ("errorfile", INT WS STR, handle_errorfile),
STDCONF ("addheader", STR WS STR, handle_addheader),
@@ -252,15 +249,13 @@ struct {
STDCONF ("reversepath", STR "(" WS STR ")?", handle_reversepath),
#endif
#ifdef UPSTREAM_SUPPORT
/* upstream is rather complicated */
{
BEGIN "(upstream)" WS "(none)" WS STR END, handle_upstream_no, NULL
BEGIN "(no" WS "upstream)" WS STR END, handle_upstream_no, NULL
},
{
BEGIN "(upstream)" WS "(http|socks4|socks5)" WS
"(" ALNUM /*username*/ ":" ALNUM /*password*/ "@" ")?"
"(" IP "|" ALNUM ")"
":" INT "(" WS STR ")?"
END, handle_upstream, NULL
BEGIN "(upstream)" WS "(" IP "|" ALNUM ")" ":" INT "(" WS STR
")?" END, handle_upstream, NULL
},
#endif
/* loglevel */
@@ -293,8 +288,7 @@ static void free_config (struct config_s *conf)
safefree (conf->stathost);
safefree (conf->user);
safefree (conf->group);
vector_delete(conf->listen_addrs);
vector_delete(conf->basicauth_list);
safefree (conf->ipAddr);
#ifdef FILTER_ENABLE
safefree (conf->filter);
#endif /* FILTER_ENABLE */
@@ -471,18 +465,8 @@ static void initialize_with_defaults (struct config_s *conf,
conf->group = safestrdup (defaults->group);
}
if (defaults->listen_addrs) {
ssize_t i;
conf->listen_addrs = vector_create();
for (i=0; i < vector_length(defaults->listen_addrs); i++) {
char *addr;
size_t size;
addr = (char *)vector_getentry(defaults->listen_addrs,
i, &size);
vector_append(conf->listen_addrs, addr, size);
}
if (defaults->ipAddr) {
conf->ipAddr = safestrdup (defaults->ipAddr);
}
#ifdef FILTER_ENABLE
@@ -775,7 +759,12 @@ static HANDLE_FUNC (handle_xtinyproxy)
static HANDLE_FUNC (handle_syslog)
{
#ifdef HAVE_SYSLOG_H
return set_bool_arg (&conf->syslog, line, &match[2]);
#else
fprintf (stderr, "Syslog support not compiled in executable.\n");
return 1;
#endif
}
static HANDLE_FUNC (handle_bindsame)
@@ -876,6 +865,7 @@ static HANDLE_FUNC (handle_deny)
static HANDLE_FUNC (handle_bind)
{
#ifndef TRANSPARENT_PROXY
int r = set_string_arg (&conf->bind_address, line, &match[2]);
if (r)
@@ -883,31 +873,20 @@ static HANDLE_FUNC (handle_bind)
log_message (LOG_INFO,
"Outgoing connections bound to IP %s", conf->bind_address);
return 0;
#else
fprintf (stderr,
"\"Bind\" cannot be used with transparent support enabled.\n");
return 1;
#endif
}
static HANDLE_FUNC (handle_listen)
{
char *arg = get_string_arg (line, &match[2]);
int r = set_string_arg (&conf->ipAddr, line, &match[2]);
if (arg == NULL) {
return -1;
}
if (conf->listen_addrs == NULL) {
conf->listen_addrs = vector_create();
if (conf->listen_addrs == NULL) {
log_message(LOG_WARNING, "Could not create a list "
"of listen addresses.");
safefree(arg);
return -1;
}
}
vector_append (conf->listen_addrs, arg, strlen(arg) + 1);
log_message(LOG_INFO, "Added address [%s] to listen addresses.", arg);
safefree (arg);
if (r)
return r;
log_message (LOG_INFO, "Listening on IP %s", conf->ipAddr);
return 0;
}
@@ -954,7 +933,6 @@ static HANDLE_FUNC (handle_addheader)
/*
* Log level's strings.
*/
struct log_levels_s {
const char *string;
@@ -989,27 +967,6 @@ static HANDLE_FUNC (handle_loglevel)
return -1;
}
static HANDLE_FUNC (handle_basicauth)
{
char *user, *pass;
user = get_string_arg(line, &match[2]);
if (!user)
return -1;
pass = get_string_arg(line, &match[3]);
if (!pass) {
safefree (user);
return -1;
}
if (!conf->basicauth_list) {
conf->basicauth_list = vector_create ();
}
basicauth_add (conf->basicauth_list, user, pass);
safefree (user);
safefree (pass);
return 0;
}
#ifdef FILTER_ENABLE
static HANDLE_FUNC (handle_filter)
{
@@ -1086,58 +1043,27 @@ static HANDLE_FUNC (handle_reversepath)
#endif
#ifdef UPSTREAM_SUPPORT
static enum proxy_type pt_from_string(const char *s)
{
static const char pt_map[][7] = {
[PT_NONE] = "none",
[PT_HTTP] = "http",
[PT_SOCKS4] = "socks4",
[PT_SOCKS5] = "socks5",
};
unsigned i;
for (i = 0; i < sizeof(pt_map)/sizeof(pt_map[0]); i++)
if (!strcmp(pt_map[i], s))
return i;
return PT_NONE;
}
static HANDLE_FUNC (handle_upstream)
{
char *ip;
int port, mi = 2;
char *domain = 0, *user = 0, *pass = 0, *tmp;
enum proxy_type pt;
int port;
char *domain;
tmp = get_string_arg (line, &match[mi]);
pt = pt_from_string(tmp);
safefree(tmp);
mi += 2;
if (match[mi].rm_so != -1)
user = get_string_arg (line, &match[mi]);
mi++;
if (match[mi].rm_so != -1)
pass = get_string_arg (line, &match[mi]);
mi++;
ip = get_string_arg (line, &match[mi]);
ip = get_string_arg (line, &match[2]);
if (!ip)
return -1;
mi += 5;
port = (int) get_long_arg (line, &match[7]);
port = (int) get_long_arg (line, &match[mi]);
mi += 3;
if (match[mi].rm_so != -1)
domain = get_string_arg (line, &match[mi]);
upstream_add (ip, port, domain, user, pass, pt, &conf->upstream_list);
safefree (user);
safefree (pass);
if (match[10].rm_so != -1) {
domain = get_string_arg (line, &match[10]);
if (domain) {
upstream_add (ip, port, domain, &conf->upstream_list);
safefree (domain);
}
} else {
upstream_add (ip, port, NULL, &conf->upstream_list);
}
safefree (ip);
return 0;
@@ -1147,11 +1073,11 @@ static HANDLE_FUNC (handle_upstream_no)
{
char *domain;
domain = get_string_arg (line, &match[3]);
domain = get_string_arg (line, &match[2]);
if (!domain)
return -1;
upstream_add (NULL, 0, domain, 0, 0, PT_NONE, &conf->upstream_list);
upstream_add (NULL, 0, domain, &conf->upstream_list);
safefree (domain);
return 0;
+1 -2
View File
@@ -37,7 +37,6 @@ typedef struct {
* Hold all the configuration time information.
*/
struct config_s {
vector_t basicauth_list;
char *logf_name;
char *config_file;
unsigned int syslog; /* boolean */
@@ -47,7 +46,7 @@ struct config_s {
unsigned int quit; /* boolean */
char *user;
char *group;
vector_t listen_addrs;
char *ipAddr;
#ifdef FILTER_ENABLE
char *filter;
unsigned int filter_url; /* boolean */
+1 -1
View File
@@ -38,7 +38,7 @@ void add_connect_port_allowed (int port, vector_t *connect_ports)
log_message (LOG_INFO,
"Adding Port [%d] to the list allowed by CONNECT", port);
vector_append (*connect_ports, &port, sizeof (port));
vector_append (*connect_ports, (void **) &port, sizeof (port));
}
/*
+11 -33
View File
@@ -50,7 +50,6 @@ struct hashbucket_s {
};
struct hashmap_s {
uint32_t seed;
unsigned int size;
hashmap_iter end_iterator;
@@ -64,12 +63,9 @@ struct hashmap_s {
* The contents of the key are converted to lowercase, so this function
* is not case-sensitive.
*
* This is Dan Bernstein's hash function as described, for example, here:
* http://www.cse.yorku.ca/~oz/hash.html
*
* If any of the arguments are invalid a negative number is returned.
*/
static int hashfunc (const char *key, unsigned int size, uint32_t seed)
static int hashfunc (const char *key, unsigned int size)
{
uint32_t hash;
@@ -78,8 +74,12 @@ static int hashfunc (const char *key, unsigned int size, uint32_t seed)
if (size == 0)
return -ERANGE;
for (hash = seed; *key != '\0'; key++) {
hash = ((hash << 5) + hash) ^ tolower (*key);
for (hash = tolower (*key++); *key != '\0'; key++) {
uint32_t bit = (hash & 1) ? (1 << (sizeof (uint32_t) - 1)) : 0;
hash >>= 1;
hash += tolower (*key) + bit;
}
/* Keep the hash within the table limits */
@@ -104,7 +104,6 @@ hashmap_t hashmap_create (unsigned int nbuckets)
if (!ptr)
return NULL;
ptr->seed = (uint32_t)rand();
ptr->size = nbuckets;
ptr->buckets = (struct hashbucket_s *) safecalloc (nbuckets,
sizeof (struct
@@ -202,7 +201,7 @@ hashmap_insert (hashmap_t map, const char *key, const void *data, size_t len)
if (!data || len < 1)
return -ERANGE;
hash = hashfunc (key, map->size, map->seed);
hash = hashfunc (key, map->size);
if (hash < 0)
return hash;
@@ -383,7 +382,7 @@ ssize_t hashmap_search (hashmap_t map, const char *key)
if (map == NULL || key == NULL)
return -EINVAL;
hash = hashfunc (key, map->size, map->seed);
hash = hashfunc (key, map->size);
if (hash < 0)
return hash;
@@ -417,7 +416,7 @@ ssize_t hashmap_entry_by_key (hashmap_t map, const char *key, void **data)
if (!map || !key || !data)
return -EINVAL;
hash = hashfunc (key, map->size, map->seed);
hash = hashfunc (key, map->size);
if (hash < 0)
return hash;
@@ -452,7 +451,7 @@ ssize_t hashmap_remove (hashmap_t map, const char *key)
if (map == NULL || key == NULL)
return -EINVAL;
hash = hashfunc (key, map->size, map->seed);
hash = hashfunc (key, map->size);
if (hash < 0)
return hash;
@@ -493,24 +492,3 @@ ssize_t hashmap_remove (hashmap_t map, const char *key)
/* The key was not found, so return 0 */
return deleted;
}
/*
* Look up the value for a variable.
*/
char *lookup_variable (hashmap_t map, const char *varname)
{
hashmap_iter result_iter;
char *key;
char *data;
result_iter = hashmap_find (map, varname);
if (hashmap_is_end (map, result_iter))
return (NULL);
if (hashmap_return_entry (map, result_iter,
&key, (void **) &data) < 0)
return (NULL);
return (data);
}
-5
View File
@@ -117,9 +117,4 @@ extern ssize_t hashmap_search (hashmap_t map, const char *key);
*/
extern ssize_t hashmap_remove (hashmap_t map, const char *key);
/*
* Look up the value for a variable.
*/
extern char *lookup_variable (hashmap_t map, const char *varname);
#endif /* _HASHMAP_H */
+28 -19
View File
@@ -62,7 +62,7 @@ static char *get_html_file (unsigned int errornum)
hashmap_iter result_iter;
char errornbuf[ERRORNUM_BUFSIZE];
char *key;
char *val;
static char *val;
assert (errornum >= 100 && errornum < 1000);
@@ -83,6 +83,27 @@ static char *get_html_file (unsigned int errornum)
return (val);
}
/*
* Look up the value for a variable.
*/
static char *lookup_variable (struct conn_s *connptr, const char *varname)
{
hashmap_iter result_iter;
char *key;
static char *data;
result_iter = hashmap_find (connptr->error_variables, varname);
if (hashmap_is_end (connptr->error_variables, result_iter))
return (NULL);
if (hashmap_return_entry (connptr->error_variables, result_iter,
&key, (void **) &data) < 0)
return (NULL);
return (data);
}
/*
* Send an already-opened file to the client with variable substitution.
*/
@@ -105,7 +126,7 @@ send_html_file (FILE *infile, struct conn_s *connptr)
if (in_variable) {
*p = '\0';
varval = (const char *)
lookup_variable (connptr->error_variables,
lookup_variable (connptr,
varstart);
if (!varval)
varval = "(unknown)";
@@ -132,7 +153,6 @@ send_html_file (FILE *infile, struct conn_s *connptr)
} else
in_variable = 0;
/* FALL THROUGH */
default:
if (!in_variable) {
r = write_message (connptr->client_fd,
@@ -157,24 +177,13 @@ send_html_file (FILE *infile, struct conn_s *connptr)
int send_http_headers (struct conn_s *connptr, int code, const char *message)
{
const char headers[] =
const char *headers =
"HTTP/1.0 %d %s\r\n"
"Server: %s/%s\r\n"
"Content-Type: text/html\r\n"
"%s"
"Connection: close\r\n" "\r\n";
const char auth_str[] =
"Proxy-Authenticate: Basic realm=\""
PACKAGE_NAME "\"\r\n";
/* according to rfc7235, the 407 error must be accompanied by
a Proxy-Authenticate header field. */
const char *add = code == 407 ? auth_str : "";
"Content-Type: text/html\r\n" "Connection: close\r\n" "\r\n";
return (write_message (connptr->client_fd, headers,
code, message, PACKAGE, VERSION,
add));
code, message, PACKAGE, VERSION));
}
/*
@@ -203,7 +212,7 @@ int send_http_error_message (struct conn_s *connptr)
error_file = get_html_file (connptr->error_number);
if (!(infile = fopen (error_file, "r"))) {
char *detail = lookup_variable (connptr->error_variables, "detail");
char *detail = lookup_variable (connptr, "detail");
return (write_message (connptr->client_fd, fallback_error,
connptr->error_number,
connptr->error_string,
@@ -271,7 +280,7 @@ int add_standard_vars (struct conn_s *connptr)
add_error_variable (connptr, "date", timebuf);
add_error_variable (connptr, "website",
"https://tinyproxy.github.io/");
"https://banu.com/tinyproxy/");
add_error_variable (connptr, "version", VERSION);
add_error_variable (connptr, "package", PACKAGE);
+6 -21
View File
@@ -70,14 +70,7 @@ static unsigned int logging_initialized = FALSE; /* boolean */
*/
int open_log_file (const char *log_file_name)
{
if (log_file_name == NULL) {
if(config.godaemon == FALSE)
log_file_fd = fileno(stdout);
else
log_file_fd = -1;
} else {
log_file_fd = create_file_safely (log_file_name, FALSE);
}
return log_file_fd;
}
@@ -86,7 +79,7 @@ int open_log_file (const char *log_file_name)
*/
void close_log_file (void)
{
if (log_file_fd < 0 || log_file_fd == fileno(stdout)) {
if (log_file_fd < 0) {
return;
}
@@ -161,9 +154,6 @@ void log_message (int level, const char *fmt, ...)
goto out;
}
if(!config.syslog && log_file_fd == -1)
goto out;
if (config.syslog) {
#ifdef HAVE_VSYSLOG_H
vsyslog (level, fmt, args);
@@ -198,13 +188,8 @@ void log_message (int level, const char *fmt, ...)
ret = write (log_file_fd, str, strlen (str));
if (ret == -1) {
config.syslog = TRUE;
log_message(LOG_CRIT, "ERROR: Could not write to log "
"file %s: %s.",
config.logf_name, strerror(errno));
log_message(LOG_CRIT,
"Falling back to syslog logging");
log_message (LOG_WARNING,
"Could not write to log file");
}
fsync (log_file_fd);
@@ -217,7 +202,7 @@ out:
/*
* This needs to send any stored log messages.
*/
static void send_stored_logs (void)
void send_stored_logs (void)
{
char *string;
char *ptr;
@@ -273,10 +258,10 @@ int setup_logging (void)
config.syslog = TRUE;
log_message (LOG_CRIT, "ERROR: Could not create log "
"file %s: %s.",
"file %s: %s.\n",
config.logf_name, strerror (errno));
log_message (LOG_CRIT,
"Falling back to syslog logging.");
"Falling back to syslog logging\n");
}
}
+10
View File
@@ -77,7 +77,16 @@
* don't advocate this, but it could be useful at times.)
*/
#ifdef HAVE_SYSLOG_H
# include <syslog.h>
#else
# define LOG_CRIT 2
# define LOG_ERR 3
# define LOG_WARNING 4
# define LOG_NOTICE 5
# define LOG_INFO 6
# define LOG_DEBUG 7
#endif
#define LOG_CONN 8 /* extra to log connections without the INFO stuff */
@@ -106,6 +115,7 @@ extern void close_log_file (void);
extern void log_message (int level, const char *fmt, ...);
extern void set_log_level (int level);
extern void send_stored_logs (void);
extern int setup_logging (void);
extern void shutdown_logging (void);
+54 -33
View File
@@ -86,6 +86,37 @@ display_version (void)
printf ("%s %s\n", PACKAGE, VERSION);
}
/*
* Display the copyright and license for this program.
*/
static void
display_license (void)
{
display_version ();
printf ("\
Copyright 1998 Steven Young (sdyoung@well.com)\n\
Copyright 1998-2002 Robert James Kaes (rjkaes@users.sourceforge.net)\n\
Copyright 1999 George Talusan (gstalusan@uwaterloo.ca)\n\
Copyright 2000 Chris Lightfoot (chris@ex-parrot.com)\n\
Copyright 2009-2010 Mukund Sivaraman (muks@banu.com)\n\
Copyright 2009-2010 Michael Adam (obnox@samba.org)\n\
\n\
This program is free software; you can redistribute it and/or modify\n\
it under the terms of the GNU General Public License as published by\n\
the Free Software Foundation; either version 2, or (at your option)\n\
any later version.\n\
\n\
This program is distributed in the hope that it will be useful,\n\
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
GNU General Public License for more details.\n\
\n\
You should have received a copy of the GNU General Public License\n\
along with this program; if not, write to the Free Software\n\
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.\n");
}
/*
* Display usage to the user.
*/
@@ -100,6 +131,7 @@ display_usage (void)
" -d Do not daemonize (run in foreground).\n"
" -c FILE Use an alternate configuration file.\n"
" -h Display this usage information.\n"
" -l Display the license.\n"
" -v Display version information.\n");
/* Display the modes compiled into tinyproxy */
@@ -139,8 +171,8 @@ display_usage (void)
printf (" None\n");
printf ("\n"
"For support and bug reporting instructions, please visit\n"
"<https://tinyproxy.github.io/>.\n");
"For bug reporting instructions, please see:\n"
"<https://banu.com/tinyproxy/>.\n");
}
static int
@@ -173,12 +205,16 @@ process_cmdline (int argc, char **argv, struct config_s *conf)
{
int opt;
while ((opt = getopt (argc, argv, "c:vdh")) != EOF) {
while ((opt = getopt (argc, argv, "c:vldh")) != EOF) {
switch (opt) {
case 'v':
display_version ();
exit (EX_OK);
case 'l':
display_license ();
exit (EX_OK);
case 'd':
conf->godaemon = FALSE;
break;
@@ -241,16 +277,6 @@ change_user (const char *program)
exit (EX_NOPERM);
}
#ifdef HAVE_SETGROUPS
/* Drop all supplementary groups, otherwise these are inherited from the calling process */
if (setgroups (0, NULL) < 0) {
fprintf (stderr,
"%s: Unable to drop supplementary groups.\n",
program);
exit (EX_NOPERM);
}
#endif
log_message (LOG_INFO, "Now running as group \"%s\".",
config.group);
}
@@ -300,8 +326,8 @@ static void initialize_config_defaults (struct config_s *conf)
conf->errorpages = NULL;
conf->stathost = safestrdup (TINYPROXY_STATHOST);
conf->idletimeout = MAX_IDLE_TIME;
conf->logf_name = NULL;
conf->pidpath = NULL;
conf->logf_name = safestrdup (LOCALSTATEDIR "/log/tinyproxy/tinyproxy.log");
conf->pidpath = safestrdup (LOCALSTATEDIR "/run/tinyproxy/tinyproxy.pid");
}
/**
@@ -360,13 +386,8 @@ main (int argc, char **argv)
anonymous_insert ("Content-Type");
}
if (config.godaemon == TRUE) {
if (!config.syslog && config.logf_name == NULL)
fprintf(stderr, "WARNING: logging deactivated "
"(can't log to stdout when daemonized)\n");
if (config.godaemon == TRUE)
makedaemon ();
}
if (set_signal_handler (SIGPIPE, SIG_IGN) == SIG_ERR) {
fprintf (stderr, "%s: Could not set the \"SIGPIPE\" signal.\n",
@@ -380,21 +401,12 @@ main (int argc, char **argv)
#endif /* FILTER_ENABLE */
/* Start listening on the selected port. */
if (child_listening_sockets(config.listen_addrs, config.port) < 0) {
fprintf (stderr, "%s: Could not create listening sockets.\n",
if (child_listening_sock (config.port) < 0) {
fprintf (stderr, "%s: Could not create listening socket.\n",
argv[0]);
exit (EX_OSERR);
}
/* Create pid file before we drop privileges */
if (config.pidpath) {
if (pidfile_create (config.pidpath) < 0) {
fprintf (stderr, "%s: Could not create PID file.\n",
argv[0]);
exit (EX_OSERR);
}
}
/* Switch to a different user if we're running as root */
if (geteuid () == 0)
change_user (argv[0]);
@@ -407,6 +419,15 @@ main (int argc, char **argv)
exit (EX_SOFTWARE);
}
/* Create pid file after we drop privileges */
if (config.pidpath) {
if (pidfile_create (config.pidpath) < 0) {
fprintf (stderr, "%s: Could not create PID file.\n",
argv[0]);
exit (EX_OSERR);
}
}
if (child_pool_create () < 0) {
fprintf (stderr,
"%s: Could not create the pool of children.\n",
@@ -446,7 +467,7 @@ main (int argc, char **argv)
child_close_sock ();
/* Remove the PID file */
if (config.pidpath != NULL && unlink (config.pidpath) < 0) {
if (unlink (config.pidpath) < 0) {
log_message (LOG_WARNING,
"Could not remove PID file \"%s\": %s.",
config.pidpath, strerror (errno));
+7 -16
View File
@@ -32,11 +32,10 @@
* Write the buffer to the socket. If an EINTR occurs, pick up and try
* again. Keep sending until the buffer has been sent.
*/
ssize_t safe_write (int fd, const void *buf, size_t count)
ssize_t safe_write (int fd, const char *buffer, size_t count)
{
ssize_t len;
size_t bytestosend;
const char *buffer = buf;
assert (fd >= 0);
assert (buffer != NULL);
@@ -68,7 +67,7 @@ ssize_t safe_write (int fd, const void *buf, size_t count)
* Matched pair for safe_write(). If an EINTR occurs, pick up and try
* again.
*/
ssize_t safe_read (int fd, void *buffer, size_t count)
ssize_t safe_read (int fd, char *buffer, size_t count)
{
ssize_t len;
@@ -192,11 +191,7 @@ ssize_t readline (int fd, char **whole_buffer)
goto CLEANUP;
}
ret = recv (fd, line_ptr->data, diff, 0);
if (ret == -1) {
goto CLEANUP;
}
recv (fd, line_ptr->data, diff, 0);
line_ptr->len = diff;
if (ptr) {
@@ -250,10 +245,8 @@ CLEANUP:
* Convert the network address into either a dotted-decimal or an IPv6
* hex string.
*/
const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
{
const char *result;
assert (sa != NULL);
assert (buf != NULL);
assert (buflen != 0);
@@ -264,8 +257,7 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
{
struct sockaddr_in *sa_in = (struct sockaddr_in *) sa;
result = inet_ntop (AF_INET, &sa_in->sin_addr, buf,
buflen);
inet_ntop (AF_INET, &sa_in->sin_addr, buf, buflen);
break;
}
case AF_INET6:
@@ -273,8 +265,7 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
struct sockaddr_in6 *sa_in6 =
(struct sockaddr_in6 *) sa;
result = inet_ntop (AF_INET6, &sa_in6->sin6_addr, buf,
buflen);
inet_ntop (AF_INET6, &sa_in6->sin6_addr, buf, buflen);
break;
}
default:
@@ -282,7 +273,7 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
return NULL;
}
return result;
return buf;
}
/*
+3 -3
View File
@@ -21,13 +21,13 @@
#ifndef TINYPROXY_NETWORK_H
#define TINYPROXY_NETWORK_H
extern ssize_t safe_write (int fd, const void *buf, size_t count);
extern ssize_t safe_read (int fd, void *buf, size_t count);
extern ssize_t safe_write (int fd, const char *buffer, size_t count);
extern ssize_t safe_read (int fd, char *buffer, size_t count);
extern int write_message (int fd, const char *fmt, ...);
extern ssize_t readline (int fd, char **whole_buffer);
extern const char *get_ip_string (struct sockaddr *sa, char *buf, size_t len);
extern char *get_ip_string (struct sockaddr *sa, char *buf, size_t len);
extern int full_inet_pton (const char *ip, void *dst);
#endif
+61 -259
View File
@@ -48,7 +48,6 @@
#include "upstream.h"
#include "connect-ports.h"
#include "conf.h"
#include "basicauth.h"
/*
* Maximum length of a HTTP line
@@ -62,11 +61,9 @@
#ifdef UPSTREAM_SUPPORT
# define UPSTREAM_CONFIGURED() (config.upstream_list != NULL)
# define UPSTREAM_HOST(host) upstream_get(host, config.upstream_list)
# define UPSTREAM_IS_HTTP(conn) (conn->upstream_proxy != NULL && conn->upstream_proxy->type == PT_HTTP)
#else
# define UPSTREAM_CONFIGURED() (0)
# define UPSTREAM_HOST(host) (NULL)
# define UPSTREAM_IS_HTTP(up) (0)
#endif
/*
@@ -189,22 +186,18 @@ static int strip_return_port (char *host)
}
/*
* Pull the information out of the URL line.
* This expects urls with the initial '<proto>://'
* part stripped and hence can handle http urls,
* (proxied) ftp:// urls and https-requests that
* come in without the proto:// part via CONNECT.
* Pull the information out of the URL line. This will handle both HTTP
* and FTP (proxied) URLs.
*/
static int extract_url (const char *url, int default_port,
struct request_s *request)
static int extract_http_url (const char *url, struct request_s *request)
{
char *p;
int len;
int port;
/* Split the URL on the slash to separate host from path */
p = strchr (url, '/');
if (p != NULL) {
int len;
len = p - url;
request->host = (char *) safemalloc (len + 1);
memcpy (request->host, url, len);
@@ -223,15 +216,12 @@ static int extract_url (const char *url, int default_port,
/* Find a proper port in www.site.com:8001 URLs */
port = strip_return_port (request->host);
request->port = (port != 0) ? port : default_port;
request->port = (port != 0) ? port : HTTP_PORT;
/* Remove any surrounding '[' and ']' from IPv6 literals */
p = strrchr (request->host, ']');
if (p && (*(request->host) == '[')) {
memmove(request->host, request->host + 1,
strlen(request->host) - 2);
*p = '\0';
p--;
request->host++;
*p = '\0';
}
@@ -246,6 +236,31 @@ ERROR_EXIT:
return -1;
}
/*
* Extract the URL from a SSL connection.
*/
static int extract_ssl_url (const char *url, struct request_s *request)
{
request->host = (char *) safemalloc (strlen (url) + 1);
if (!request->host)
return -1;
if (sscanf (url, "%[^:]:%hu", request->host, &request->port) == 2) ;
else if (sscanf (url, "%s", request->host) == 1)
request->port = HTTP_PORT_SSL;
else {
log_message (LOG_ERR, "extract_ssl_url: Can't parse URL.");
safefree (request->host);
return -1;
}
/* Remove the username/password if they're present */
strip_username_password (request->host);
return 0;
}
/*
* Create a connection for HTTP connections.
*/
@@ -270,17 +285,6 @@ establish_http_connection (struct conn_s *connptr, struct request_s *request)
"Connection: close\r\n",
request->method, request->path,
request->host, portbuff);
} else if (connptr->upstream_proxy &&
connptr->upstream_proxy->type == PT_HTTP &&
connptr->upstream_proxy->ua.authstr) {
return write_message (connptr->server_fd,
"%s %s HTTP/1.0\r\n"
"Host: %s%s\r\n"
"Connection: close\r\n"
"Proxy-Authorization: Basic %s\r\n",
request->method, request->path,
request->host, portbuff,
connptr->upstream_proxy->ua.authstr);
} else {
return write_message (connptr->server_fd,
"%s %s HTTP/1.0\r\n"
@@ -371,6 +375,15 @@ BAD_REQUEST_ERROR:
goto fail;
}
if (!url) {
log_message (LOG_ERR,
"process_request: Null URL on file descriptor %d",
connptr->client_fd);
indicate_http_error (connptr, 400, "Bad Request",
"detail", "Request has an empty URL",
"url", url, NULL);
goto fail;
}
#ifdef REVERSE_SUPPORT
if (config.reversepath_list != NULL) {
/*
@@ -383,18 +396,12 @@ BAD_REQUEST_ERROR:
reverse_url = reverse_rewrite_url (connptr, hashofheaders, url);
if (reverse_url != NULL) {
safefree (url);
url = reverse_url;
} else if (config.reverseonly) {
log_message (LOG_ERR,
"Bad request, no mapping for '%s' found",
url);
indicate_http_error (connptr, 400, "Bad Request",
"detail", "No mapping found for "
"requested url", "url", url, NULL);
if (!reverse_url) {
goto fail;
}
safefree (url);
url = reverse_url;
}
#endif
@@ -403,14 +410,14 @@ BAD_REQUEST_ERROR:
{
char *skipped_type = strstr (url, "//") + 2;
if (extract_url (skipped_type, HTTP_PORT, request) < 0) {
if (extract_http_url (skipped_type, request) < 0) {
indicate_http_error (connptr, 400, "Bad Request",
"detail", "Could not parse URL",
"url", url, NULL);
goto fail;
}
} else if (strcmp (request->method, "CONNECT") == 0) {
if (extract_url (url, HTTP_PORT_SSL, request) < 0) {
if (extract_ssl_url (url, request) < 0) {
indicate_http_error (connptr, 400, "Bad Request",
"detail", "Could not parse URL",
"url", url, NULL);
@@ -511,7 +518,6 @@ static int pull_client_data (struct conn_s *connptr, long int length)
{
char *buffer;
ssize_t len;
int ret;
buffer =
(char *) safemalloc (min (MAXBUFFSIZE, (unsigned long int) length));
@@ -537,30 +543,18 @@ static int pull_client_data (struct conn_s *connptr, long int length)
* return and line feed) at the end of a POST message. These
* need to be eaten for tinyproxy to work correctly.
*/
ret = socket_nonblocking (connptr->client_fd);
if (ret != 0) {
log_message(LOG_ERR, "Failed to set the client socket "
"to non-blocking: %s", strerror(errno));
goto ERROR_EXIT;
}
socket_nonblocking (connptr->client_fd);
len = recv (connptr->client_fd, buffer, 2, MSG_PEEK);
ret = socket_blocking (connptr->client_fd);
if (ret != 0) {
log_message(LOG_ERR, "Failed to set the client socket "
"to blocking: %s", strerror(errno));
goto ERROR_EXIT;
}
socket_blocking (connptr->client_fd);
if (len < 0 && errno != EAGAIN)
goto ERROR_EXIT;
if ((len == 2) && CHECK_CRLF (buffer, len)) {
ssize_t bytes_read;
ssize_t ret;
bytes_read = read (connptr->client_fd, buffer, 2);
if (bytes_read == -1) {
ret = read (connptr->client_fd, buffer, 2);
if (ret == -1) {
log_message
(LOG_WARNING,
"Could not read two bytes from POST message");
@@ -616,13 +610,6 @@ add_header_to_connection (hashmap_t hashofheaders, char *header, size_t len)
return hashmap_insert (hashofheaders, header, sep, len);
}
/*
* Define maximum number of headers that we accept.
* This should be big enough to handle legitimate cases,
* but limited to avoid DoS.
*/
#define MAX_HEADERS 10000
/*
* Read all the headers from the stream
*/
@@ -630,7 +617,6 @@ static int get_all_headers (int fd, hashmap_t hashofheaders)
{
char *line = NULL;
char *header = NULL;
int count;
char *tmp;
ssize_t linelen;
ssize_t len = 0;
@@ -639,7 +625,7 @@ static int get_all_headers (int fd, hashmap_t hashofheaders)
assert (fd >= 0);
assert (hashofheaders != NULL);
for (count = 0; count < MAX_HEADERS; count++) {
for (;;) {
if ((linelen = readline (fd, &line)) <= 0) {
safefree (header);
safefree (line);
@@ -705,14 +691,6 @@ static int get_all_headers (int fd, hashmap_t hashofheaders)
safefree (line);
}
/*
* If we get here, this means we reached MAX_HEADERS count.
* Bail out with error.
*/
safefree (header);
safefree (line);
return -1;
}
/*
@@ -839,7 +817,7 @@ done:
/*
* Number of buckets to use internally in the hashmap.
*/
#define HEADER_BUCKETS 256
#define HEADER_BUCKETS 32
/*
* Here we loop through all the headers the client is sending. If we
@@ -867,10 +845,10 @@ process_client_headers (struct conn_s *connptr, hashmap_t hashofheaders)
/*
* Don't send headers if there's already an error, if the request was
* a stats request, or if this was a CONNECT method (unless upstream
* http proxy is in use.)
* proxy is in use.)
*/
if (connptr->server_fd == -1 || connptr->show_stats
|| (connptr->connect_method && ! UPSTREAM_IS_HTTP(connptr))) {
|| (connptr->connect_method && (connptr->upstream_proxy == NULL))) {
log_message (LOG_INFO,
"Not sending client headers to remote machine");
return 0;
@@ -1159,19 +1137,8 @@ static void relay_connection (struct conn_s *connptr)
int maxfd = max (connptr->client_fd, connptr->server_fd) + 1;
ssize_t bytes_received;
ret = socket_nonblocking (connptr->client_fd);
if (ret != 0) {
log_message(LOG_ERR, "Failed to set the client socket "
"to non-blocking: %s", strerror(errno));
return;
}
ret = socket_nonblocking (connptr->server_fd);
if (ret != 0) {
log_message(LOG_ERR, "Failed to set the server socket "
"to non-blocking: %s", strerror(errno));
return;
}
socket_nonblocking (connptr->client_fd);
socket_nonblocking (connptr->server_fd);
last_access = time (NULL);
@@ -1246,14 +1213,7 @@ static void relay_connection (struct conn_s *connptr)
* Here the server has closed the connection... write the
* remainder to the client and then exit.
*/
ret = socket_blocking (connptr->client_fd);
if (ret != 0) {
log_message(LOG_ERR,
"Failed to set client socket to blocking: %s",
strerror(errno));
return;
}
socket_blocking (connptr->client_fd);
while (buffer_size (connptr->sbuffer) > 0) {
if (write_buffer (connptr->client_fd, connptr->sbuffer) < 0)
break;
@@ -1263,14 +1223,7 @@ static void relay_connection (struct conn_s *connptr)
/*
* Try to send any remaining data to the server if we can.
*/
ret = socket_blocking (connptr->server_fd);
if (ret != 0) {
log_message(LOG_ERR,
"Failed to set server socket to blocking: %s",
strerror(errno));
return;
}
socket_blocking (connptr->server_fd);
while (buffer_size (connptr->cbuffer) > 0) {
if (write_buffer (connptr->server_fd, connptr->cbuffer) < 0)
break;
@@ -1279,122 +1232,6 @@ static void relay_connection (struct conn_s *connptr)
return;
}
static int
connect_to_upstream_proxy(struct conn_s *connptr, struct request_s *request)
{
unsigned len;
unsigned char buff[512]; /* won't use more than 7 + 255 */
unsigned short port;
size_t ulen, passlen;
struct hostent *host;
struct upstream *cur_upstream = connptr->upstream_proxy;
ulen = cur_upstream->ua.user ? strlen(cur_upstream->ua.user) : 0;
passlen = cur_upstream->pass ? strlen(cur_upstream->pass) : 0;
log_message(LOG_CONN,
"Established connection to %s proxy \"%s\" using file descriptor %d.",
proxy_type_name(cur_upstream->type), cur_upstream->host, connptr->server_fd);
if (cur_upstream->type == PT_SOCKS4) {
buff[0] = 4; /* socks version */
buff[1] = 1; /* connect command */
port = htons(request->port);
memcpy(&buff[2], &port, 2); /* dest port */
host = gethostbyname(request->host);
memcpy(&buff[4], host->h_addr_list[0], 4); /* dest ip */
buff[8] = 0; /* user */
if (9 != safe_write(connptr->server_fd, buff, 9))
return -1;
if (8 != safe_read(connptr->server_fd, buff, 8))
return -1;
if (buff[0]!=0 || buff[1]!=90)
return -1;
} else if (cur_upstream->type == PT_SOCKS5) {
/* init */
int n_methods = ulen ? 2 : 1;
buff[0] = 5; /* socks version */
buff[1] = n_methods; /* number of methods */
buff[2] = 0; /* no auth method */
if (ulen) buff[3] = 2; /* auth method -> username / password */
if (2+n_methods != safe_write(connptr->server_fd, buff, 2+n_methods))
return -1;
if (2 != safe_read(connptr->server_fd, buff, 2))
return -1;
if (buff[0] != 5 || (buff[1] != 0 && buff[1] != 2))
return -1;
if (buff[1] == 2) {
/* authentication */
char in[2];
char out[515];
char *cur = out;
size_t c;
*cur++ = 1; /* version */
c = ulen & 0xFF;
*cur++ = c;
memcpy(cur, cur_upstream->ua.user, c);
cur += c;
c = passlen & 0xFF;
*cur++ = c;
memcpy(cur, cur_upstream->pass, c);
cur += c;
if((cur - out) != safe_write(connptr->server_fd, out, cur - out))
return -1;
if(2 != safe_read(connptr->server_fd, in, 2))
return -1;
if(in[1] != 0 || !(in[0] == 5 || in[0] == 1)) {
return -1;
}
}
/* connect */
buff[0] = 5; /* socks version */
buff[1] = 1; /* connect */
buff[2] = 0; /* reserved */
buff[3] = 3; /* domainname */
len=strlen(request->host);
if(len>255)
return -1;
buff[4] = len; /* length of domainname */
memcpy(&buff[5], request->host, len); /* dest ip */
port = htons(request->port);
memcpy(&buff[5+len], &port, 2); /* dest port */
if (7+len != safe_write(connptr->server_fd, buff, 7+len))
return -1;
if (4 != safe_read(connptr->server_fd, buff, 4))
return -1;
if (buff[0]!=5 || buff[1]!=0)
return -1;
switch(buff[3]) {
case 1: len=4; break; /* ip v4 */
case 4: len=16; break; /* ip v6 */
case 3: /* domainname */
if (1 != safe_read(connptr->server_fd, buff, 1))
return -1;
len = buff[0]; /* max = 255 */
break;
default: return -1;
}
if (2+len != safe_read(connptr->server_fd, buff, 2+len))
return -1;
} else {
return -1;
}
if (connptr->connect_method)
return 0;
return establish_http_connection(connptr, request);
}
/*
* Establish a connection to the upstream proxy server.
*/
@@ -1438,9 +1275,6 @@ connect_to_upstream (struct conn_s *connptr, struct request_s *request)
return -1;
}
if (cur_upstream->type != PT_HTTP)
return connect_to_upstream_proxy(connptr, request);
log_message (LOG_CONN,
"Established connection to upstream proxy \"%s\" "
"using file descriptor %d.",
@@ -1504,7 +1338,7 @@ get_request_entity(struct conn_s *connptr)
nread = read_buffer (connptr->client_fd, connptr->cbuffer);
if (nread < 0) {
log_message (LOG_ERR,
"Error reading readable client_fd %d",
"Error reading readble client_fd %d",
connptr->client_fd);
ret = -1;
} else {
@@ -1608,38 +1442,6 @@ void handle_connection (int fd)
goto fail;
}
if (config.basicauth_list != NULL) {
ssize_t len;
char *authstring;
int failure = 1;
len = hashmap_entry_by_key (hashofheaders, "proxy-authorization",
(void **) &authstring);
if (len == 0) {
update_stats (STAT_DENIED);
indicate_http_error (connptr, 407, "Proxy Authentication Required",
"detail",
"This proxy requires authentication.",
NULL);
goto fail;
}
if ( /* currently only "basic" auth supported */
(strncmp(authstring, "Basic ", 6) == 0 ||
strncmp(authstring, "basic ", 6) == 0) &&
basicauth_check (config.basicauth_list, authstring + 6) == 1)
failure = 0;
if(failure) {
update_stats (STAT_DENIED);
indicate_http_error (connptr, 401, "Unauthorized",
"detail",
"The administrator of this proxy has not configured "
"it to service requests from you.",
NULL);
goto fail;
}
hashmap_remove (hashofheaders, "proxy-authorization");
}
/*
* Add any user-specified headers (AddHeader directive) to the
* outgoing HTTP request.
@@ -1692,7 +1494,7 @@ void handle_connection (int fd)
goto fail;
}
if (!connptr->connect_method || UPSTREAM_IS_HTTP(connptr)) {
if (!(connptr->connect_method && (connptr->upstream_proxy == NULL))) {
if (process_server_headers (connptr) < 0) {
update_stats (STAT_BADCONN);
goto fail;
+7 -1
View File
@@ -156,7 +156,13 @@ char *reverse_rewrite_url (struct conn_s *connptr, hashmap_t hashofheaders,
}
}
if (rewrite_url == NULL) {
/* Forward proxy support off and no reverse path match found */
if (config.reverseonly && !rewrite_url) {
log_message (LOG_ERR, "Bad request");
indicate_http_error (connptr, 400, "Bad Request",
"detail",
"Request has an invalid URL", "url", url,
NULL);
return NULL;
}
+38 -112
View File
@@ -84,9 +84,6 @@ int opensock (const char *host, int port, const char *bind_to)
assert (host != NULL);
assert (port > 0);
log_message(LOG_INFO,
"opensock: opening connection to %s:%d", host, port);
memset (&hints, 0, sizeof (struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
@@ -100,9 +97,6 @@ int opensock (const char *host, int port, const char *bind_to)
return -1;
}
log_message(LOG_INFO,
"opensock: getaddrinfo returned for %s:%d", host, port);
ressave = res;
do {
sockfd =
@@ -168,100 +162,21 @@ int socket_blocking (int sock)
return fcntl (sock, F_SETFL, flags & ~O_NONBLOCK);
}
/**
* Try to listen on one socket based on the addrinfo
* as returned from getaddrinfo.
*
* Return the file descriptor upon success, -1 upon error.
*/
static int listen_on_one_socket(struct addrinfo *ad)
{
int listenfd;
int ret;
const int on = 1;
char numerichost[NI_MAXHOST];
int flags = NI_NUMERICHOST;
ret = getnameinfo(ad->ai_addr, ad->ai_addrlen,
numerichost, NI_MAXHOST, NULL, 0, flags);
if (ret != 0) {
log_message(LOG_ERR, "error calling getnameinfo: %s",
gai_strerror(errno));
return -1;
}
log_message(LOG_INFO, "trying to listen on host[%s], family[%d], "
"socktype[%d], proto[%d]", numerichost,
ad->ai_family, ad->ai_socktype, ad->ai_protocol);
listenfd = socket(ad->ai_family, ad->ai_socktype, ad->ai_protocol);
if (listenfd == -1) {
log_message(LOG_ERR, "socket() failed: %s", strerror(errno));
return -1;
}
ret = setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
if (ret != 0) {
log_message(LOG_ERR,
"setsockopt failed to set SO_REUSEADDR: %s",
strerror(errno));
close(listenfd);
return -1;
}
if (ad->ai_family == AF_INET6) {
ret = setsockopt(listenfd, IPPROTO_IPV6, IPV6_V6ONLY, &on,
sizeof(on));
if (ret != 0) {
log_message(LOG_ERR,
"setsockopt failed to set IPV6_V6ONLY: %s",
strerror(errno));
close(listenfd);
return -1;
}
}
ret = bind(listenfd, ad->ai_addr, ad->ai_addrlen);
if (ret != 0) {
log_message(LOG_ERR, "bind failed: %s", strerror (errno));
close(listenfd);
return -1;
}
ret = listen(listenfd, MAXLISTEN);
if (ret != 0) {
log_message(LOG_ERR, "listen failed: %s", strerror(errno));
close(listenfd);
return -1;
}
log_message(LOG_INFO, "listening on fd [%d]", listenfd);
return listenfd;
}
/*
* Start listening on a socket. Create a socket with the selected port.
* If the provided address is NULL, we may listen on multiple sockets,
* e.g. the wildcard addresse for IPv4 and IPv6, depending on what is
* supported. If the address is not NULL, we only listen on the first
* address reported by getaddrinfo that works.
*
* Upon success, the listen-fds are added to the listen_fds list
* and 0 is returned. Upon error, -1 is returned.
* Start listening to a socket. Create a socket with the selected port.
* The size of the socket address will be returned to the caller through
* the pointer, while the socket is returned as a default return.
* - rjkaes
*/
int listen_sock (const char *addr, uint16_t port, vector_t listen_fds)
int listen_sock (uint16_t port, socklen_t * addrlen)
{
struct addrinfo hints, *result, *rp;
char portstr[6];
int ret = -1;
int listenfd;
const int on = 1;
assert (port > 0);
assert (listen_fds != NULL);
log_message(LOG_INFO, "listen_sock called with addr = '%s'",
addr == NULL ? "(NULL)" : addr);
assert (addrlen != NULL);
memset (&hints, 0, sizeof (struct addrinfo));
hints.ai_family = AF_UNSPEC;
@@ -270,7 +185,7 @@ int listen_sock (const char *addr, uint16_t port, vector_t listen_fds)
snprintf (portstr, sizeof (portstr), "%d", port);
if (getaddrinfo (addr, portstr, &hints, &result) != 0) {
if (getaddrinfo (config.ipAddr, portstr, &hints, &result) != 0) {
log_message (LOG_ERR,
"Unable to getaddrinfo() because of %s",
strerror (errno));
@@ -278,34 +193,45 @@ int listen_sock (const char *addr, uint16_t port, vector_t listen_fds)
}
for (rp = result; rp != NULL; rp = rp->ai_next) {
int listenfd;
listenfd = listen_on_one_socket(rp);
if (listenfd == -1) {
listenfd = socket (rp->ai_family, rp->ai_socktype,
rp->ai_protocol);
if (listenfd == -1)
continue;
setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, &on,
sizeof (on));
if (bind (listenfd, rp->ai_addr, rp->ai_addrlen) == 0)
break; /* success */
close (listenfd);
}
vector_append (listen_fds, &listenfd, sizeof(int));
if (rp == NULL) {
/* was not able to bind to any address */
log_message (LOG_ERR,
"Unable to bind listening socket "
"to any address.");
/* success */
ret = 0;
if (addr != NULL) {
/*
* Unless wildcard is requested, only listen
* on the first result that works.
*/
break;
}
freeaddrinfo (result);
return -1;
}
if (ret != 0) {
log_message (LOG_ERR, "Unable to listen on any address.");
if (listen (listenfd, MAXLISTEN) < 0) {
log_message (LOG_ERR,
"Unable to start listening socket because of %s",
strerror (errno));
close (listenfd);
freeaddrinfo (result);
return -1;
}
*addrlen = rp->ai_addrlen;
freeaddrinfo (result);
return ret;
return listenfd;
}
/*
+1 -3
View File
@@ -28,10 +28,8 @@
#define MAXLINE (1024 * 4)
#include "vector.h"
extern int opensock (const char *host, int port, const char *bind_to);
extern int listen_sock (const char *addr, uint16_t port, vector_t listen_fds);
extern int listen_sock (uint16_t port, socklen_t * addrlen);
extern int socket_nonblocking (int sock);
extern int socket_blocking (int sock);
+7 -20
View File
@@ -45,7 +45,7 @@ static int build_url (char **url, const char *host, int port, const char *path)
assert (path != NULL);
len = strlen (host) + strlen (path) + 14;
*url = (char *) saferealloc (*url, len);
*url = (char *) safemalloc (len);
if (*url == NULL)
return -1;
@@ -60,7 +60,6 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
socklen_t length;
char *data;
size_t ulen = strlen (*url);
ssize_t i;
length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data);
if (length <= 0) {
@@ -106,29 +105,17 @@ do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
"process_request: trans Host %s %s for %d",
request->method, *url, connptr->client_fd);
}
if (conf->listen_addrs == NULL) {
return 1;
}
for (i = 0; i < vector_length(conf->listen_addrs); i++) {
const char *addr;
addr = (char *)vector_getentry(conf->listen_addrs, i, NULL);
if (addr && strcmp(request->host, addr) == 0) {
if (conf->ipAddr && strcmp (request->host, conf->ipAddr) == 0) {
log_message (LOG_ERR,
"transparent: destination IP %s is local "
"on socket fd %d",
request->host, connptr->client_fd);
"process_request: destination IP is localhost %d",
connptr->client_fd);
indicate_http_error (connptr, 400, "Bad Request",
"detail",
"You tried to connect to the "
"machine the proxy is running on",
"url", *url, NULL);
"You tried to connect to the machine "
"the proxy is running on", "url", *url,
NULL);
return 0;
}
}
return 1;
}
+12 -48
View File
@@ -27,28 +27,12 @@
#include "upstream.h"
#include "heap.h"
#include "log.h"
#include "base64.h"
#include "basicauth.h"
#ifdef UPSTREAM_SUPPORT
const char *
proxy_type_name(proxy_type type)
{
switch(type) {
case PT_NONE: return "none";
case PT_HTTP: return "http";
case PT_SOCKS4: return "socks4";
case PT_SOCKS5: return "socks5";
default: return "unknown";
}
}
/**
* Construct an upstream struct from input data.
*/
static struct upstream *upstream_build (const char *host, int port, const char *domain,
const char *user, const char *pass,
proxy_type type)
static struct upstream *upstream_build (const char *host, int port, const char *domain)
{
char *ptr;
struct upstream *up;
@@ -60,25 +44,8 @@ static struct upstream *upstream_build (const char *host, int port, const char *
return NULL;
}
up->type = type;
up->host = up->domain = up->ua.user = up->pass = NULL;
up->host = up->domain = NULL;
up->ip = up->mask = 0;
if (user) {
if (type == PT_HTTP) {
char b[BASE64ENC_BYTES((256+2)-1) + 1];
ssize_t ret;
ret = basicauth_string(user, pass, b, sizeof b);
if (ret == 0) {
log_message (LOG_ERR,
"User / pass in upstream config too long");
return NULL;
}
up->ua.authstr = safestrdup (b);
} else {
up->ua.user = safestrdup (user);
up->pass = safestrdup (pass);
}
}
if (domain == NULL) {
if (!host || host[0] == '\0' || port < 1) {
@@ -90,9 +57,9 @@ static struct upstream *upstream_build (const char *host, int port, const char *
up->host = safestrdup (host);
up->port = port;
log_message (LOG_INFO, "Added upstream %s %s:%d for [default]",
proxy_type_name(type), host, port);
} else if (host == NULL || type == PT_NONE) {
log_message (LOG_INFO, "Added upstream %s:%d for [default]",
host, port);
} else if (host == NULL) {
if (!domain || domain[0] == '\0') {
log_message (LOG_WARNING,
"Nonsense no-upstream rule: empty domain");
@@ -124,7 +91,7 @@ static struct upstream *upstream_build (const char *host, int port, const char *
log_message (LOG_INFO, "Added no-upstream for %s", domain);
} else {
if (!host || host[0] == '\0' || port < 1 || !domain
|| domain[0] == '\0') {
|| domain == '\0') {
log_message (LOG_WARNING,
"Nonsense upstream rule: invalid parameters");
goto fail;
@@ -134,15 +101,13 @@ static struct upstream *upstream_build (const char *host, int port, const char *
up->port = port;
up->domain = safestrdup (domain);
log_message (LOG_INFO, "Added upstream %s %s:%d for %s",
proxy_type_name(type), host, port, domain);
log_message (LOG_INFO, "Added upstream %s:%d for %s",
host, port, domain);
}
return up;
fail:
safefree (up->ua.user);
safefree (up->pass);
safefree (up->host);
safefree (up->domain);
safefree (up);
@@ -154,12 +119,11 @@ fail:
* Add an entry to the upstream list
*/
void upstream_add (const char *host, int port, const char *domain,
const char *user, const char *pass,
proxy_type type, struct upstream **upstream_list)
struct upstream **upstream_list)
{
struct upstream *up;
up = upstream_build (host, port, domain, user, pass, type);
up = upstream_build (host, port, domain);
if (up == NULL) {
return;
}
@@ -238,8 +202,8 @@ struct upstream *upstream_get (char *host, struct upstream *up)
up = NULL;
if (up)
log_message (LOG_INFO, "Found upstream proxy %s %s:%d for %s",
proxy_type_name(up->type), up->host, up->port, host);
log_message (LOG_INFO, "Found upstream proxy %s:%d for %s",
up->host, up->port, host);
else
log_message (LOG_INFO, "No upstream proxy for %s", host);
+1 -16
View File
@@ -31,32 +31,17 @@
* Even if upstream support is not compiled into tinyproxy, this
* structure still needs to be defined.
*/
typedef enum proxy_type {
PT_NONE = 0,
PT_HTTP,
PT_SOCKS4,
PT_SOCKS5
} proxy_type;
struct upstream {
struct upstream *next;
char *domain; /* optional */
char *host;
union {
char *user;
char *authstr;
} ua;
char *pass;
int port;
in_addr_t ip, mask;
proxy_type type;
};
#ifdef UPSTREAM_SUPPORT
const char *proxy_type_name(proxy_type type);
extern void upstream_add (const char *host, int port, const char *domain,
const char *user, const char *pass,
proxy_type type, struct upstream **upstream_list);
struct upstream **upstream_list);
extern struct upstream *upstream_get (char *host, struct upstream *up);
extern void free_upstream_list (struct upstream *up);
#endif /* UPSTREAM_SUPPORT */