davechri-test 1.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of davechri-test might be problematic. Click here for more details.

Files changed (113) hide show
  1. package/README.md +277 -0
  2. package/bin/proxyall +5 -0
  3. package/build/app.js +89 -0
  4. package/build/app.js.map +1 -0
  5. package/build/common/Message.js +34 -0
  6. package/build/common/Message.js.map +1 -0
  7. package/build/common/ProxyConfig.js +27 -0
  8. package/build/common/ProxyConfig.js.map +1 -0
  9. package/build/node-http-mitm-proxy/.gitattributes +2 -0
  10. package/build/node-http-mitm-proxy/.travis.yml +10 -0
  11. package/build/node-http-mitm-proxy/README.md +539 -0
  12. package/build/node-http-mitm-proxy/bin/mitm-proxy.js +36 -0
  13. package/build/node-http-mitm-proxy/examples/forwardHttps.js +62 -0
  14. package/build/node-http-mitm-proxy/examples/modifyGoogle.js +44 -0
  15. package/build/node-http-mitm-proxy/examples/onCertificateMissing.js +30 -0
  16. package/build/node-http-mitm-proxy/examples/onCertificateRequired.js +23 -0
  17. package/build/node-http-mitm-proxy/examples/preventRequest.js +20 -0
  18. package/build/node-http-mitm-proxy/examples/processFullResponseBody.js +36 -0
  19. package/build/node-http-mitm-proxy/examples/removeProxyToServerContentLength.js +17 -0
  20. package/build/node-http-mitm-proxy/examples/websocket.js +31 -0
  21. package/build/node-http-mitm-proxy/examples/wildcard.js +17 -0
  22. package/build/node-http-mitm-proxy/index.d.ts +233 -0
  23. package/build/node-http-mitm-proxy/index.js +3 -0
  24. package/build/node-http-mitm-proxy/lib/ca.js +245 -0
  25. package/build/node-http-mitm-proxy/lib/middleware/gunzip.js +19 -0
  26. package/build/node-http-mitm-proxy/lib/middleware/wildcard.js +22 -0
  27. package/build/node-http-mitm-proxy/lib/proxy.js +1137 -0
  28. package/build/node-http-mitm-proxy/package-lock.json +1406 -0
  29. package/build/node-http-mitm-proxy/package.json +45 -0
  30. package/build/node-http-mitm-proxy/test/01_proxy.js +449 -0
  31. package/build/node-http-mitm-proxy/test/www/1024.bin +64 -0
  32. package/build/node-http-mitm-proxy/test/wwwA/1024.bin +64 -0
  33. package/build/node-http-mitm-proxy/test/wwwA/example.com.html +8 -0
  34. package/build/node-http-mitm-proxy/test/wwwA/index.html +0 -0
  35. package/build/node-http-mitm-proxy/test/wwwB/1024.bin +64 -0
  36. package/build/node-http-mitm-proxy/test/wwwB/index.html +0 -0
  37. package/build/private/keys/README.md +2 -0
  38. package/build/private/keys/server.crt +20 -0
  39. package/build/private/keys/server.key +28 -0
  40. package/build/private/keys/ssl.conf +25 -0
  41. package/build/server/src/Global.js +38 -0
  42. package/build/server/src/Global.js.map +1 -0
  43. package/build/server/src/Http2Proxy.js +197 -0
  44. package/build/server/src/Http2Proxy.js.map +1 -0
  45. package/build/server/src/HttpMessage.js +99 -0
  46. package/build/server/src/HttpMessage.js.map +1 -0
  47. package/build/server/src/HttpProxy.js +196 -0
  48. package/build/server/src/HttpProxy.js.map +1 -0
  49. package/build/server/src/HttpsProxy.js +110 -0
  50. package/build/server/src/HttpsProxy.js.map +1 -0
  51. package/build/server/src/LogProxy.js +115 -0
  52. package/build/server/src/LogProxy.js.map +1 -0
  53. package/build/server/src/Paths.js +28 -0
  54. package/build/server/src/Paths.js.map +1 -0
  55. package/build/server/src/Ping.js +21 -0
  56. package/build/server/src/Ping.js.map +1 -0
  57. package/build/server/src/ProxyAllApp.js +70 -0
  58. package/build/server/src/ProxyAllApp.js.map +1 -0
  59. package/build/server/src/Resend.js +89 -0
  60. package/build/server/src/Resend.js.map +1 -0
  61. package/build/server/src/SocketIoManager.js +312 -0
  62. package/build/server/src/SocketIoManager.js.map +1 -0
  63. package/build/server/src/SocketMessage.js +68 -0
  64. package/build/server/src/SocketMessage.js.map +1 -0
  65. package/build/server/src/TcpProxy.js +202 -0
  66. package/build/server/src/TcpProxy.js.map +1 -0
  67. package/build/server/src/formatters/HexFormatter.js +33 -0
  68. package/build/server/src/formatters/HexFormatter.js.map +1 -0
  69. package/build/server/src/formatters/MongoFormatter.js +97 -0
  70. package/build/server/src/formatters/MongoFormatter.js.map +1 -0
  71. package/build/server/src/formatters/MongoOpCode.js +51 -0
  72. package/build/server/src/formatters/MongoOpCode.js.map +1 -0
  73. package/build/server/src/formatters/RedisFormatter.js +25 -0
  74. package/build/server/src/formatters/RedisFormatter.js.map +1 -0
  75. package/build/server/src/formatters/SqlCommand.js +111 -0
  76. package/build/server/src/formatters/SqlCommand.js.map +1 -0
  77. package/build/server/src/formatters/SqlFormatter.js +150 -0
  78. package/build/server/src/formatters/SqlFormatter.js.map +1 -0
  79. package/client/README.md +46 -0
  80. package/client/build/asset-manifest.json +26 -0
  81. package/client/build/favicon.ico +0 -0
  82. package/client/build/index.html +1 -0
  83. package/client/build/manifest.json +8 -0
  84. package/client/build/robots.txt +3 -0
  85. package/client/build/static/css/2.bbde182e.chunk.css +12 -0
  86. package/client/build/static/css/2.bbde182e.chunk.css.map +1 -0
  87. package/client/build/static/css/main.5bf489b2.chunk.css +2 -0
  88. package/client/build/static/css/main.5bf489b2.chunk.css.map +1 -0
  89. package/client/build/static/js/2.ba308ba1.chunk.js +3 -0
  90. package/client/build/static/js/2.ba308ba1.chunk.js.LICENSE.txt +100 -0
  91. package/client/build/static/js/2.ba308ba1.chunk.js.map +1 -0
  92. package/client/build/static/js/3.7073b0d8.chunk.js +2 -0
  93. package/client/build/static/js/3.7073b0d8.chunk.js.map +1 -0
  94. package/client/build/static/js/main.494a7501.chunk.js +2 -0
  95. package/client/build/static/js/main.494a7501.chunk.js.map +1 -0
  96. package/client/build/static/js/runtime-main.00264969.js +2 -0
  97. package/client/build/static/js/runtime-main.00264969.js.map +1 -0
  98. package/client/build/static/media/fa-brands-400.2285773e.woff +0 -0
  99. package/client/build/static/media/fa-brands-400.23f19bb0.eot +0 -0
  100. package/client/build/static/media/fa-brands-400.2f517e09.svg +3717 -0
  101. package/client/build/static/media/fa-brands-400.527940b1.ttf +0 -0
  102. package/client/build/static/media/fa-brands-400.d878b0a6.woff2 +0 -0
  103. package/client/build/static/media/fa-regular-400.4689f52c.svg +801 -0
  104. package/client/build/static/media/fa-regular-400.491974d1.ttf +0 -0
  105. package/client/build/static/media/fa-regular-400.77206a6b.eot +0 -0
  106. package/client/build/static/media/fa-regular-400.7a333762.woff2 +0 -0
  107. package/client/build/static/media/fa-regular-400.bb58e57c.woff +0 -0
  108. package/client/build/static/media/fa-solid-900.1551f4f6.woff2 +0 -0
  109. package/client/build/static/media/fa-solid-900.7a8b4f13.svg +5034 -0
  110. package/client/build/static/media/fa-solid-900.9bbb245e.eot +0 -0
  111. package/client/build/static/media/fa-solid-900.be9ee23c.ttf +0 -0
  112. package/client/build/static/media/fa-solid-900.eeccf4f6.woff +0 -0
  113. package/package.json +80 -0
