simple-proxy 0.0.30__tar.gz → 0.0.32__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.
Files changed (44) hide show
  1. {simple_proxy-0.0.30/simple_proxy.egg-info → simple_proxy-0.0.32}/PKG-INFO +58 -31
  2. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/README.md +56 -29
  3. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/pyproject.toml +2 -2
  4. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/__main__.py +2 -0
  5. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/handler/http_proxy_channel_handler.py +4 -1
  6. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/run.py +9 -1
  7. {simple_proxy-0.0.30 → simple_proxy-0.0.32/simple_proxy.egg-info}/PKG-INFO +58 -31
  8. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy.egg-info/requires.txt +1 -1
  9. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/LICENSE +0 -0
  10. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/setup.cfg +0 -0
  11. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/__init__.py +0 -0
  12. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/clients.py +0 -0
  13. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/handler/__init__.py +0 -0
  14. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/handler/echo_channel_handler.py +0 -0
  15. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/handler/proxy_channel_handler.py +0 -0
  16. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/handler/shell_channel_handler.py +0 -0
  17. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/handler/socks5_proxy_channel_handler.py +0 -0
  18. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/utils/__init__.py +0 -0
  19. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/utils/certutils.py +0 -0
  20. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/utils/logutils.py +0 -0
  21. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/utils/netutils.py +0 -0
  22. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/utils/osutils.py +0 -0
  23. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/utils/proxyutils.py +0 -0
  24. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/utils/stringutils.py +0 -0
  25. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/utils/tlsutils.py +0 -0
  26. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy/version.py +0 -0
  27. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy.egg-info/SOURCES.txt +0 -0
  28. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy.egg-info/dependency_links.txt +0 -0
  29. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy.egg-info/entry_points.txt +0 -0
  30. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/simple_proxy.egg-info/top_level.txt +0 -0
  31. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/handler/test_echo_channel_handler.py +0 -0
  32. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/handler/test_http_proxy_channel_handler.py +0 -0
  33. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/handler/test_proxy_channel_handler.py +0 -0
  34. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/handler/test_shell_channel_handler.py +0 -0
  35. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/handler/test_socks5_proxy_channel_handler.py +0 -0
  36. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/test_clients.py +0 -0
  37. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/test_run.py +0 -0
  38. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/utils/test_certutils.py +0 -0
  39. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/utils/test_logutils.py +0 -0
  40. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/utils/test_netutils.py +0 -0
  41. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/utils/test_osutils.py +0 -0
  42. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/utils/test_proxyutils.py +0 -0
  43. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/utils/test_stringutils.py +0 -0
  44. {simple_proxy-0.0.30 → simple_proxy-0.0.32}/tests/utils/test_tlsutils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simple_proxy
3
- Version: 0.0.30
3
+ Version: 0.0.32
4
4
  Summary: A simple NIO proxy tool
5
5
  Home-page: https://github.com/ruanhao/simple-proxy
6
6
  Author-email: Hao Ruan <ruanhao1116@gmail.com>
@@ -26,7 +26,7 @@ Requires-Python: <4,>=3.7
26
26
  Description-Content-Type: text/markdown
27
27
  License-File: LICENSE
28
28
  Requires-Dist: click-option-group
29
- Requires-Dist: py-netty>=1.0.8
29
+ Requires-Dist: py-netty>=1.0.9
30
30
  Requires-Dist: cryptography>=42.0.0
31
31
  Requires-Dist: attrs>=22.1.0
32
32
  Provides-Extra: dev
@@ -70,55 +70,77 @@ pip install simple-proxy -U
70
70
  Usage: simple-proxy [OPTIONS]
71
71
 
72
72
  Options:
73
- Common configuration: Configuration for local/remote endpoints
74
- -l, --listening-host TEXT Listening server address [default: localhost]
75
- -lp, --listening-port INTEGER
73
+ Common configuration: Configuration for local/remote
74
+ endpoints
75
+ -l, --listening-host TEXT Listening server address
76
+ [default: localhost]
77
+ -lp, -p, --listening-port INTEGER
76
78
  Listening port [default: 8080]
77
79
  -g, --global Listening on all interfaces
78
80
  -r, --remote-host TEXT Remote host [default: localhost]
79
81
  -rp, --remote-port INTEGER Remote port [default: 80]
80
- -s, --tls Denote remote is listening on secure port
82
+ -s, --tls Denote remote is listening on
83
+ secure port
81
84
  -ss Listening on secure port
82
85
  TCP proxy configuration: Configuration for TCP proxy mode
83
86
  --read-delay-millis INTEGER Read delay(ms) [default: 0]
84
87
  --write-delay-millis INTEGER Write delay(ms) [default: 0]
