@warren-bank/hls-proxy 3.2.5 → 3.3.0
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 +5 -1
- package/hls-proxy/bin/hlsd.js +2 -1
- package/hls-proxy/bin/lib/help.js +2 -1
- package/hls-proxy/bin/lib/process_argv.js +20 -1
- package/hls-proxy/utils.js +9 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -110,7 +110,7 @@ options:
|
|
|
110
110
|
--help
|
|
111
111
|
--version
|
|
112
112
|
--tls
|
|
113
|
-
--host <
|
|
113
|
+
--host <host>
|
|
114
114
|
--port <number>
|
|
115
115
|
--req-headers <filepath>
|
|
116
116
|
--origin <header>
|
|
@@ -130,6 +130,7 @@ options:
|
|
|
130
130
|
--cache-key <number>
|
|
131
131
|
-v <number>
|
|
132
132
|
--acl-whitelist <ip_address_list>
|
|
133
|
+
--http-proxy <http[s]://[user:pass@]hostname:port>
|
|
133
134
|
--tls-cert <filepath>
|
|
134
135
|
--tls-key <filepath>
|
|
135
136
|
--tls-pass <filepath>
|
|
@@ -342,6 +343,9 @@ options:
|
|
|
342
343
|
* show the content of .m3u8 files (both before and after URLs are modified)
|
|
343
344
|
* _--acl-whitelist_ restricts proxy server access to clients at IP addresses in whitelist
|
|
344
345
|
* ex: `"192.168.1.100,192.168.1.101,192.168.1.102"`
|
|
346
|
+
* --http-proxy enables all outbound HTTP and HTTPS requests from HLS-Proxy to be tunnelled through an additional external web proxy server
|
|
347
|
+
* SOCKS proxies are not supported
|
|
348
|
+
* ex: `http://myusername:mypassword@myproxy.example.com:1234`
|
|
345
349
|
* _--tls-cert_ is the filepath to a security certificate to use for HTTPS
|
|
346
350
|
* _--tls-key_ is the filepath to the private key for the _--tls-cert_ security certificate
|
|
347
351
|
* _--tls-pass_ is the filepath to a text file containing the security passphrase for the _--tls-key_ private key
|
package/hls-proxy/bin/hlsd.js
CHANGED
|
@@ -42,7 +42,8 @@ const middleware = require('../proxy')({
|
|
|
42
42
|
cache_timeout: argv_vals["--cache-timeout"],
|
|
43
43
|
cache_key: argv_vals["--cache-key"],
|
|
44
44
|
debug_level: argv_vals["-v"],
|
|
45
|
-
acl_whitelist: argv_vals["--acl-whitelist"]
|
|
45
|
+
acl_whitelist: argv_vals["--acl-whitelist"],
|
|
46
|
+
http_proxy: argv_vals["--http-proxy"]
|
|
46
47
|
})
|
|
47
48
|
|
|
48
49
|
if (middleware.connection)
|
|
@@ -6,7 +6,7 @@ options:
|
|
|
6
6
|
--help
|
|
7
7
|
--version
|
|
8
8
|
--tls
|
|
9
|
-
--host <
|
|
9
|
+
--host <host>
|
|
10
10
|
--port <number>
|
|
11
11
|
--req-headers <filepath>
|
|
12
12
|
--origin <header>
|
|
@@ -26,6 +26,7 @@ options:
|
|
|
26
26
|
--cache-key <number>
|
|
27
27
|
-v <number>
|
|
28
28
|
--acl-whitelist <ip_address_list>
|
|
29
|
+
--http-proxy <http[s]://[user:pass@]hostname:port>
|
|
29
30
|
--tls-cert <filepath>
|
|
30
31
|
--tls-key <filepath>
|
|
31
32
|
--tls-pass <filepath>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const process_argv = require('@warren-bank/node-process-argv')
|
|
2
2
|
|
|
3
|
+
const {HttpProxyAgent, HttpsProxyAgent} = require('hpagent')
|
|
4
|
+
|
|
3
5
|
const argv_flags = {
|
|
4
6
|
"--help": {bool: true},
|
|
5
7
|
"--version": {bool: true},
|
|
@@ -30,6 +32,7 @@ const argv_flags = {
|
|
|
30
32
|
|
|
31
33
|
"-v": {num: "int"},
|
|
32
34
|
"--acl-whitelist": {},
|
|
35
|
+
"--http-proxy": {},
|
|
33
36
|
|
|
34
37
|
"--tls-cert": {file: "path-exists"},
|
|
35
38
|
"--tls-key": {file: "path-exists"},
|
|
@@ -37,7 +40,8 @@ const argv_flags = {
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
const argv_flag_aliases = {
|
|
40
|
-
"--help": ["-h"]
|
|
43
|
+
"--help": ["-h"],
|
|
44
|
+
"--http-proxy": ["--https-proxy", "--proxy"]
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
let argv_vals = {}
|
|
@@ -160,4 +164,19 @@ if (typeof argv_vals["--cache-key"] !== 'number')
|
|
|
160
164
|
if (typeof argv_vals["-v"] !== 'number')
|
|
161
165
|
argv_vals["-v"] = 0
|
|
162
166
|
|
|
167
|
+
if (argv_vals["--http-proxy"]) {
|
|
168
|
+
const proxy_options = {
|
|
169
|
+
keepAlive: true,
|
|
170
|
+
keepAliveMsecs: 1000,
|
|
171
|
+
maxSockets: 256,
|
|
172
|
+
maxFreeSockets: 256,
|
|
173
|
+
proxy: argv_vals["--http-proxy"]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
argv_vals["--http-proxy"] = {
|
|
177
|
+
"http:": new HttpProxyAgent( proxy_options),
|
|
178
|
+
"https:": new HttpsProxyAgent(proxy_options)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
163
182
|
module.exports = argv_vals
|
package/hls-proxy/utils.js
CHANGED
|
@@ -97,7 +97,7 @@ const debug = function() {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
const get_request_options = function(params, url, is_m3u8, referer_url) {
|
|
100
|
-
const {req_headers, req_options, hooks} = params
|
|
100
|
+
const {req_headers, req_options, hooks, http_proxy} = params
|
|
101
101
|
|
|
102
102
|
const additional_req_options = (hooks && (hooks instanceof Object) && hooks.add_request_options && (typeof hooks.add_request_options === 'function'))
|
|
103
103
|
? hooks.add_request_options(url, is_m3u8)
|
|
@@ -107,7 +107,7 @@ const get_request_options = function(params, url, is_m3u8, referer_url) {
|
|
|
107
107
|
? hooks.add_request_headers(url, is_m3u8)
|
|
108
108
|
: null
|
|
109
109
|
|
|
110
|
-
if (!req_options && !additional_req_options && !req_headers && !additional_req_headers && !referer_url) return url
|
|
110
|
+
if (!req_options && !http_proxy && !additional_req_options && !req_headers && !additional_req_headers && !referer_url) return url
|
|
111
111
|
|
|
112
112
|
const request_options = Object.assign(
|
|
113
113
|
{},
|
|
@@ -125,6 +125,13 @@ const get_request_options = function(params, url, is_m3u8, referer_url) {
|
|
|
125
125
|
(referer_url ? {"referer": referer_url, "origin": referer_url.replace(regexs.origin, '$1')} : {})
|
|
126
126
|
)
|
|
127
127
|
|
|
128
|
+
// normalize
|
|
129
|
+
if (request_options.protocol)
|
|
130
|
+
request_options.protocol = request_options.protocol.toLowerCase()
|
|
131
|
+
|
|
132
|
+
if (!request_options.agent && http_proxy && request_options.protocol && http_proxy[request_options.protocol])
|
|
133
|
+
request_options.agent = http_proxy[request_options.protocol]
|
|
134
|
+
|
|
128
135
|
return request_options
|
|
129
136
|
}
|
|
130
137
|
|
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": "3.
|
|
4
|
+
"version": "3.3.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "node hls-proxy/bin/hlsd.js",
|
|
7
7
|
"sudo": "sudo node hls-proxy/bin/hlsd.js"
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@warren-bank/node-process-argv": "^1.2.1",
|
|
14
|
-
"@warren-bank/node-request": "^2.0.
|
|
14
|
+
"@warren-bank/node-request": "^2.0.12",
|
|
15
15
|
"@warren-bank/url": "^3.1.0",
|
|
16
|
+
"hpagent": "^1.2.0",
|
|
16
17
|
"tough-cookie": "^3.0.1"
|
|
17
18
|
},
|
|
18
19
|
"license": "GPL-2.0",
|