package/README.md ADDED
@@ -0,0 +1,277 @@
1
+ <h1 align="center" style="border-bottom: none;">ProxyAll: HTTP, SQL, gRPC... Debugging Tool</h1>
2
+
3
+ ProxyAll is similar to Fiddler and Charles, but in addition to HTTP(S), it also can captures SQL, gRPC, MongoDB, Redis, Memcached, TCP, and log messages.
4
+
5
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/dashboard.png)
6
+
7
+ **Features:**
8
+ * captures HTTP and/or HTTPS messages as either a forward or reverse proxy
9
+ * captures SQL, MongoDB, Redis, gRPC, and other protocol messages sent to backend services
10
+ * captures log messages from dockers logs
11
+ * modify and resend HTTP requests
12
+ * search entire request/response message for matching text
13
+ * stop/start recording
14
+ * take snapshots of captured messages
15
+ * export and import captured messages
16
+ * supports multiple dashboard browser tabs
17
+
18
+ ### Table of Contents
19
+
20
+ * [Quick Start](#quick-start)
21
+ * [Node Version](#node-version)
22
+ * [Install ProxyAll](#install-proxyall-proxy)
23
+ * [Build ProxyAll](#build-proxyall-proxy)
24
+ * [Start the ProxyAll](#start-the-proxyall-proxy)
25
+ * [Open Dashboard in Browser](#open-dashboard-in-browser)
26
+ * [Configure Browser Proxy](#configure-browser-proxy)
27
+ * [Screenshots](#screenshots)
28
+ * [Configuration](#configuration)
29
+ * [HTTP/HTTPS Proxy](http-https-proxy)
30
+ * [MySQL Proxy](#mysql-proxy)
31
+ * [gRPC Proxy](#grpc-Proxy)
32
+ * [MongoDB Proxy](#mongodb-proxy)
33
+ * [Redis Proxy](#redis-proxy)
34
+ * [TCP Proxy](tcp-proxy)
35
+ * [Docker Logs](#docker-logs)
36
+ * [Dashboard](#dashboard)
37
+ * [Pause Recording](#pause-recording)
38
+ * [Filter Messages](#filter-messages)
39
+ * [Resend HTTP Requests](#resend-http-requests)
40
+ * [Snapshots](#snapshots)
41
+ * [Multiple Browser Tabs](#multiple-browser-tabs)
42
+ * [Certificates](#certificates)
43
+ * [Implementation](#imlementation)
44
+ * [Limitations](#limitations)
45
+
46
+ ## Quick Start
47
+
48
+ ### Node Version
49
+ The ProxyAll has been tested with node versions v10.22.1, and v12.19.1. Version 10 or higher is recommended. Use nvm to install the appropriate node version.
50
+
51
+ ### Install ProxyAll
52
+ ```sh
53
+ $ cd ~/git/proxyall
54
+ proxyall$ npm install
55
+ ```
56
+
57
+ ### Build ProxyAll
58
+ ```sh
59
+ proxyall$ npm run build
60
+ ```
61
+
62
+ #### ProxyAll Parameters
63
+ ```sh
64
+ Usage: npm start [--listen [host:]port] [--listenHttps [host:]port]
65
+
66
+ Options:
67
+ --listen - listen for incoming http connections. Default is 8888.
68
+ --listenHttps - listen for incoming https connections.
69
+
70
+ Example: npm start -- --listen 8888 --listenHttps 9999
71
+ ```
72
+
73
+ ### Start the ProxyAll
74
+
75
+ ```sh
76
+ proxyall$ npm start
77
+
78
+ > proxyall@1.0.0 start /home/davechri/proxyall-proxy
79
+ > if ./scripts/noDir.sh ./build; then npm run build; fi; if ./scripts/noDir.sh ./client/build; then npm run build-client; fi; NODE_ENV=production node ./build/app.js
80
+
81
+ Listening on http: 8888
82
+ Open browser to http://localhost:8888/proxyall
83
+
84
+ Listening on https: 9999
85
+ ```
86
+ ### Open Dashboard in Browser
87
+
88
+ Enter http://localhost:8888/proxyall in browser.
89
+
90
+ ### Configure Browser Proxy
91
+
92
+ To capture HTTP and HTTPS messages, configure your browser to proxy HTTP/HTTPS messages to the ProxyAll. The default is to proxy HTTP messages to port 8888, and HTTPS messages to port 9999. This is how Firefox can be configured to proxy HTTP and HTTPS messages.
93
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/firefox-proxy.png)
94
+
95
+ for chrome and chromium you can set the browser proxy using environment variables http_proxy and https_proxy.
96
+ ```sh
97
+ $ http_proxy=http://localhost:8888 https_proxy://9999 chromium-browser
98
+ ```
99
+ ## Screenshots
100
+ ### Dashboard
101
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/dashboard.png)
102
+
103
+ ### Settings
104
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/settings.png)
105
+
106
+ ### Reachable Hosts
107
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/reachable.png)
108
+
109
+ ## Configuration
110
+
111
+ This section gives example on how to configure the ProxyAll. Clicking the settings icon in the upper right corner opens the Setting modal.
112
+
113
+ <h3 id="http-https-proxy">HTTP/HTTPS Proxy</h3>
114
+
115
+ Both a forward and reverse proxy is supported for HTTP/HTTPS messages. Your browser must be configured to proxy HTTP/HTTPS messages to the forward proxy. See [Configure Browser Proxy](#configure-browser-proxy) for more information on configuring your browser.
116
+
117
+ The reverse proxy can be used to transparently capture HTTP/HTTPS messages sent by backend services. The backend service is configured to send the HTTP/HTTPS messages to the ProxyAll. For example, a -search- microservice could be configured to send Elasticsearch messages to the ProxyAll by setting environment variables.
118
+
119
+ Example -search- microservice configuration:
120
+ ```sh
121
+ ELASTIC_HOST=elasticsearch
122
+ ELASTIC_PORT=9200
123
+ ```
124
+
125
+ Modified -search- micorservice configuration:
126
+ ```sh
127
+ ELASTIC_HOST=proxyall # proxyall is the docker container host name
128
+ ELASTIC_PORT=8888 # proxyall HTTP port is 8888. Use 9999 for HTTPS.
129
+ ```
130
+
131
+ An HTTP path is added to proxy HTTP requests to the elasticsearch host. All HTTP requests matching path /_search are proxied to the elasticsearch host on port 9200.
132
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/elasticsearch-settings.png)
133
+
134
+ ### MySQL Proxy
135
+ The SQL proxy can transparently capture SQL messages sent by backend microservices to a MySQL server.
136
+
137
+ Example microservice config file:
138
+ ```sh
139
+ MYSQL_HOST=mysql
140
+ MYSQL_PORT=3306
141
+ ```
142
+
143
+ Modified microservice config file:
144
+ ```sh
145
+ MYSQL_HOST=proxyall # Proxy queries to the ProxyAll
146
+ MYSQL_PORT=3306
147
+ ```
148
+
149
+ The ProxyAll is configured to proxy MySQL requests to the MySQL server:
150
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/mysql-settings.png)
151
+
152
+ ### gRPC Proxy
153
+ The gRPC proxy can transparently capture gRPC HTTP/2 messages sent to backend microservices. Only unsecure connections are supported. Secure TLS support may be added in the future.
154
+
155
+ Example gRPC microservice config file:
156
+ ```sh
157
+ GRPC_HOST=grpchost # gRPC host name
158
+ GRPC_PORT=12345 # gRPC port number
159
+ ```
160
+
161
+ Modified gRPC microservice config file:
162
+ ```sh
163
+ GRPC_HOST=proxyall # Proxy gRPC requests to the ProxyAll
164
+ GRPC_PORT=12345
165
+ ```
166
+
167
+ The ProxyAll is configured to proxy gRPC requests to a microservice:
168
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/grpc-settings.png)
169
+
170
+ ### MongoDB Proxy
171
+ The MongoDB proxy can transparently capture MongoDB messages sent by backend microservices.
172
+
173
+ Example MongoDB microservice config file:
174
+ ```sh
175
+ MONGO_HOST=mongodb # MongoDB host name
176
+ MONGO_PORT=27017 # MongoDB port number
177
+ ```
178
+
179
+ Modified MongoDB microservice config file:
180
+ ```sh
181
+ MONGO_HOST=proxyall # Proxy MongoDB requests to the ProxyAll
182
+ MONGO_PORT=27017
183
+ ```
184
+
185
+ The ProxyAll is configured to proxy MongoDB requests to a microservice:
186
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/mongodb-settings.png)
187
+
188
+ ### Redis Proxy
189
+ The Redis proxy can transparently capture Redis messages sent by backend microservices.
190
+
191
+ Example Redis microservice config file:
192
+ ```sh
193
+ REDIS_HOST=redis # Redis host name
194
+ REDIS_PORT=6379 # Redis port number
195
+ ```
196
+
197
+ Modified Redis microservice config file:
198
+ ```sh
199
+ REDIS_HOST=proxyall # Proxy Redis requests to the ProxyAll
200
+ REDIS_PORT=6379
201
+ ```
202
+
203
+ The ProxyAll is configured to proxy Redis requests to a microservice:
204
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/redis-settings.png)
205
+
206
+ ### TCP Proxy
207
+ The TCP proxy can transparently capture TCP request/response messages sent by backend microservices. For example, the TCP proxy can be used to capture memcached messages.
208
+
209
+ Example Memcached microservice config file:
210
+ ```sh
211
+ MEMCACHED_HOST=memcached # Memcached host name
212
+ MEMCACHED_PORT=11211 # Memcached port number
213
+ ```
214
+
215
+ Modified Memcached microservice config file:
216
+ ```sh
217
+ MEMCACHED_HOST=proxyall # Proxy Memcached requests to the ProxyAll
218
+ MEMCACHED_PORT=11211
219
+ ```
220
+
221
+ The ProxyAll is configured to proxy Memcached requests to a microservice:
222
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/memcached-settings.png)
223
+
224
+ ### Dockers Logs
225
+ The Docker log proxy can capture log messages.
226
+
227
+ The ProxyAll is configured to capture Dockers log messages:
228
+ ![ ](https://github.com/davechri/proxyall/blob/master/images/log-settings.png)
229
+
230
+ ## Dashboard
231
+ The ProxyAll dashboard is stated from the browser with URL http://localhost:8888/proxyall.
232
+
233
+ ### Pause Recording
234
+ The recording of messages can be temporarily stopped, to allow time to examine the messages without the log wrapping.
235
+
236
+ ### Filter Messages
237
+ Filtering allows you to find messages matching a search filter, and hide other messages. The entire message is search for a match. The filter may be *case insensitive*, *case sensitive*, a *logical expression*, or a *regular expression*.
238
+
239
+ Types of filters:
240
+ * **case insensitive** - If *Aa* is not selected, a case insensitive search is performed.
241
+ * **case ensensitive** - If *Aa* is selected, a case sensitive search is performed.
242
+ * **logical expression** - If *&&* is selected, &&, ||, (), and ! operators may be used to build a logical expression.
243
+ * **regular expression** - If *.** is selected, regular expression match in performed.
244
+
245
+ Boolean filters can use &&, ||, !, and parenthesis.
246
+
247
+ ### Resend HTTP Requests
248
+ To resend an HTTP or HTTPS request, click on the icon next to the request to open a modal. Optionally modify the request body, and then click the send button. If the dashboard is not paused, the resent request should appear at the bottom of the dashboard request log.
249
+
250
+ ### Snapshots
251
+ Clicking on the camera icon will take a snapshot of the currently captured messages, and create a new snapshot tab. A snapshot tab may be exported to a file, and later imported again.
252
+
253
+ ### Multiple Browser Tabs
254
+ Multiple Dashboard instances can be opened in separate browser tabs, and all of the open Dashboards will record messages.
255
+
256
+ Each Dashboard instance keeps its own copy of the messages, so clearing or stopping recording in one Dashboard instance, does not affect another other Dashboard instances.
257
+
258
+ ## Certificates
259
+ Certificates are managed by the [node-http-mitm-proxy](https://github.com/joeferner/node-http-mitm-proxy/tree/master/examples) package.
260
+
261
+ Generated certificates are stored in proxyall/.http-mitm-proxy/certs/. The '/proxyall/.http-mitm-proxy/certs/ca.pem' CA certificate can be imported to your browser to trust certificates generated by the ProxyAll.
262
+
263
+ ## Implementation:
264
+ - **HTTP proxy** - The *http* package is used to proxy HTTP traffic as either a forward or reverse proxy.
265
+ - **HTTPS proxy** - The *node-http-mitm-proxy* package is used to build certificates to capture decrypted HTTPS traffic as either a forward or reverse proxy.
266
+ - **TCP proxy** - The *net* package is used to listen on a TCP port for non-HTTP messages, and proxy the protocol messages to the target host.
267
+ - **Socket.IO** - The node *socket.io* package is used to pass messages between the server and browser where they are recorded and displayed in a dashboard.
268
+ - **stdout/stderr** - Spawn a child process to read *stdout* and *stderr* from any docker log or log file, and display the log messages in the dashboard.
269
+
270
+ ## Limitations
271
+ 1. Only unsecure HTTP/2 is supported. You can only connect to gRPC without TLS.
272
+ 2. Only HTTP/2 reverse proxy is supported. HTTP/2 forward proxy is not supported.
273
+ 3. The TCP proxy does not support TLS. You can only connect to memcached without TLS.
274
+
275
+ ## License
276
+
277
+ This code is licensed under the [MIT License](https://opensource.org/licenses/MIT).
package/bin/proxyall ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ require('../build/app');
package/build/app.js ADDED
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const http_1 = __importDefault(require("http"));
7
+ const process_1 = require("process");
8
+ const Global_1 = __importDefault(require("./server/src/Global"));
9
+ const SocketIoManager_1 = __importDefault(require("./server/src/SocketIoManager"));
10
+ const HttpProxy_1 = __importDefault(require("./server/src/HttpProxy"));
11
+ const HttpsProxy_1 = __importDefault(require("./server/src/HttpsProxy"));
12
+ const node_http_mitm_proxy_1 = __importDefault(require("./node-http-mitm-proxy"));
13
+ const httpMitmProxy = node_http_mitm_proxy_1.default();
14
+ const listen = [];
15
+ let httpServer;
16
+ for (let i = 2; i < process.argv.length; ++i) {
17
+ switch (process.argv[i]) {
18
+ case '--help':
19
+ usage();
20
+ process_1.exit(1);
21
+ break;
22
+ case '--listen':
23
+ case '--listenHttps': {
24
+ if (i + 1 >= process.argv.length) {
25
+ usage();
26
+ console.error('\nMissing --listen value.');
27
+ }
28
+ const protocol = process.argv[i] === '--listenHttps' ? 'https:' : 'http:';
29
+ let host;
30
+ let port = process.argv[++i];
31
+ const tokens = port.split(':');
32
+ if (tokens.length > 1) {
33
+ host = tokens[0];
34
+ port = tokens[1];
35
+ }
36
+ const portNum = +port;
37
+ listen.push({
38
+ protocol,
39
+ host,
40
+ port: portNum
41
+ });
42
+ break;
43
+ }
44
+ default:
45
+ usage();
46
+ console.error('\nInvalid option: ' + process.argv[i]);
47
+ process_1.exit(1);
48
+ }
49
+ }
50
+ if (listen.length === 0) {
51
+ listen.push({ protocol: 'http:', port: 8888 });
52
+ listen.push({ protocol: 'https:', port: 9999 });
53
+ }
54
+ function usage() {
55
+ console.log('\nUsage: npm start [--listen [host:]port] [--listenHttps [host:]port] [--debug]');
56
+ console.log('\nOptions:');
57
+ console.log('\t--listen - listen for incoming http connections. Default is 8888.');
58
+ console.log('\t--listenHttps - listen for incoming https connections.');
59
+ console.log('\nExample: npm start -- --listen 8888 --listenHttps 9999');
60
+ }
61
+ /**
62
+ * Exception handler.
63
+ */
64
+ process.on('uncaughtException', (err) => {
65
+ console.error(err.stack);
66
+ // process.exit()
67
+ });
68
+ Global_1.default.socketIoManager = new SocketIoManager_1.default();
69
+ const httpProxy = new HttpProxy_1.default();
70
+ const httpsProxy = new HttpsProxy_1.default();
71
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; // trust all certificates
72
+ for (const entry of listen) {
73
+ const protocol = entry.protocol ? entry.protocol : 'http:';
74
+ const host = entry.host;
75
+ const port = entry.port;
76
+ if (protocol === 'https:') {
77
+ httpMitmProxy.listen({ port: port });
78
+ console.log(`Listening on ${protocol} ${host || ''} ${port}`);
79
+ httpsProxy.onRequest(httpMitmProxy);
80
+ }
81
+ else {
82
+ httpServer = http_1.default.createServer((clientReq, clientRes) => httpProxy.onRequest(clientReq, clientRes));
83
+ httpServer.listen(port, host);
84
+ console.log(`Listening on ${protocol} ${host || ''} ${port}`);
85
+ console.log(`Open browser to ${protocol}//localhost:${port}/proxyall\n`);
86
+ Global_1.default.socketIoManager.addHttpServer(httpServer);
87
+ }
88
+ }
89
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AACvB,qCAA8B;AAE9B,iEAAwC;AACxC,mFAA0D;AAC1D,uEAA8C;AAC9C,yEAAgD;AAChD,kFAAkD;AAClD,MAAM,aAAa,GAAG,8BAAa,EAAE,CAAA;AAErC,MAAM,MAAM,GAEY,EAAE,CAAA;AAC1B,IAAI,UAAsC,CAAA;AAE1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAA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IAAI,EAAE,CAAC,CAAA;QACpC,OAAO,CAAC,GAAG,CAAC,gBAAgB,QAAQ,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;QAC7D,UAAU,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;KACpC;SAAM;QACL,UAAU,GAAG,cAAI,CAAC,YAAY,CAC5B,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAA;QACtE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC7B,OAAO,CAAC,GAAG,CAAC,gBAAgB,QAAQ,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;QAC7D,OAAO,CAAC,GAAG,CAAC,mBAAmB,QAAQ,eAAe,IAAI,aAAa,CAAC,CAAA;QAExE,gBAAM,CAAC,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;KACjD;CACF"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageType = exports.NO_RESPONSE = void 0;
4
+ exports.NO_RESPONSE = 'No Response';
5
+ var MessageType;
6
+ (function (MessageType) {
7
+ MessageType[MessageType["REQUEST"] = 0] = "REQUEST";
8
+ MessageType[MessageType["RESPONSE"] = 1] = "RESPONSE";
9
+ MessageType[MessageType["REQUEST_AND_RESPONSE"] = 2] = "REQUEST_AND_RESPONSE";
10
+ })(MessageType = exports.MessageType || (exports.MessageType = {}));
11
+ class Message {
12
+ constructor() {
13
+ this.type = MessageType.REQUEST_AND_RESPONSE;
14
+ this.timestamp = 0;
15
+ this.sequenceNumber = 0;
16
+ this.requestHeaders = {};
17
+ this.responseHeaders = {};
18
+ this.method = '';
19
+ this.protocol = '';
20
+ this.url = '';
21
+ this.endpoint = '';
22
+ this.requestBody = '';
23
+ this.responseBody = '';
24
+ this.clientIp = '';
25
+ this.serverHost = '';
26
+ this.path = '';
27
+ this.elapsedTime = 0;
28
+ this.status = 0;
29
+ this.proxyConfig = undefined;
30
+ }
31
+ }
32
+ exports.default = Message;
33
+ ;
34
+ //# sourceMappingURL=Message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../common/Message.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAG,aAAa,CAAA;AACxC,IAAY,WAIX;AAJD,WAAY,WAAW;IACtB,mDAAO,CAAA;IACP,qDAAQ,CAAA;IACR,6EAAoB,CAAA;AACrB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAWD,MAAqB,OAAO;IAA5B;QACE,SAAI,GAAgB,WAAW,CAAC,oBAAoB,CAAC;QACrD,cAAS,GAAW,CAAC,CAAC;QACtB,mBAAc,GAAW,CAAC,CAAC;QAC3B,mBAAc,GAA4B,EAAE,CAAC;QAC7C,oBAAe,GAA4B,EAAE,CAAC;QAC9C,WAAM,GAAuB,EAAE,CAAC;QAChC,aAAQ,GAAyB,EAAE,CAAC;QACpC,QAAG,GAAqB,EAAE,CAAC;QAC3B,aAAQ,GAAW,EAAE,CAAC;QACtB,gBAAW,GAA+B,EAAE,CAAC;QAC7C,iBAAY,GAA+B,EAAE,CAAC;QAC9C,aAAQ,GAAqB,EAAE,CAAC;QAChC,eAAU,GAAW,EAAE,CAAC;QACxB,SAAI,GAAW,EAAE,CAAC;QAClB,gBAAW,GAAW,CAAC,CAAC;QACxB,WAAM,GAAW,CAAC,CAAC;QACnB,gBAAW,GAAiB,SAAS,CAAC;IACxC,CAAC;CAAA;AAlBD,0BAkBC;AAAA,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ProxyConfig {
4
+ constructor() {
5
+ this.isSecure = false;
6
+ this.path = '';
7
+ this.protocol = 'http:';
8
+ this.hostname = '';
9
+ this.port = 0;
10
+ this.recording = true;
11
+ this.hostReachable = true;
12
+ this.logProxyProcess = undefined;
13
+ this.comment = '';
14
+ }
15
+ static isHttpOrHttps(config) {
16
+ switch (config.protocol) {
17
+ case 'http:':
18
+ case 'https:':
19
+ case 'browser:':
20
+ return true;
21
+ default:
22
+ return false;
23
+ }
24
+ }
25
+ }
26
+ exports.default = ProxyConfig;
27
+ //# sourceMappingURL=ProxyConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProxyConfig.js","sourceRoot":"","sources":["../../common/ProxyConfig.ts"],"names":[],"mappings":";;AAcA,MAAqB,WAAW;IAAhC;QACE,aAAQ,GAAY,KAAK,CAAC;QAC1B,SAAI,GAAW,EAAE,CAAC;QAClB,aAAQ,GAAmB,OAAO,CAAC;QACnC,aAAQ,GAAW,EAAE,CAAC;QACtB,SAAI,GAAW,CAAC,CAAC;QACjB,cAAS,GAAY,IAAI,CAAC;QAC1B,kBAAa,GAAY,IAAI,CAAC;QAC9B,oBAAe,GAAS,SAAS,CAAC;QAElC,YAAO,GAAU,EAAE,CAAC;IAYtB,CAAC;IAVC,MAAM,CAAC,aAAa,CAAE,MAAmB;QACvC,QAAQ,MAAM,CAAC,QAAQ,EAAE;YACvB,KAAK,OAAO,CAAC;YACb,KAAK,QAAQ,CAAC;YACd,KAAK,UAAU;gBACb,OAAO,IAAI,CAAA;YACb;gBACE,OAAO,KAAK,CAAA;SACf;IACH,CAAC;CACF;AAtBD,8BAsBC"}
@@ -0,0 +1,2 @@
1
+ # The test files should be treated as binary to prevent LF/CRLF conversion on windows.
2
+ *.bin binary
@@ -0,0 +1,10 @@
1
+ language: node_js
2
+ os:
3
+ - "windows"
4
+ - "osx"
5
+ - "linux"
6
+ node_js:
7
+ - "10"
8
+ - "12"
9
+ - "lts/*"
10
+ - "node"