85
88
  -sni, --server-name-indication TEXT
86
- Server Name Indication(SNI) for TLS connection to remote server
89
+ Server Name Indication(SNI) for
90
+ TLS connection to remote server
87
91
  Thread configuration: Configuration for thread
88
- --workers INTEGER Number of worker threads [default: 1]
89
- --proxy-workers INTEGER Number of proxy threads [default: 1]
92
+ --workers INTEGER Number of worker threads
93
+ [default: 1]
94
+ --proxy-workers INTEGER Number of proxy threads [default:
95
+ 1]
90
96
  Traffic dump configuration: Configuration for traffic dump
91
97
  -c, --tcp-flow Dump tcp flow on to console
92
98
  -f, --save-tcp-flow Save tcp flow to file
93
- TLS certificate configuration:
99
+ TLS certificate configuration:
94
100
  Configuration for TLS certificate
95
101
  -kf, --key-file PATH Key file for local server
96
102
  -cf, --cert-file PATH Certificate file for local server
97
- --alpn Set ALPN protocol as [h2, http/1.1]
98
- Traffic monitor configuration:
103
+ --alpn Set ALPN protocol as [h2,
104
+ http/1.1]
105
+ Traffic monitor configuration:
99
106
  Configuration for traffic monitor
100
- -m, --monitor Print speed info to console for established connection
107
+ -m, --monitor Print speed info to console for
108
+ established connection
101
109
  -mi, --monitor-interval INTEGER
102
- Speed monitor interval(seconds) [default: 3]
103
- TLS Disguise configuration: Configuration for protection against unwanted inspection
110
+ Speed monitor interval(seconds)
111
+ [default: 3]
112
+ TLS Disguise configuration: Configuration for protection
113
+ against unwanted inspection
104
114
  -dti, --disguise-tls-ip TEXT Disguised upstream TLS IP
105
115
  -dtp, --disguise-tls-port INTEGER
106
- Disguised upstream TLS port [default: 443]
107
- --run-disguise-tls-server Run builtin disguise TLS server without specifying external one
108
- -wl, --white-list TEXT IP White list for legal incoming TLS connections (comma separated)
109
- Proxy configuration: Configuration for application proxies
116
+ Disguised upstream TLS port
117
+ [default: 443]
118
+ --run-disguise-tls-server Run builtin disguise TLS server
119
+ without specifying external one
120
+ -wl, --white-list TEXT IP White list for legal incoming
121
+ TLS connections (comma separated)
122
+ Proxy configuration: Configuration for application
123
+ proxies
110
124
  -e, --echo-proxy Run as Echo server
111
125
  --shell-proxy Run as shell proxy server
112
126
  --http-proxy Run as HTTP proxy server
113
127
  --socks5-proxy Run as SOCKS5 proxy server
114
- --proxy-username TEXT Proxy username for HTTP/SOCKS5 proxy
115
- --proxy-password TEXT Proxy password for HTTP/SOCKS5 proxy
128
+ --proxy-username TEXT Proxy username for HTTP/SOCKS5
129
+ proxy
130
+ --proxy-password TEXT Proxy password for HTTP/SOCKS5
131
+ proxy
116
132
  -t, --proxy-transform <TEXT INTEGER TEXT INTEGER>...
117
- List of target transformations(origin_host, origin_port, transformed_host,
118
- transformed_port) for HTTP/SOCKS5 proxy
119
- Misc configuration:
133
+ List of target
134
+ transformations(origin_host,
135
+ origin_port, transformed_host,
136
+ transformed_port) for HTTP/SOCKS5
137
+ proxy
138
+ Misc configuration:
120
139
  -v, --verbose
121
140
  --log-file PATH Log file
141
+ --internal-socks5-host TEXT [Internal] SOCKS5 proxy host
142
+ --internal-socks5-port INTEGER
143
+ [Internal] SOCKS5 proxy port
122
144
  --version Show the version and exit.
123
145
  -h, --help Show this message and exit.
124
146
  ```
@@ -127,7 +149,7 @@ Options:
127
149
  ## Features
128
150
  ### Basic proxy (TLS termination)
129
151
  ```commandline
130
- > simple-proxy --tls -r www.google.com -rp 443 -lp 8080
152
+ > simple-proxy --tls -r www.google.com -rp 443 -p 8080
131
153
  Proxy server started listening: localhost:8080 => www.google.com:443(TLS) ...
132
154
  console:False, file:False, disguise:n/a, whitelist:*
133
155
  > curl -I -H 'Host: www.google.com' http://localhost:8080
@@ -136,7 +158,7 @@ HTTP/1.1 200 OK
136
158
  ```
137
159
 
138
160
  ```commandline
