@warren-bank/hls-proxy 3.6.7 → 3.6.8
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.
- package/README.md +25 -1
- package/hls-proxy/bin/lib/help.js +1 -0
- package/hls-proxy/bin/lib/process_argv.js +94 -1
- package/hls-proxy/utils.js +15 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,6 +160,7 @@ options:
|
|
|
160
160
|
--acl-ip <ip_address_list>
|
|
161
161
|
--acl-pass <password_list>
|
|
162
162
|
--block-req-hostname <hostname_list>
|
|
163
|
+
--allow-private-req-hostnames
|
|
163
164
|
--http-proxy <http[s]://[user:pass@]hostname:port>
|
|
164
165
|
--tls-cert <filepath>
|
|
165
166
|
--tls-key <filepath>
|
|
@@ -400,7 +401,30 @@ options:
|
|
|
400
401
|
* _--acl-pass_ restricts proxy server access to requests that include a `password` querystring parameter having a value in whitelist
|
|
401
402
|
* ex: `"1111,2222,3333,4444,5555"`
|
|
402
403
|
* _--block-req-hostname_ blocks proxy server requests to hostnames in blacklist
|
|
403
|
-
*
|
|
404
|
+
* the value is a comma-separated list that is normalized to lowercase
|
|
405
|
+
* the value of each item in the list can use any of the following formats:
|
|
406
|
+
- includes substring
|
|
407
|
+
* value begins and ends with `*` character
|
|
408
|
+
* ex: `"*foo*"`<br>blacklists all hostnames that include the substring: `foo`
|
|
409
|
+
- starts with substring
|
|
410
|
+
* value ends with `*` character
|
|
411
|
+
* ex: `"www.*"`<br>blacklists all hostnames that start with the substring: `www.`
|
|
412
|
+
- ends with substring
|
|
413
|
+
* value starts with `*` character
|
|
414
|
+
* ex: `"*.foo.com"`<br>blacklists all hostnames that end with the substring: `.foo.com`
|
|
415
|
+
- matches regex pattern
|
|
416
|
+
* value begins and ends with `/` character
|
|
417
|
+
* ex: `"/^www\..+\.com$/"`<br>blacklists all hostnames that both start with the substring: `www.`, and end with the substring: `.com`
|
|
418
|
+
- equals exact string
|
|
419
|
+
* all other values
|
|
420
|
+
* ex: `"localhost,127.0.0.1"`
|
|
421
|
+
* _--allow-private-req-hostnames_ is a flag to prevent the automatic addition of the following values to the _--block-req-hostname_ blacklist:
|
|
422
|
+
```text
|
|
423
|
+
localhost,
|
|
424
|
+
::1,
|
|
425
|
+
/^(0\.|10\.|127\.|169\.254\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/,
|
|
426
|
+
/^(fe80:|fc|fd|::ffff:(0\.|10\.|127\.|169\.254\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.))/
|
|
427
|
+
```
|
|
404
428
|
* --http-proxy enables all outbound HTTP and HTTPS requests from HLS-Proxy to be tunnelled through an additional external web proxy server
|
|
405
429
|
* SOCKS proxies are not supported
|
|
406
430
|
* ex: `http://myusername:mypassword@myproxy.example.com:1234`
|
|
@@ -39,6 +39,7 @@ const argv_flags = {
|
|
|
39
39
|
"--acl-ip": {},
|
|
40
40
|
"--acl-pass": {},
|
|
41
41
|
"--block-req-hostname": {},
|
|
42
|
+
"--allow-private-req-hostnames": {bool: true},
|
|
42
43
|
"--http-proxy": {},
|
|
43
44
|
|
|
44
45
|
"--tls-cert": {file: "path-exists"},
|
|
@@ -179,7 +180,99 @@ if (argv_vals["--acl-pass"]) {
|
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
if (argv_vals["--block-req-hostname"]) {
|
|
182
|
-
|
|
183
|
+
const blacklist = argv_vals["--block-req-hostname"].trim().toLowerCase().split(/\s*,\s*/g)
|
|
184
|
+
|
|
185
|
+
argv_vals["--block-req-hostname"] = {
|
|
186
|
+
includes: [],
|
|
187
|
+
startsWith: [],
|
|
188
|
+
endsWith: [],
|
|
189
|
+
match: [],
|
|
190
|
+
equals: []
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
for (const item of blacklist) {
|
|
194
|
+
if (!item) continue
|
|
195
|
+
|
|
196
|
+
const globStart = item.startsWith('*')
|
|
197
|
+
const globEnd = item.endsWith('*')
|
|
198
|
+
const regexStart = item.startsWith('/')
|
|
199
|
+
const regexEnd = item.endsWith('/')
|
|
200
|
+
|
|
201
|
+
if (globStart && globEnd) {
|
|
202
|
+
if (item.length > 2) {
|
|
203
|
+
argv_vals["--block-req-hostname"].includes.push(
|
|
204
|
+
item.substring(1, item.length - 1)
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
continue
|
|
208
|
+
}
|
|
209
|
+
if (globEnd) {
|
|
210
|
+
if (item.length > 1) {
|
|
211
|
+
argv_vals["--block-req-hostname"].startsWith.push(
|
|
212
|
+
item.substring(0, item.length - 1)
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
continue
|
|
216
|
+
}
|
|
217
|
+
if (globStart) {
|
|
218
|
+
if (item.length > 1) {
|
|
219
|
+
argv_vals["--block-req-hostname"].endsWith.push(
|
|
220
|
+
item.substring(1, item.length)
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
continue
|
|
224
|
+
}
|
|
225
|
+
if (regexStart && regexEnd) {
|
|
226
|
+
if (item.length > 2) {
|
|
227
|
+
try {
|
|
228
|
+
const regex = new RegExp(item.substring(1, item.length - 1))
|
|
229
|
+
|
|
230
|
+
argv_vals["--block-req-hostname"].match.push(
|
|
231
|
+
regex
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
catch(ignored) {}
|
|
235
|
+
}
|
|
236
|
+
continue
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
argv_vals["--block-req-hostname"].equals.push(
|
|
240
|
+
item
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (!argv_vals["--allow-private-req-hostnames"]) {
|
|
247
|
+
if (!argv_vals["--block-req-hostname"]) {
|
|
248
|
+
argv_vals["--block-req-hostname"] = {
|
|
249
|
+
includes: [],
|
|
250
|
+
startsWith: [],
|
|
251
|
+
endsWith: [],
|
|
252
|
+
match: [],
|
|
253
|
+
equals: []
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
argv_vals["--block-req-hostname"].match.push(
|
|
257
|
+
/^(0\.|10\.|127\.|169\.254\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/,
|
|
258
|
+
/^(fe80:|fc|fd|::ffff:(0\.|10\.|127\.|169\.254\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.))/
|
|
259
|
+
)
|
|
260
|
+
argv_vals["--block-req-hostname"].equals.push(
|
|
261
|
+
'localhost',
|
|
262
|
+
'::1'
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (argv_vals["--block-req-hostname"]) {
|
|
267
|
+
if (
|
|
268
|
+
!argv_vals["--block-req-hostname"].includes.length &&
|
|
269
|
+
!argv_vals["--block-req-hostname"].startsWith.length &&
|
|
270
|
+
!argv_vals["--block-req-hostname"].endsWith.length &&
|
|
271
|
+
!argv_vals["--block-req-hostname"].match.length &&
|
|
272
|
+
!argv_vals["--block-req-hostname"].equals.length
|
|
273
|
+
) {
|
|
274
|
+
argv_vals["--block-req-hostname"] = null
|
|
275
|
+
}
|
|
183
276
|
}
|
|
184
277
|
|
|
185
278
|
if (argv_vals["--http-proxy"]) {
|
package/hls-proxy/utils.js
CHANGED
|
@@ -201,7 +201,7 @@ const block_request_options = function(params, request_options) {
|
|
|
201
201
|
const {block_req_hostname} = params
|
|
202
202
|
|
|
203
203
|
// short circuit
|
|
204
|
-
if (!block_req_hostname || !
|
|
204
|
+
if (!block_req_hostname || !request_options)
|
|
205
205
|
return false
|
|
206
206
|
|
|
207
207
|
// special case: url
|
|
@@ -212,7 +212,20 @@ const block_request_options = function(params, request_options) {
|
|
|
212
212
|
if (!request_options.hostname || (typeof request_options.hostname !== 'string'))
|
|
213
213
|
return false
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
const hostname = request_options.hostname.toLowerCase()
|
|
216
|
+
for (const blacklist_item of block_req_hostname.includes) {
|
|
217
|
+
if (hostname.includes(blacklist_item)) return true
|
|
218
|
+
}
|
|
219
|
+
for (const blacklist_item of block_req_hostname.startsWith) {
|
|
220
|
+
if (hostname.startsWith(blacklist_item)) return true
|
|
221
|
+
}
|
|
222
|
+
for (const blacklist_item of block_req_hostname.endsWith) {
|
|
223
|
+
if (hostname.endsWith(blacklist_item)) return true
|
|
224
|
+
}
|
|
225
|
+
for (const blacklist_item of block_req_hostname.match) {
|
|
226
|
+
if (blacklist_item.test(hostname)) return true
|
|
227
|
+
}
|
|
228
|
+
return (block_req_hostname.equals.indexOf(hostname) >= 0)
|
|
216
229
|
}
|
|
217
230
|
|
|
218
231
|
const should_prefetch_url = function(params, url, url_type) {
|
package/package.json
CHANGED