Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1115251555 | ||
|
|
72b477da9e | ||
|
|
87e8da90b0 | ||
|
|
c348513095 | ||
|
|
8845bdbff7 | ||
|
|
132a32a68d | ||
|
|
12c454119b | ||
|
|
9db1b0d087 | ||
|
|
e16844bd3b | ||
|
|
3cb25a7857 | ||
|
|
ffbef661cd | ||
|
|
54244661f7 | ||
|
|
5054b9b80f | ||
|
|
b86ecaa11b | ||
|
|
e467744134 | ||
|
|
4ebb3c1bb6 | ||
|
|
d05e801eef | ||
|
|
e1af5ffa58 | ||
|
|
6c8d9de3cc | ||
|
|
9eec142886 | ||
|
|
f413620c5f | ||
|
|
903c9eeb1c | ||
|
|
5a5ae8bfe1 | ||
|
|
51d4f11448 | ||
|
|
78ff8e0f07 | ||
|
|
6505867f7a | ||
|
|
0654ed6403 | ||
|
|
9ed48eb03b | ||
|
|
578f409a03 | ||
|
|
08c44a36ba | ||
|
|
e0ad093b0f | ||
|
|
4ef81ff95d | ||
|
|
3cdb1bf7aa | ||
|
|
d11d23c14c | ||
|
|
fdfa365bae | ||
|
|
954d427565 | ||
|
|
bb5d6af78f | ||
|
|
79f34cd113 | ||
|
|
4f600654d2 | ||
|
|
37ffa6986d | ||
|
|
5608382be9 | ||
|
|
04cc18d0f8 | ||
|
|
7b1801d8e7 | ||
|
|
844403afbe | ||
|
|
866f1c3e56 | ||
|
|
425ce3beb6 | ||
|
|
a8a2342527 | ||
|
|
ccb987e8e0 | ||
|
|
0adf359245 | ||
|
|
54eaac8e76 | ||
|
|
8963739e4b | ||
|
|
a747617c05 | ||
|
|
9d7a95bd56 | ||
|
|
3933daf793 | ||
|
|
18db1675a0 | ||
|
|
4d979df636 | ||
|
|
fc354343f9 | ||
|
|
1db982793d | ||
|
|
95a6f8259c | ||
|
|
8b76f1a939 | ||
|
|
121a11d8e5 | ||
|
|
736e052dc1 | ||
|
|
aa197d6dc8 | ||
|
|
d13d575d29 | ||
|
|
c4b187c8ab | ||
|
|
5012ce690f | ||
|
|
4b75b634d9 | ||
|
|
4b64de4c31 | ||
|
|
7fa544c3d8 | ||
|
|
a5a3741291 | ||
|
|
784d458b82 | ||
|
|
94edc4f4c5 | ||
|
|
be63d2ca19 | ||
|
|
a905437242 | ||
|
|
3127e726d0 | ||
|
|
5bb184c54d | ||
|
|
505ff803e9 | ||
|
|
d03e3a52e5 | ||
|
|
fe9444d585 | ||
|
|
b37135524d | ||
|
|
7f053670c0 | ||
|
|
b28e438cdf | ||
|
|
e495bdf129 | ||
|
|
287a7ae649 | ||
|
|
315e129f12 | ||
|
|
7cb30dd9ee | ||
|
|
9927d411bf | ||
|
|
0f28221ec5 | ||
|
|
57d90c8bf7 | ||
|
|
8de8634b8b | ||
|
|
ce149cc7a6 | ||
|
|
410eaf107c | ||
|
|
e6cbaf7b6e | ||
|
|
2d0192b8a8 | ||
|
|
643d52ac5a | ||
|
|
b92792fd8d | ||
|
|
965664798c | ||
|
|
6d5709de38 | ||
|
|
107f9117d0 | ||
|
|
1b3dd058d1 | ||
|
|
333d722d56 | ||
|
|
6f0abb7339 | ||
|
|
a19f758743 | ||
|
|
f63730c77e | ||
|
|
ed3ada7c26 | ||
|
|
b9e6d9742d | ||
|
|
fbc434e26d | ||
|
|
cc74869e71 | ||
|
|
577ac16cf1 | ||
|
|
810b9ae49a |
No files matched your search
@@ -18,6 +18,5 @@ stamp-h1
|
||||
autom4te.cache
|
||||
cscope.files
|
||||
cscope.out
|
||||
compile
|
||||
*~
|
||||
tags
|
||||
-18
@@ -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
|
||||
@@ -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
|
||||
@@ -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 \
|
||||
|
||||
@@ -1 +1,179 @@
|
||||
See git log for recent changes in Tinyproxy.
|
||||
Tinyproxy NEWS
|
||||
==============
|
||||
|
||||
Version 1.8.4
|
||||
-------------
|
||||
|
||||
Most notably, this release removes the limitation of
|
||||
a single Listen address of not listening on the
|
||||
wildcard address (BB#63) and a DoS (BB#110, CVE-2012-3505).
|
||||
|
||||
Among several other bug fixes, this release fixes a bunch of issues found
|
||||
by coverity (scan.coverity.com).
|
||||
|
||||
Bugs resolved since version 1.8.3
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* BB#110: fix algorithmic complexity DoS in hashmap
|
||||
* BB#106: fix failing CONNECT requests with IPv6 literal addresses
|
||||
* BB#116: fix invalid free for GET requests to IPv6 literal addresses
|
||||
* BB#63: support multiple Listen statements in configuration
|
||||
* BB#81: support listening on ipv4 and ipv6 wildcard if no Listen specified
|
||||
* BB#109: fix crash when writing to log file fails
|
||||
* BB#112: fix build with autoconf >= 2.69
|
||||
|
||||
Contributors:
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Mukund Sivaraman, Michael Adam, Gaudenz Steinlin, Peter H. Froehlich
|
||||
|
||||
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.
|
||||
@@ -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).
|
||||
@@ -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`).
|
||||
+112
-51
@@ -4,17 +4,22 @@
|
||||
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], [4])
|
||||
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
|
||||
@@ -24,6 +29,19 @@ 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,50 @@ 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([gethostname inet_ntoa memchr memset select socket strcasecmp \
|
||||
strchr strdup strerror strncasecmp strpbrk strstr strtol])
|
||||
AC_CHECK_FUNCS([isascii memcpy memmove setrlimit ftruncate regcomp regexec])
|
||||
AC_CHECK_FUNCS([strlcpy strlcat setgroups])
|
||||
|
||||
AC_CHECK_FUNCS([time rand srand])
|
||||
|
||||
|
||||
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 +224,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")
|
||||
|
||||
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 +284,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"
|
||||
fi
|
||||
rm -f conftest.txt conftest.xml
|
||||
if test x"$A2X" = x"no"; then
|
||||
AC_MSG_ERROR([Test for asciidoc failed. See the file 'INSTALL' for help.])
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_XMLLINT, test "x$XMLLINT" != "xno")
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
@@ -230,20 +308,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
|
||||
@@ -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)
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -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
@@ -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
@@ -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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
EXTRA_DIST = \
|
||||
as-compiler-flag.m4 \
|
||||
argenable.m4
|
||||
argenable.m4 \
|
||||
typecheck.m4
|
||||
@@ -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
|
||||
])
|
||||
@@ -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
@@ -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 \
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -233,9 +233,6 @@ static void child_main (struct child_s *ptr)
|
||||
|
||||
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);
|
||||
|
||||
+110
-43
@@ -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_MALLOC_H
|
||||
# include <malloc.h>
|
||||
#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
|
||||
|
||||
+30
-77
@@ -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 */
|
||||
@@ -294,7 +289,6 @@ static void free_config (struct config_s *conf)
|
||||
safefree (conf->user);
|
||||
safefree (conf->group);
|
||||
vector_delete(conf->listen_addrs);
|
||||
vector_delete(conf->basicauth_list);
|
||||
#ifdef FILTER_ENABLE
|
||||
safefree (conf->filter);
|
||||
#endif /* FILTER_ENABLE */
|
||||
@@ -775,7 +769,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 +875,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,6 +883,11 @@ 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)
|
||||
@@ -989,27 +994,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 +1070,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 +1100,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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
+1
-1
@@ -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));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -493,24 +493,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);
|
||||
}
|
||||
@@ -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
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -217,7 +207,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;
|
||||
|
||||
@@ -77,7 +77,16 @@
|
||||
* don't advocate this, but it could be useful at times.)
|
||||
*/
|
||||
|
||||
#include <syslog.h>
|
||||
#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);
|
||||
|
||||
+52
-21
@@ -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;
|
||||
@@ -300,8 +336,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 +396,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",
|
||||
@@ -386,15 +417,6 @@ main (int argc, char **argv)
|
||||
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 +429,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 +477,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));
|
||||
|
||||
+6
-11
@@ -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;
|
||||
|
||||
@@ -250,10 +249,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 +261,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 +269,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 +277,7 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+3
-3
@@ -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
|
||||
+8
-179
@@ -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
|
||||
|
||||
/*
|
||||
@@ -199,12 +196,12 @@ static int extract_url (const char *url, int default_port,
|
||||
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);
|
||||
@@ -270,17 +267,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"
|
||||
@@ -383,18 +369,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
|
||||
|
||||
@@ -867,10 +847,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;
|
||||
@@ -1279,122 +1259,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 +1302,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.",
|
||||
@@ -1608,38 +1469,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 +1521,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
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+12
-48
@@ -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
@@ -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 */
|
||||
|
||||
Reference in new issue
Block a user