139
- > simple-proxy -r www.google.com -rp 80 -lp 8443 -ss
161
+ > simple-proxy -r www.google.com -rp 80 -p 8443 -ss
140
162
  Proxy server started listening: localhost:8443(TLS) => www.google.com:80 ...
141
163
  console:False, file:False, disguise:n/a, whitelist:*
142
164
  > curl -I -H 'Host: www.google.com' -k https://localhost:8443
@@ -147,7 +169,7 @@ HTTP/1.1 200 OK
147
169
  ### Dump TCP flow
148
170
  TCP flow can be dumped into console or files (under directory __tcpflow__)
149
171
  ```commandline
150
- > simple-proxy -r www.google.com -rp 443 -lp 8443 -ss -s -c -f
172
+ > simple-proxy -r www.google.com -rp 443 -p 8443 -ss -s -c -f
151
173
  Proxy server started listening: localhost:8443(TLS) => www.google.com:443(TLS) ...
152
174
  console:True, file:True, disguise:n/a, whitelist:*
153
175
  > curl -k -I -H 'Host: www.google.com' https://localhost:8443
@@ -156,7 +178,7 @@ console:True, file:True, disguise:n/a, whitelist:*
156
178
 
157
179
  ### Connection status monitor
158
180
  ```commandline
159
- > $ simple-proxy -r echo-server.proxy.com -rp 8080 -lp 48080 --monitor
181
+ > $ simple-proxy -r echo-server.proxy.com -rp 8080 -p 48080 -m
160
182
  Proxy server started listening: localhost:48080 => echo-server.proxy.com:8080 ...
161
183
  console:False, file:False, disguise:n/a, whitelist:*
162
184
  Connection opened: ('127.0.0.1', 60937)
@@ -187,15 +209,20 @@ Average Read Speed: 32765.0 bytes/s, Average Write Speed: 32752.88 bytes/s
187
209
 
188
210
 
189
211
  ### HTTP Proxy
190
- You can set global envs *https_proxy* or *https_proxy* after http proxy server startd.
212
+ You can set global envs *http_proxy* or *https_proxy* after http proxy server started.
191
213
  ```commandline
192
214
  > simple-proxy --http-proxy
193
215
 
194
216
  > simple-proxy --http-proxy --proxy-username=test --proxy-password=test
195
217
 
196
218
  > simple-proxy --http-proxy --proxy-transform www.google.com 443 man-in-middle.com 8443
219
+
220
+ # Use this when an application supports only HTTP proxy,
221
+ # but your upstream proxy is SOCKS5.
222
+ > simple-proxy --http-proxy --internal-socks5-host=localhost --internal-socks5-port=1080
197
223
  ```
198
224
 
225
+
199
226
  ### SOCKS5 Proxy
200
227
  You can set global envs *https_proxy* or *https_proxy* after socks5 proxy server startd.
201
228
  ```commandline
@@ -225,10 +252,10 @@ Any connection beyond whitelist will be served by a mock https server. Real serv
225
252
  For example, you can protect your Scurrying Squirrel against attack from Grim Foolish Weasel.
226
253
 
227
254
  ```commandline
228
- > simple-proxy -rp 8388 -lp 443 -g --run-disguise-tls-server -wl=<your ip>,<your girlfriend's ip>,<your friend's girlfriend's ip>
255
+ > simple-proxy -rp 8388 -p 443 -g --run-disguise-tls-server -wl=<your ip>,<your girlfriend's ip>,<your friend's girlfriend's ip>
229
256
  # only you and your girlfriends can access :8388
230
257
 
231
- > simple-proxy -rp 8388 -lp 443 -g --disguise-tls-ip=www.google.com --disguise-tls-port=443
258
+ > simple-proxy -rp 8388 -p 443 -g --disguise-tls-ip=www.google.com --disguise-tls-port=443
232
259
  # only non-https can access :8388, https traffic through :443 will be directed to google
