@@ -11,13 +11,15 @@ const argv = mri(process.argv.slice(2), {
11
11
if ( argv . help || argv . h ) {
12
12
process . stdout . write ( `
13
13
Usage:
14
- tcp-over-websockets <tunnel-url> <tunnelled-target> <port-to-listen-on>
14
+ tcp-over-websockets <tunnel-url> <tunnelled-target> <port-to-listen-on> [<http-header-for-tunnel>]
15
15
Arguments:
16
- tunnel-url The WebSocket address of the tunnel server.
17
- tunnelled-target The hostname & port to let the tunnel server connect to.
18
- port-to-listen-on The (local) port to expose the tunnel on.
16
+ tunnel-url The WebSocket address of the tunnel server.
17
+ tunnelled-target The hostname & port to let the tunnel server connect to.
18
+ port-to-listen-on The (local) port to expose the tunnel on.
19
+ http-header-for-tunnel The HTTP header for tunnerl websocket request, JSON format.
19
20
Example:
20
21
tcp-over-websockets wss://example.org localhost:22 8022
22
+ tcp-over-websockets wss://example.org localhost:22 8022 '{ "Cookie" : "anything" }'
21
23
\n` )
22
24
process . exit ( 0 )
23
25
}
@@ -40,7 +42,13 @@ if (!target) showError('missing target argument')
40
42
const port = argv . _ [ 2 ]
41
43
if ( ! port ) showError ( 'missing port argument' )
42
44
43
- startClient ( tunnel , target , port , ( err ) => {
45
+ const header_str = argv . _ [ 3 ]
46
+ let headers = undefined
47
+ if ( header_str ) {
48
+ headers = JSON . parse ( header_str )
49
+ }
50
+
51
+ startClient ( tunnel , target , port , headers , ( err ) => {
44
52
if ( err ) showError ( err )
45
53
else console . info ( `tunneling ${ target } via ${ tunnel } & exposing it on port ${ port } ` )
46
54
} )
0 commit comments