| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: http-relay |
| 3 |
Version: 2.1.3 |
| 4 |
Summary: Relay for HTTP messages (reverse proxy) |
| 5 |
Home-page: https://github.com/ctu-vras/http_relay |
| 6 |
Author: Martin Pecka |
| 7 |
Author-email: Martin Pecka <[email protected]> |
| 8 |
Maintainer: Martin Pecka |
| 9 |
Maintainer-email: Martin Pecka <[email protected]> |
| 10 |
License: BSD 3-Clause License |
| 11 |
|
| 12 |
Copyright (c) 2023, Czech Technical University in Prague |
| 13 |
|
| 14 |
Redistribution and use in source and binary forms, with or without |
| 15 |
modification, are permitted provided that the following conditions are met: |
| 16 |
|
| 17 |
1. Redistributions of source code must retain the above copyright notice, this |
| 18 |
list of conditions and the following disclaimer. |
| 19 |
|
| 20 |
2. Redistributions in binary form must reproduce the above copyright notice, |
| 21 |
this list of conditions and the following disclaimer in the documentation |
| 22 |
and/or other materials provided with the distribution. |
| 23 |
|
| 24 |
3. Neither the name of the copyright holder nor the names of its |
| 25 |
contributors may be used to endorse or promote products derived from |
| 26 |
this software without specific prior written permission. |
| 27 |
|
| 28 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 29 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 30 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 31 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 32 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 33 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 34 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 35 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 36 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 37 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 |
|
| 39 |
Project-URL: Homepage, https://github.com/ctu-vras/http_relay |
| 40 |
Keywords: http,proxy |
| 41 |
Classifier: License :: OSI Approved :: BSD License |
| 42 |
Classifier: Programming Language :: Python |
| 43 |
Classifier: Programming Language :: Python :: 2 |
| 44 |
Classifier: Programming Language :: Python :: 3 |
| 45 |
Classifier: Development Status :: 5 - Production/Stable |
| 46 |
Classifier: Environment :: Console |
| 47 |
Classifier: Intended Audience :: Developers |
| 48 |
Classifier: Intended Audience :: Information Technology |
| 49 |
Classifier: Intended Audience :: Science/Research |
| 50 |
Classifier: Operating System :: OS Independent |
| 51 |
Classifier: Topic :: Communications |
| 52 |
Classifier: Topic :: Internet |
| 53 |
Classifier: Topic :: Internet :: WWW/HTTP |
| 54 |
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers |
| 55 |
Classifier: Topic :: Software Development :: Libraries |
| 56 |
Classifier: Topic :: System :: Networking |
| 57 |
Classifier: Topic :: Utilities |
| 58 |
Requires-Python: >=2.7 |
| 59 |
Description-Content-Type: text/markdown |
| 60 |
License-File: LICENSE |
| 61 |
Provides-Extra: test |
| 62 |
Requires-Dist: pytest; extra == "test" |
| 63 |
|
| 64 |
<!-- |
| 65 |
SPDX-License-Identifier: BSD-3-Clause |
| 66 |
SPDX-FileCopyrightText: Czech Technical University in Prague |
| 67 |
--> |
| 68 |
|
| 69 |
# http-relay |
| 70 |
|
| 71 |
Relay HTTP requests from localhost to a remote host (act as reverse HTTP proxy). |
| 72 |
|
| 73 |
This HTTP relay properly processes also the nonstandard HTTP responses like `ICY 200 OK` produced by Shoutcast or NTRIP streaming servers. |
| 74 |
|
| 75 |
The relay works properly with hostnames, IPv4 and IPv6 addresses. IPv6 addresses can be specified with or without `[]`. |
| 76 |
|
| 77 |
## Usage |
| 78 |
|
| 79 |
``` |
| 80 |
usage: http-relay [-h] [-n NUM_THREADS] [-b BUFFER_SIZE] [-t SIGKILL_TIMEOUT] [-s] host [port] [local_port] [local_addr] |
| 81 |
|
| 82 |
positional arguments: |
| 83 |
host The remote host to connect to (e.g. "cvut.cz") |
| 84 |
port The remote host's port to connect to (e.g. 80). |
| 85 |
local_port The local port to be used for the relay. If left out, will be the same as remote port. |
| 86 |
local_addr Local interface (IP or hostname) to run the relay on. By default, it runs on all IPv4 interfaces (0.0.0.0). |
| 87 |
|
| 88 |
optional arguments: |
| 89 |
-h, --help show this help message and exit |
| 90 |
-n NUM_THREADS, --num-threads NUM_THREADS |
| 91 |
Number of threads servicing the incoming requests. |
| 92 |
-b BUFFER_SIZE, --buffer-size BUFFER_SIZE |
| 93 |
Size of the buffer used for reading responses. Generally, a larger buffer should be more efficient, but if it is too large, the local clients may time out before they receive any data. |
| 94 |
-t SIGKILL_TIMEOUT, --sigkill-timeout SIGKILL_TIMEOUT |
| 95 |
If specified, the relay will be sigkilled in this number of seconds. |
| 96 |
-s, --sigkill-on-stream-stop |
| 97 |
If True, --sigkill-timeout will not be counted when no requests are active, and during requests, each successful data transmission will reset the timeout. This can be used to detect |
| 98 |
stale streams if you expect an application to be constantly receiving data. |
| 99 |
|
| 100 |
``` |
| 101 |
|
| 102 |
## Python module |
| 103 |
|
| 104 |
This package also provides Python module `http_relay`. You can start the relay as a part of your application like this: |
| 105 |
|
| 106 |
```python |
| 107 |
from http_relay import run |
| 108 |
|
| 109 |
# ... |
| 110 |
|
| 111 |
run("0.0.0.0", 80, "cvut.cz", 80) |
| 112 |
``` |
| 113 |
|
| 114 |
## Examples |
| 115 |
|
| 116 |
```bash |
| 117 |
http-relay cvut.cz 80 8080 # redirects local port 8080 to cvut.cz:80 |
| 118 |
http-relay cvut.cz 2101 # redirects local port 2101 to cvut.cz:2101 |
| 119 |
http-relay cvut.cz 80 8080 localhost # redirects localhost:8080 to cvut.cz:80 (i.e. no external access to the 8080 port) |
| 120 |
|
| 121 |
http-relay stream.cz 2101 -t 10 -s # redirects local port 2101 to stream.cz and kills the relay after 10 secs if a stream is being downloaded and becomes stale |
| 122 |
``` |