233
260
  ```
234
261
 
@@ -29,55 +29,77 @@ pip install simple-proxy -U
29
29
  Usage: simple-proxy [OPTIONS]
30
30
 
31
31
  Options:
32
- Common configuration: Configuration for local/remote endpoints
33
- -l, --listening-host TEXT Listening server address [default: localhost]
34
- -lp, --listening-port INTEGER
32
+ Common configuration: Configuration for local/remote
33
+ endpoints
34
+ -l, --listening-host TEXT Listening server address
35
+ [default: localhost]
36
+ -lp, -p, --listening-port INTEGER
35
37
  Listening port [default: 8080]
36
38
  -g, --global Listening on all interfaces
37
39
  -r, --remote-host TEXT Remote host [default: localhost]
38
40
  -rp, --remote-port INTEGER Remote port [default: 80]
39
- -s, --tls Denote remote is listening on secure port
41
+ -s, --tls Denote remote is listening on
42
+ secure port
40
43
  -ss Listening on secure port
41
44
  TCP proxy configuration: Configuration for TCP proxy mode
42
45
  --read-delay-millis INTEGER Read delay(ms) [default: 0]
43
46
  --write-delay-millis INTEGER Write delay(ms) [default: 0]
44
47
  -sni, --server-name-indication TEXT
45
- Server Name Indication(SNI) for TLS connection to remote server
48
+ Server Name Indication(SNI) for
49
+ TLS connection to remote server
46
50
  Thread configuration: Configuration for thread
47
- --workers INTEGER Number of worker threads [default: 1]
48
- --proxy-workers INTEGER Number of proxy threads [default: 1]
51
+ --workers INTEGER Number of worker threads
52
+ [default: 1]
53
+ --proxy-workers INTEGER Number of proxy threads [default:
54
+ 1]
49
55
  Traffic dump configuration: Configuration for traffic dump
50
56
  -c, --tcp-flow Dump tcp flow on to console
51
57
  -f, --save-tcp-flow Save tcp flow to file
52
- TLS certificate configuration:
58
+ TLS certificate configuration:
53
59
  Configuration for TLS certificate
54
60
  -kf, --key-file PATH Key file for local server
55
61
  -cf, --cert-file PATH Certificate file for local server
56
- --alpn Set ALPN protocol as [h2, http/1.1]
57
- Traffic monitor configuration:
62
+ --alpn Set ALPN protocol as [h2,
63
+ http/1.1]
64
+ Traffic monitor configuration:
58
65
  Configuration for traffic monitor
59
- -m, --monitor Print speed info to console for established connection
66
+ -m, --monitor Print speed info to console for
67
+ established connection
60
68
  -mi, --monitor-interval INTEGER
61
- Speed monitor interval(seconds) [default: 3]
62
- TLS Disguise configuration: Configuration for protection against unwanted inspection
69
+ Speed monitor interval(seconds)
70
+ [default: 3]
71
+ TLS Disguise configuration: Configuration for protection
72
+ against unwanted inspection
63
73
  -dti, --disguise-tls-ip TEXT Disguised upstream TLS IP
64
74
  -dtp, --disguise-tls-port INTEGER
65
- Disguised upstream TLS port [default: 443]
66
- --run-disguise-tls-server Run builtin disguise TLS server without specifying external one
67
- -wl, --white-list TEXT IP White list for legal incoming TLS connections (comma separated)
68
- Proxy configuration: Configuration for application proxies
75
+ Disguised upstream TLS port
76
+ [default: 443]
77
+ --run-disguise-tls-server Run builtin disguise TLS server
78
+ without specifying external one
79
+ -wl, --white-list TEXT IP White list for legal incoming
80
+ TLS connections (comma separated)
81
+ Proxy configuration: Configuration for application
82
+ proxies
69
83
  -e, --echo-proxy Run as Echo server
70
84
  --shell-proxy Run as shell proxy server
71
85
  --http-proxy Run as HTTP proxy server
72
86
  --socks5-proxy Run as SOCKS5 proxy server
73
- --proxy-username TEXT Proxy username for HTTP/SOCKS5 proxy
74
- --proxy-password TEXT Proxy password for HTTP/SOCKS5 proxy
87
+ --proxy-username TEXT Proxy username for HTTP/SOCKS5
88
+ proxy
89
+ --proxy-password TEXT Proxy password for HTTP/SOCKS5
90
+ proxy
75
91
  -t, --proxy-transform <TEXT INTEGER TEXT INTEGER>...
76
- List of target transformations(origin_host, origin_port, transformed_host,
77
- transformed_port) for HTTP/SOCKS5 proxy
78
- Misc configuration:
92
+ List of target
93
+ transformations(origin_host,
94
+ origin_port, transformed_host,
95
+ transformed_port) for HTTP/SOCKS5
96
+ proxy
97
+ Misc configuration:
79
98
  -v, --verbose
80
99
  --log-file PATH Log file
100
+ --internal-socks5-host TEXT [Internal] SOCKS5 proxy host
101
+ --internal-socks5-port INTEGER
102
+ [Internal] SOCKS5 proxy port
81
103
  --version Show the version and exit.
82
104
  -h, --help Show this message and exit.
83
105
  ```
@@ -86,7 +108,7 @@ Options:
86
108
  ## Features
87
109
  ### Basic proxy (TLS termination)
