@warren-bank/hls-proxy 0.20.0 → 0.20.2

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 CHANGED
@@ -282,6 +282,8 @@ options:
282
282
  * show technical details
283
283
  * `3`:
284
284
  * show an enhanced technical trace (useful while debugging unexpected behavior)
285
+ * `4`:
286
+ * show the content of .m3u8 files (both before and after URLs are modified)
285
287
  * _--acl-whitelist_ restricts proxy server access to clients at IP addresses in whitelist
286
288
  * ex: `"192.168.1.100,192.168.1.101,192.168.1.102"`
287
289
  * _--tls-cert_ is the filepath to a security certificate to use for HTTPS
@@ -13,6 +13,10 @@ const base64_decode = function(str) {
13
13
 
14
14
  const proxy = function({server, host, is_secure, req_headers, req_options, hooks, cache_segments, max_segments, cache_timeout, cache_key, debug_level, acl_whitelist}) {
15
15
 
16
+ const debug_divider = (debug_level >= 4)
17
+ ? ('-').repeat(40)
18
+ : ''
19
+
16
20
  const debug = function() {
17
21
  let args = [...arguments]
18
22
  let verbosity = args.shift()
@@ -95,6 +99,10 @@ const proxy = function({server, host, is_secure, req_headers, req_options, hooks
95
99
  "absolute": m3u8_url.replace(/(:\/\/[^\/]+).*$/, '$1')
96
100
  }
97
101
 
102
+ if (debug_level >= 4) {
103
+ debug(4, 'proxied response (original m3u8):', `\n${debug_divider}\n${m3u8_content}\n${debug_divider}`)
104
+ }
105
+
98
106
  if (debug_level >= 2) {
99
107
  m3u8_content = m3u8_content.replace(regexs.keys, function(match, head, key_url, tail) {
100
108
  debug(2, 'key:', key_url)
@@ -383,6 +391,10 @@ const proxy = function({server, host, is_secure, req_headers, req_options, hooks
383
391
  })
384
392
  }
385
393
 
394
+ if (debug_level >= 4) {
395
+ debug(4, 'proxied response (modified m3u8):', `\n${debug_divider}\n${m3u8_content}\n${debug_divider}`)
396
+ }
397
+
386
398
  return m3u8_content
387
399
  }
388
400
 
@@ -463,13 +475,19 @@ const proxy = function({server, host, is_secure, req_headers, req_options, hooks
463
475
  debug(3, 'm3u8:', (is_m3u8 ? 'true' : 'false'))
464
476
 
465
477
  request(options, '', {binary: !is_m3u8, stream: !is_m3u8})
466
- .then(({response}) => {
478
+ .then(({redirects, response}) => {
479
+ debug(2, 'proxied response:', {status_code: response.statusCode, headers: response.headers, redirects})
480
+
467
481
  if (!is_m3u8) {
468
482
  response.pipe(res)
469
483
  }
470
484
  else {
485
+ const m3u8_url = (redirects && Array.isArray(redirects) && redirects.length)
486
+ ? redirects[(redirects.length - 1)]
487
+ : url
488
+
471
489
  res.writeHead(200, { "Content-Type": "application/x-mpegURL" })
472
- res.end( modify_m3u8_content(response, url, referer_url) )
490
+ res.end( modify_m3u8_content(response.toString().trim(), m3u8_url, referer_url) )
473
491
  }
474
492
  })
475
493
  .catch((e) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warren-bank/hls-proxy",
3
3
  "description": "Node.js server to proxy HLS video streams",
4
- "version": "0.20.0",
4
+ "version": "0.20.2",
5
5
  "scripts": {
6
6
  "start": "node hls-proxy/bin/hlsd.js",
7
7
  "sudo": "sudo node hls-proxy/bin/hlsd.js"