pyproxytools 0.3.2__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyproxytools-0.3.2/pyproxytools.egg-info → pyproxytools-0.4.1}/PKG-INFO +10 -5
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/README.md +8 -4
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/__init__.py +1 -1
- pyproxytools-0.4.1/pyproxy/__main__.py +4 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/pyproxy.py +13 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/server.py +1 -1
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/utils/args.py +1 -1
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/utils/config.py +16 -2
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/utils/logger.py +20 -4
- {pyproxytools-0.3.2 → pyproxytools-0.4.1/pyproxytools.egg-info}/PKG-INFO +10 -5
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxytools.egg-info/SOURCES.txt +1 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxytools.egg-info/requires.txt +1 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxytools.egg-info/top_level.txt +0 -2
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/requirements.txt +2 -1
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/tests/utils/test_logger.py +10 -1
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/LICENSE +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/benchmark/benchmark.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/benchmark/utils/__init__.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/benchmark/utils/html.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/benchmark/utils/req.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproject.toml +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/handlers/__init__.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/handlers/client.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/handlers/http.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/handlers/https.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/modules/__init__.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/modules/cancel_inspect.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/modules/custom_header.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/modules/filter.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/modules/shortcuts.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/monitoring/__init__.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/monitoring/web.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/utils/__init__.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/utils/crypto.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/utils/http_req.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxy/utils/version.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxytools.egg-info/dependency_links.txt +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/pyproxytools.egg-info/entry_points.txt +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/setup.cfg +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/setup.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/tests/modules/__init__.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/tests/modules/test_cancel_inspect.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/tests/modules/test_custom_header.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/tests/modules/test_filter.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/tests/modules/test_shortcuts.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/tests/utils/__init__.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/tests/utils/test_crypto.py +0 -0
- {pyproxytools-0.3.2 → pyproxytools-0.4.1}/tests/utils/test_http_req.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyproxytools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Lightweight and fast python web proxy
|
|
5
5
|
Author: 6C656C65
|
|
6
6
|
License-Expression: MIT
|
|
@@ -28,6 +28,7 @@ Requires-Dist: requests>=2.31.0
|
|
|
28
28
|
Requires-Dist: Flask>=3.1.0
|
|
29
29
|
Requires-Dist: Flask-HTTPAuth>=4.8.0
|
|
30
30
|
Requires-Dist: psutil>=5.9.8
|
|
31
|
+
Requires-Dist: colorlog>=6.9.0
|
|
31
32
|
Dynamic: license-file
|
|
32
33
|
|
|
33
34
|
<div align="center">
|
|
@@ -47,9 +48,8 @@ Dynamic: license-file
|
|
|
47
48
|
<img src="https://img.shields.io/github/commit-activity/w/6C656C65/pyproxy?style=for-the-badge">
|
|
48
49
|
<img src="https://img.shields.io/github/contributors/6C656C65/pyproxy?style=for-the-badge">
|
|
49
50
|
<br>
|
|
50
|
-
<img src="https://img.shields.io/
|
|
51
|
-
<img src="https://img.shields.io/
|
|
52
|
-
<img src="https://img.shields.io/github/actions/workflow/status/6C656C65/pyproxy/docker-images.yml?label=Delivery&style=for-the-badge">
|
|
51
|
+
<img src="https://img.shields.io/pypi/v/pyproxytools?style=for-the-badge">
|
|
52
|
+
<img src="https://img.shields.io/pypi/pyversions/pyproxytools?style=for-the-badge">
|
|
53
53
|
</p>
|
|
54
54
|
|
|
55
55
|
---
|
|
@@ -74,6 +74,11 @@ Dynamic: license-file
|
|
|
74
74
|
|
|
75
75
|
## 📦 **Installation**
|
|
76
76
|
|
|
77
|
+
### Install from package
|
|
78
|
+
```bash
|
|
79
|
+
pip install pyproxytools
|
|
80
|
+
```
|
|
81
|
+
|
|
77
82
|
### Install from source
|
|
78
83
|
```bash
|
|
79
84
|
git clone https://github.com/6C656C65/pyproxy.git
|
|
@@ -92,7 +97,7 @@ You can use slim images by adding `-slim` to the end of the tags
|
|
|
92
97
|
|
|
93
98
|
### Start the proxy
|
|
94
99
|
```bash
|
|
95
|
-
python3 -m pyproxy
|
|
100
|
+
python3 -m pyproxy
|
|
96
101
|
```
|
|
97
102
|
The proxy will be available at: `0.0.0.0:8080`.
|
|
98
103
|
The access log will be available at `./logs/access.log`.
|
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
<img src="https://img.shields.io/github/commit-activity/w/6C656C65/pyproxy?style=for-the-badge">
|
|
16
16
|
<img src="https://img.shields.io/github/contributors/6C656C65/pyproxy?style=for-the-badge">
|
|
17
17
|
<br>
|
|
18
|
-
<img src="https://img.shields.io/
|
|
19
|
-
<img src="https://img.shields.io/
|
|
20
|
-
<img src="https://img.shields.io/github/actions/workflow/status/6C656C65/pyproxy/docker-images.yml?label=Delivery&style=for-the-badge">
|
|
18
|
+
<img src="https://img.shields.io/pypi/v/pyproxytools?style=for-the-badge">
|
|
19
|
+
<img src="https://img.shields.io/pypi/pyversions/pyproxytools?style=for-the-badge">
|
|
21
20
|
</p>
|
|
22
21
|
|
|
23
22
|
---
|
|
@@ -42,6 +41,11 @@
|
|
|
42
41
|
|
|
43
42
|
## 📦 **Installation**
|
|
44
43
|
|
|
44
|
+
### Install from package
|
|
45
|
+
```bash
|
|
46
|
+
pip install pyproxytools
|
|
47
|
+
```
|
|
48
|
+
|
|
45
49
|
### Install from source
|
|
46
50
|
```bash
|
|
47
51
|
git clone https://github.com/6C656C65/pyproxy.git
|
|
@@ -60,7 +64,7 @@ You can use slim images by adding `-slim` to the end of the tags
|
|
|
60
64
|
|
|
61
65
|
### Start the proxy
|
|
62
66
|
```bash
|
|
63
|
-
python3 -m pyproxy
|
|
67
|
+
python3 -m pyproxy
|
|
64
68
|
```
|
|
65
69
|
The proxy will be available at: `0.0.0.0:8080`.
|
|
66
70
|
The access log will be available at `./logs/access.log`.
|
|
@@ -36,6 +36,13 @@ def main():
|
|
|
36
36
|
proxy_host = get_config_value(args, config, "proxy_host", "Proxy", "127.0.0.1")
|
|
37
37
|
proxy_port = get_config_value(args, config, "proxy_port", "Proxy", 8081)
|
|
38
38
|
|
|
39
|
+
console_format = None
|
|
40
|
+
if config.has_section("Logging") and config.has_option("Logging", "console_format"):
|
|
41
|
+
console_format = config.get("Logging", "console_format")
|
|
42
|
+
datefmt = None
|
|
43
|
+
if config.has_section("Logging") and config.has_option("Logging", "datefmt"):
|
|
44
|
+
datefmt = config.get("Logging", "datefmt")
|
|
45
|
+
|
|
39
46
|
logger_config = ProxyConfigLogger(
|
|
40
47
|
access_log=get_config_value(
|
|
41
48
|
args, config, "access_log", "Logging", "logs/access.log"
|
|
@@ -49,6 +56,12 @@ def main():
|
|
|
49
56
|
no_logging_block=str_to_bool(
|
|
50
57
|
get_config_value(args, config, "no_logging_block", "Logging", False)
|
|
51
58
|
),
|
|
59
|
+
console_format=(
|
|
60
|
+
console_format
|
|
61
|
+
if console_format is not None
|
|
62
|
+
else "%(asctime)s - %(levelname)s - %(message)s"
|
|
63
|
+
),
|
|
64
|
+
datefmt=datefmt if datefmt is not None else "%d/%m/%Y %H:%M:%S",
|
|
52
65
|
)
|
|
53
66
|
|
|
54
67
|
filter_config = ProxyConfigFilter(
|
|
@@ -113,7 +113,7 @@ class ProxyServer:
|
|
|
113
113
|
self.custom_header_result_queue = multiprocessing.Queue()
|
|
114
114
|
|
|
115
115
|
# Logging
|
|
116
|
-
self.console_logger = configure_console_logger()
|
|
116
|
+
self.console_logger = configure_console_logger(self.logger_config)
|
|
117
117
|
if not self.logger_config.no_logging_access:
|
|
118
118
|
self.logger_config.access_logger = configure_file_logger(
|
|
119
119
|
self.logger_config.access_log, "AccessLogger"
|
|
@@ -124,7 +124,7 @@ def load_config(config_path: str) -> configparser.ConfigParser:
|
|
|
124
124
|
Returns:
|
|
125
125
|
configparser.ConfigParser: The parsed configuration object.
|
|
126
126
|
"""
|
|
127
|
-
config = configparser.ConfigParser()
|
|
127
|
+
config = configparser.ConfigParser(interpolation=None)
|
|
128
128
|
config.read(config_path)
|
|
129
129
|
return config
|
|
130
130
|
|
|
@@ -10,20 +10,32 @@ class ProxyConfigLogger:
|
|
|
10
10
|
Handles logging configuration for the proxy.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
def __init__(
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
access_log,
|
|
16
|
+
block_log,
|
|
17
|
+
no_logging_access,
|
|
18
|
+
no_logging_block,
|
|
19
|
+
console_format,
|
|
20
|
+
datefmt,
|
|
21
|
+
):
|
|
14
22
|
self.access_log = access_log
|
|
15
23
|
self.block_log = block_log
|
|
16
24
|
self.access_logger = None
|
|
17
25
|
self.block_logger = None
|
|
18
26
|
self.no_logging_access = no_logging_access
|
|
19
27
|
self.no_logging_block = no_logging_block
|
|
28
|
+
self.console_format = console_format
|
|
29
|
+
self.datefmt = datefmt
|
|
20
30
|
|
|
21
31
|
def __repr__(self):
|
|
22
32
|
return (
|
|
23
33
|
f"ProxyConfigLogger(access_log={self.access_log}, "
|
|
24
34
|
f"block_log={self.block_log}, "
|
|
25
35
|
f"no_logging_access={self.no_logging_access}, "
|
|
26
|
-
f"no_logging_block={self.no_logging_block})"
|
|
36
|
+
f"no_logging_block={self.no_logging_block}), "
|
|
37
|
+
f"console_format={self.console_format}), "
|
|
38
|
+
f"datefmt={self.datefmt})"
|
|
27
39
|
)
|
|
28
40
|
|
|
29
41
|
def to_dict(self):
|
|
@@ -35,6 +47,8 @@ class ProxyConfigLogger:
|
|
|
35
47
|
"block_log": self.block_log,
|
|
36
48
|
"no_logging_access": self.no_logging_access,
|
|
37
49
|
"no_logging_block": self.no_logging_block,
|
|
50
|
+
"console_format": self.console_format,
|
|
51
|
+
"datefmt": self.datefmt,
|
|
38
52
|
}
|
|
39
53
|
|
|
40
54
|
|
|
@@ -6,22 +6,38 @@ This module contains functions to configure and return loggers for both console
|
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
8
|
import os
|
|
9
|
+
import colorlog
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
def configure_console_logger() -> logging.Logger:
|
|
12
|
+
def configure_console_logger(logger_config) -> logging.Logger:
|
|
12
13
|
"""
|
|
13
14
|
Configures and returns a logger that outputs log messages to the console.
|
|
14
15
|
|
|
15
16
|
Returns:
|
|
16
17
|
logging.Logger: A logger instance that writes logs to the console.
|
|
17
18
|
"""
|
|
19
|
+
print(logger_config)
|
|
18
20
|
console_logger = logging.getLogger("ConsoleLogger")
|
|
19
21
|
console_logger.setLevel(logging.INFO)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
if "%(log_color)s" not in logger_config.console_format:
|
|
24
|
+
fmt = "%(log_color)s" + logger_config.console_format
|
|
25
|
+
else:
|
|
26
|
+
fmt = logger_config.console_format
|
|
27
|
+
|
|
28
|
+
formatter = colorlog.ColoredFormatter(
|
|
29
|
+
fmt,
|
|
30
|
+
datefmt=logger_config.datefmt,
|
|
31
|
+
log_colors={
|
|
32
|
+
"DEBUG": "cyan",
|
|
33
|
+
"INFO": "green",
|
|
34
|
+
"WARNING": "yellow",
|
|
35
|
+
"ERROR": "red",
|
|
36
|
+
"CRITICAL": "bold_red",
|
|
37
|
+
},
|
|
22
38
|
)
|
|
23
39
|
console_handler = logging.StreamHandler()
|
|
24
|
-
console_handler.setFormatter(
|
|
40
|
+
console_handler.setFormatter(formatter)
|
|
25
41
|
console_logger.addHandler(console_handler)
|
|
26
42
|
return console_logger
|
|
27
43
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyproxytools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Lightweight and fast python web proxy
|
|
5
5
|
Author: 6C656C65
|
|
6
6
|
License-Expression: MIT
|
|
@@ -28,6 +28,7 @@ Requires-Dist: requests>=2.31.0
|
|
|
28
28
|
Requires-Dist: Flask>=3.1.0
|
|
29
29
|
Requires-Dist: Flask-HTTPAuth>=4.8.0
|
|
30
30
|
Requires-Dist: psutil>=5.9.8
|
|
31
|
+
Requires-Dist: colorlog>=6.9.0
|
|
31
32
|
Dynamic: license-file
|
|
32
33
|
|
|
33
34
|
<div align="center">
|
|
@@ -47,9 +48,8 @@ Dynamic: license-file
|
|
|
47
48
|
<img src="https://img.shields.io/github/commit-activity/w/6C656C65/pyproxy?style=for-the-badge">
|
|
48
49
|
<img src="https://img.shields.io/github/contributors/6C656C65/pyproxy?style=for-the-badge">
|
|
49
50
|
<br>
|
|
50
|
-
<img src="https://img.shields.io/
|
|
51
|
-
<img src="https://img.shields.io/
|
|
52
|
-
<img src="https://img.shields.io/github/actions/workflow/status/6C656C65/pyproxy/docker-images.yml?label=Delivery&style=for-the-badge">
|
|
51
|
+
<img src="https://img.shields.io/pypi/v/pyproxytools?style=for-the-badge">
|
|
52
|
+
<img src="https://img.shields.io/pypi/pyversions/pyproxytools?style=for-the-badge">
|
|
53
53
|
</p>
|
|
54
54
|
|
|
55
55
|
---
|
|
@@ -74,6 +74,11 @@ Dynamic: license-file
|
|
|
74
74
|
|
|
75
75
|
## 📦 **Installation**
|
|
76
76
|
|
|
77
|
+
### Install from package
|
|
78
|
+
```bash
|
|
79
|
+
pip install pyproxytools
|
|
80
|
+
```
|
|
81
|
+
|
|
77
82
|
### Install from source
|
|
78
83
|
```bash
|
|
79
84
|
git clone https://github.com/6C656C65/pyproxy.git
|
|
@@ -92,7 +97,7 @@ You can use slim images by adding `-slim` to the end of the tags
|
|
|
92
97
|
|
|
93
98
|
### Start the proxy
|
|
94
99
|
```bash
|
|
95
|
-
python3 -m pyproxy
|
|
100
|
+
python3 -m pyproxy
|
|
96
101
|
```
|
|
97
102
|
The proxy will be available at: `0.0.0.0:8080`.
|
|
98
103
|
The access log will be available at `./logs/access.log`.
|
|
@@ -12,6 +12,14 @@ from unittest.mock import patch, MagicMock
|
|
|
12
12
|
from pyproxy.utils.logger import configure_console_logger, configure_file_logger
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
class DummyLoggerConfig:
|
|
16
|
+
def __init__(self, console_format=None, datefmt=None):
|
|
17
|
+
self.console_format = (
|
|
18
|
+
console_format or "%(log_color)s%(asctime)s - %(levelname)s - %(message)s"
|
|
19
|
+
)
|
|
20
|
+
self.datefmt = datefmt or "%d/%m/%Y %H:%M:%S"
|
|
21
|
+
|
|
22
|
+
|
|
15
23
|
class TestLogger(unittest.TestCase):
|
|
16
24
|
"""
|
|
17
25
|
Test suite for the logger module.
|
|
@@ -26,7 +34,8 @@ class TestLogger(unittest.TestCase):
|
|
|
26
34
|
- Checks that the log level is set to INFO.
|
|
27
35
|
- Verifies that the handler is a StreamHandler.
|
|
28
36
|
"""
|
|
29
|
-
|
|
37
|
+
logger_config = DummyLoggerConfig()
|
|
38
|
+
logger = configure_console_logger(logger_config)
|
|
30
39
|
|
|
31
40
|
self.assertTrue(logger.hasHandlers())
|
|
32
41
|
self.assertEqual(logger.level, logging.INFO)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|