88
110
  ```commandline
89
- > simple-proxy --tls -r www.google.com -rp 443 -lp 8080
111
+ > simple-proxy --tls -r www.google.com -rp 443 -p 8080
90
112
  Proxy server started listening: localhost:8080 => www.google.com:443(TLS) ...
91
113
  console:False, file:False, disguise:n/a, whitelist:*
92
114
  > curl -I -H 'Host: www.google.com' http://localhost:8080
@@ -95,7 +117,7 @@ HTTP/1.1 200 OK
95
117
  ```
96
118
 
97
119
  ```commandline
98
- > simple-proxy -r www.google.com -rp 80 -lp 8443 -ss
120
+ > simple-proxy -r www.google.com -rp 80 -p 8443 -ss
99
121
  Proxy server started listening: localhost:8443(TLS) => www.google.com:80 ...
100
122
  console:False, file:False, disguise:n/a, whitelist:*
101
123
  > curl -I -H 'Host: www.google.com' -k https://localhost:8443
@@ -106,7 +128,7 @@ HTTP/1.1 200 OK
106
128
  ### Dump TCP flow
107
129
  TCP flow can be dumped into console or files (under directory __tcpflow__)
108
130
  ```commandline
109
- > simple-proxy -r www.google.com -rp 443 -lp 8443 -ss -s -c -f
131
+ > simple-proxy -r www.google.com -rp 443 -p 8443 -ss -s -c -f
110
132
  Proxy server started listening: localhost:8443(TLS) => www.google.com:443(TLS) ...
111
133
  console:True, file:True, disguise:n/a, whitelist:*
112
134
  > curl -k -I -H 'Host: www.google.com' https://localhost:8443
@@ -115,7 +137,7 @@ console:True, file:True, disguise:n/a, whitelist:*
115
137
 
116
138
  ### Connection status monitor
117
139
  ```commandline
118
- > $ simple-proxy -r echo-server.proxy.com -rp 8080 -lp 48080 --monitor
140
+ > $ simple-proxy -r echo-server.proxy.com -rp 8080 -p 48080 -m
119
141
  Proxy server started listening: localhost:48080 => echo-server.proxy.com:8080 ...
120
142
  console:False, file:False, disguise:n/a, whitelist:*
121
143
  Connection opened: ('127.0.0.1', 60937)
@@ -146,15 +168,20 @@ Average Read Speed: 32765.0 bytes/s, Average Write Speed: 32752.88 bytes/s
146
168
 
147
169
 
148
170
  ### HTTP Proxy
149
- You can set global envs *https_proxy* or *https_proxy* after http proxy server startd.
171
+ You can set global envs *http_proxy* or *https_proxy* after http proxy server started.
150
172
  ```commandline
151
173
  > simple-proxy --http-proxy
152
174
 
153
175
  > simple-proxy --http-proxy --proxy-username=test --proxy-password=test
154
176
 
155
177
  > simple-proxy --http-proxy --proxy-transform www.google.com 443 man-in-middle.com 8443
178
+
179
+ # Use this when an application supports only HTTP proxy,
180
+ # but your upstream proxy is SOCKS5.
181
+ > simple-proxy --http-proxy --internal-socks5-host=localhost --internal-socks5-port=1080
156
182
  ```
157
183
 
184
+
158
185
  ### SOCKS5 Proxy
159
186
  You can set global envs *https_proxy* or *https_proxy* after socks5 proxy server startd.
160
187
  ```commandline
@@ -184,10 +211,10 @@ Any connection beyond whitelist will be served by a mock https server. Real serv
184
211
  For example, you can protect your Scurrying Squirrel against attack from Grim Foolish Weasel.
185
212
 
186
213
  ```commandline
187
- > simple-proxy -rp 8388 -lp 443 -g --run-disguise-tls-server -wl=<your ip>,<your girlfriend's ip>,<your friend's girlfriend's ip>
214
+ > simple-proxy -rp 8388 -p 443 -g --run-disguise-tls-server -wl=<your ip>,<your girlfriend's ip>,<your friend's girlfriend's ip>
188
215
  # only you and your girlfriends can access :8388
189
216
 
190
- > simple-proxy -rp 8388 -lp 443 -g --disguise-tls-ip=www.google.com --disguise-tls-port=443
217
+ > simple-proxy -rp 8388 -p 443 -g --disguise-tls-ip=www.google.com --disguise-tls-port=443
191
218
  # only non-https can access :8388, https traffic through :443 will be directed to google
192
219
  ```
193
220
 
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "simple_proxy"
8
- version = "0.0.30"
8
+ version = "0.0.32"
9
9
  description = "A simple NIO proxy tool"
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.7, <4"
@@ -17,7 +17,7 @@ keywords = ["network", "tcp", "non-blocking", "proxy"]
17
17
 
18
18
  dependencies = [
19
19
  "click-option-group",
20
- "py-netty>=1.0.8",
20
+ "py-netty>=1.0.9",
21
21
  "cryptography>=42.0.0",
22
22
  "attrs>=22.1.0",
23
23
  ]
@@ -62,6 +62,8 @@ logger = logging.getLogger(__name__)
62
62
  @optgroup.group('Misc configuration')
63
63
  @optgroup.option('-v', '--verbose', count=True)
64
64
  @optgroup.option('--log-file', help='Log file', type=click.Path())
65
+ @optgroup.option('--internal-socks5-host', help='[Internal] SOCKS5 proxy host')
66
+ @optgroup.option('--internal-socks5-port', help='[Internal] SOCKS5 proxy port', default=0)
65
67
  @click.version_option(prog_name='Simple Proxy', version=__version__)
66
68
  def _cli(verbose, log_file: click.Path, **kwargs):
67
69
  setup_logging(log_file, logging.INFO if verbose == 0 else logging.DEBUG)
@@ -34,6 +34,9 @@ def get_local_peer_to_target_mapping() -> dict[str, str]:
34
34
 
35
35
 
36
36
  class HttpProxyChannelHandler(LoggingChannelHandler):
37
+
38
+ USE_SOCKSOCKET = False
39
+
37
40
  def __init__(
38
41
  self,
39
42
  client_eventloop_group,
@@ -68,7 +71,7 @@ class HttpProxyChannelHandler(LoggingChannelHandler):
68
71
  self._client = Bootstrap(
69
72
  eventloop_group=self._client_eventloop_group,
70
73
  handler_initializer=_ChannelHandler
71
- ).connect(ip, port, True).sync().channel()
74
+ ).connect(ip, port, True, use_socksocket=HttpProxyChannelHandler.USE_SOCKSOCKET).sync().channel()
72
75
  return self._client
73
76
 
74
77
  def exception_caught(self, ctx, exception):
@@ -2,7 +2,7 @@ import codecs
2
2
  import http.server
3
3
  import signal
4
4
  import ssl
5
-
5
+ import socks
6
6
  from py_netty import EventLoopGroup, ServerBootstrap
7
7
 
8
8
  from .clients import spawn_clients_monitor, stop_clients_monitor
@@ -56,7 +56,15 @@ def run_proxy(
56
56
  server_name_indication: str | None = None,
57
57
  workers=1, proxy_workers=1,
58
58
  as_echo_server=False,
59
+ internal_socks5_host: str | None = None,
60
+ internal_socks5_port: int = 0,
59
61
  ):
62
+ if internal_socks5_port and internal_socks5_host:
63
+ pstderr("[Internal] Setting up internal SOCKS5 proxy for outgoing connection ...")
64
+ socks.set_default_proxy(socks.SOCKS5, internal_socks5_host, internal_socks5_port)
65
+ HttpProxyChannelHandler.USE_SOCKSOCKET = True
66
+
67
+
60
68
  if tls and (disguise_tls_ip or run_disguise_tls_server):
61
69
  pfatal("'--tls/-s' is not applicable if disguise mode is used!")
62
70
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simple_proxy
3
- Version: 0.0.30
3
+ Version: 0.0.32
4
4
  Summary: A simple NIO proxy tool
5
5
  Home-page: https://github.com/ruanhao/simple-proxy
6
6
  Author-email: Hao Ruan <ruanhao1116@gmail.com>
@@ -26,7 +26,7 @@ Requires-Python: <4,>=3.7
26
26
  Description-Content-Type: text/markdown
27
27
  License-File: LICENSE
28
28
  Requires-Dist: click-option-group
29
- Requires-Dist: py-netty>=1.0.8
29
+ Requires-Dist: py-netty>=1.0.9
30
30
  Requires-Dist: cryptography>=42.0.0
31
31
  Requires-Dist: attrs>=22.1.0
32
32
  Provides-Extra: dev
@@ -70,55 +70,77 @@ pip install simple-proxy -U
70
70
  Usage: simple-proxy [OPTIONS]
71
71
 
72
72
  Options:
73
- Common configuration: Configuration for local/remote endpoints
74
- -l, --listening-host TEXT Listening server address [default: localhost]
75
- -lp, --listening-port INTEGER
73
+ Common configuration: Configuration for local/remote
74
+ endpoints
75
+ -l, --listening-host TEXT Listening server address
76
+ [default: localhost]
77
+ -lp, -p, --listening-port INTEGER
76
78
  Listening port [default: 8080]
77
79
  -g, --global Listening on all interfaces
78
80
  -r, --remote-host TEXT Remote host [default: localhost]
79
81
  -rp, --remote-port INTEGER Remote port [default: 80]
80
- -s, --tls Denote remote is listening on secure port
82
+ -s, --tls Denote remote is listening on
83
+ secure port
81
84
  -ss Listening on secure port
82
85
  TCP proxy configuration: Configuration for TCP proxy mode
83
86
  --read-delay-millis INTEGER Read delay(ms) [default: 0]
84
87
  --write-delay-millis INTEGER Write delay(ms) [default: 0]
85
88
  -sni, --server-name-indication TEXT
86
- Server Name Indication(SNI) for TLS connection to remote server
89
+ Server Name Indication(SNI) for
90
+ TLS connection to remote server
87
91
  Thread configuration: Configuration for thread
88
- --workers INTEGER Number of worker threads [default: 1]
89
- --proxy-workers INTEGER Number of proxy threads [default: 1]
92
+ --workers INTEGER Number of worker threads
93
+ [default: 1]
94
+ --proxy-workers INTEGER Number of proxy threads [default:
95
+ 1]
90
96
  Traffic dump configuration: Configuration for traffic dump
91
97
  -c, --tcp-flow Dump tcp flow on to console
92
98
  -f, --save-tcp-flow Save tcp flow to file
93
- TLS certificate configuration:
99
+ TLS certificate configuration:
94
100
  Configuration for TLS certificate
95
101
  -kf, --key-file PATH Key file for local server
96
102
  -cf, --cert-file PATH Certificate file for local server
97
- --alpn Set ALPN protocol as [h2, http/1.1]
98
- Traffic monitor configuration:
103
+ --alpn Set ALPN protocol as [h2,
104
+ http/1.1]
105
+ Traffic monitor configuration:
99
106
  Configuration for traffic monitor
100
- -m, --monitor Print speed info to console for established connection
107
+ -m, --monitor Print speed info to console for
108
+ established connection
101
109
  -mi, --monitor-interval INTEGER
102
- Speed monitor interval(seconds) [default: 3]
103
- TLS Disguise configuration: Configuration for protection against unwanted inspection
110
+ Speed monitor interval(seconds)
111
+ [default: 3]
112
+ TLS Disguise configuration: Configuration for protection
113
+ against unwanted inspection
104
114
  -dti, --disguise-tls-ip TEXT Disguised upstream TLS IP
105
115
  -dtp, --disguise-tls-port INTEGER
106
- Disguised upstream TLS port [default: 443]
107
- --run-disguise-tls-server Run builtin disguise TLS server without specifying external one
108
- -wl, --white-list TEXT IP White list for legal incoming TLS connections (comma separated)
109
- Proxy configuration: Configuration for application proxies
116
+ Disguised upstream TLS port
117
+ [default: 443]
118
+ --run-disguise-tls-server Run builtin disguise TLS server
119
+ without specifying external one
120
+ -wl, --white-list TEXT IP White list for legal incoming
121
+ TLS connections (comma separated)
122
+ Proxy configuration: Configuration for application
123
+ proxies
110
124
  -e, --echo-proxy Run as Echo server
111
125
  --shell-proxy Run as shell proxy server
112
126
  --http-proxy Run as HTTP proxy server
113
127
  --socks5-proxy Run as SOCKS5 proxy server
114
- --proxy-username TEXT Proxy username for HTTP/SOCKS5 proxy
115
- --proxy-password TEXT Proxy password for HTTP/SOCKS5 proxy
128
+ --proxy-username TEXT Proxy username for HTTP/SOCKS5
129
+ proxy
130
+ --proxy-password TEXT Proxy password for HTTP/SOCKS5
131
+ proxy
116
132
  -t, --proxy-transform <TEXT INTEGER TEXT INTEGER>...
117
- List of target transformations(origin_host, origin_port, transformed_host,
118
- transformed_port) for HTTP/SOCKS5 proxy
119
- Misc configuration:
133
+ List of target
134
+ transformations(origin_host,
135
+ origin_port, transformed_host,
136
+ transformed_port) for HTTP/SOCKS5
137
+ proxy
138
+ Misc configuration:
120
139
  -v, --verbose
121
140
  --log-file PATH Log file
141
+ --internal-socks5-host TEXT [Internal] SOCKS5 proxy host
142
+ --internal-socks5-port INTEGER
143
+ [Internal] SOCKS5 proxy port
122
144
  --version Show the version and exit.
123
145
  -h, --help Show this message and exit.
124
146
  ```
@@ -127,7 +149,7 @@ Options:
127
149
  ## Features
128
150
  ### Basic proxy (TLS termination)
129
151
  ```commandline
130
- > simple-proxy --tls -r www.google.com -rp 443 -lp 8080
152
+ > simple-proxy --tls -r www.google.com -rp 443 -p 8080
131
153
  Proxy server started listening: localhost:8080 => www.google.com:443(TLS) ...
132
154
  console:False, file:False, disguise:n/a, whitelist:*
133
155
  > curl -I -H 'Host: www.google.com' http://localhost:8080
@@ -136,7 +158,7 @@ HTTP/1.1 200 OK
136
158
  ```
137
159
 
138
160
  ```commandline
139
- > simple-proxy -r www.google.com -rp 80 -lp 8443 -ss
161
+ > simple-proxy -r www.google.com -rp 80 -p 8443 -ss
140
162
  Proxy server started listening: localhost:8443(TLS) => www.google.com:80 ...
141
163
  console:False, file:False, disguise:n/a, whitelist:*
142
164
  > curl -I -H 'Host: www.google.com' -k https://localhost:8443
@@ -147,7 +169,7 @@ HTTP/1.1 200 OK
147
169
  ### Dump TCP flow
148
170
  TCP flow can be dumped into console or files (under directory __tcpflow__)
149
171
  ```commandline
150
- > simple-proxy -r www.google.com -rp 443 -lp 8443 -ss -s -c -f
172
+ > simple-proxy -r www.google.com -rp 443 -p 8443 -ss -s -c -f
151
173
  Proxy server started listening: localhost:8443(TLS) => www.google.com:443(TLS) ...
152
174
  console:True, file:True, disguise:n/a, whitelist:*
153
175
  > curl -k -I -H 'Host: www.google.com' https://localhost:8443
@@ -156,7 +178,7 @@ console:True, file:True, disguise:n/a, whitelist:*
156
178
 
157
179
  ### Connection status monitor
158
180
  ```commandline
159
- > $ simple-proxy -r echo-server.proxy.com -rp 8080 -lp 48080 --monitor
181
+ > $ simple-proxy -r echo-server.proxy.com -rp 8080 -p 48080 -m
160
182
  Proxy server started listening: localhost:48080 => echo-server.proxy.com:8080 ...
161
183
  console:False, file:False, disguise:n/a, whitelist:*
162
184
  Connection opened: ('127.0.0.1', 60937)
@@ -187,15 +209,20 @@ Average Read Speed: 32765.0 bytes/s, Average Write Speed: 32752.88 bytes/s
187
209
 
188
210
 
189
211
  ### HTTP Proxy
190
- You can set global envs *https_proxy* or *https_proxy* after http proxy server startd.
212
+ You can set global envs *http_proxy* or *https_proxy* after http proxy server started.
191
213
  ```commandline
192
214
  > simple-proxy --http-proxy
193
215
 
194
216
  > simple-proxy --http-proxy --proxy-username=test --proxy-password=test
195
217
 
196
218
  > simple-proxy --http-proxy --proxy-transform www.google.com 443 man-in-middle.com 8443
219
+
220
+ # Use this when an application supports only HTTP proxy,
221
+ # but your upstream proxy is SOCKS5.
222
+ > simple-proxy --http-proxy --internal-socks5-host=localhost --internal-socks5-port=1080
197
223
  ```
198
224
 
225
+
199
226
  ### SOCKS5 Proxy
200
227
  You can set global envs *https_proxy* or *https_proxy* after socks5 proxy server startd.
201
228
  ```commandline
@@ -225,10 +252,10 @@ Any connection beyond whitelist will be served by a mock https server. Real serv
225
252
  For example, you can protect your Scurrying Squirrel against attack from Grim Foolish Weasel.
226
253
 
227
254
  ```commandline
228
- > simple-proxy -rp 8388 -lp 443 -g --run-disguise-tls-server -wl=<your ip>,<your girlfriend's ip>,<your friend's girlfriend's ip>
255
+ > simple-proxy -rp 8388 -p 443 -g --run-disguise-tls-server -wl=<your ip>,<your girlfriend's ip>,<your friend's girlfriend's ip>
229
256
  # only you and your girlfriends can access :8388
230
257
 
231
- > simple-proxy -rp 8388 -lp 443 -g --disguise-tls-ip=www.google.com --disguise-tls-port=443
258
+ > simple-proxy -rp 8388 -p 443 -g --disguise-tls-ip=www.google.com --disguise-tls-port=443
232
259
  # only non-https can access :8388, https traffic through :443 will be directed to google
233
260
  ```
234
261
 
@@ -1,5 +1,5 @@
1
1
  click-option-group
2
- py-netty>=1.0.8
2
+ py-netty>=1.0.9
3
3
  cryptography>=42.0.0
4
4
  attrs>=22.1.0
5
5
 
File without changes
File without changes