bdy 1.23.6-dev → 1.23.7-dev

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.
Files changed (205) hide show
  1. package/distTs/package.json +10 -2
  2. package/distTs/src/agent/linux.js +53 -3
  3. package/distTs/src/agent/manager.js +3 -6
  4. package/distTs/src/agent/osx.js +51 -3
  5. package/distTs/src/agent/system.js +400 -21
  6. package/distTs/src/agent/windows.js +4 -7
  7. package/distTs/src/command/agent/debug.js +2 -2
  8. package/distTs/src/command/agent/install.js +37 -10
  9. package/distTs/src/command/agent/restart.js +2 -2
  10. package/distTs/src/command/agent/run.js +3 -0
  11. package/distTs/src/command/agent/start.js +2 -2
  12. package/distTs/src/command/agent/status.js +19 -0
  13. package/distTs/src/command/agent/stop.js +2 -2
  14. package/distTs/src/command/agent/uninstall.js +5 -8
  15. package/distTs/src/command/agent/update.js +2 -2
  16. package/distTs/src/command/artifact/publish.js +3 -1
  17. package/distTs/src/command/version.js +13 -5
  18. package/distTs/src/logger.js +40 -4
  19. package/distTs/src/texts.js +35 -19
  20. package/distTs/src/utils.js +98 -3
  21. package/node_modules/asn1/Jenkinsfile +65 -0
  22. package/node_modules/asn1/LICENSE +19 -0
  23. package/node_modules/asn1/README.md +50 -0
  24. package/node_modules/asn1/lib/ber/errors.js +13 -0
  25. package/node_modules/asn1/lib/ber/index.js +27 -0
  26. package/node_modules/asn1/lib/ber/reader.js +262 -0
  27. package/node_modules/asn1/lib/ber/types.js +36 -0
  28. package/node_modules/asn1/lib/ber/writer.js +317 -0
  29. package/node_modules/asn1/lib/index.js +20 -0
  30. package/node_modules/asn1/package.json +31 -0
  31. package/node_modules/bcrypt-pbkdf/CONTRIBUTING.md +13 -0
  32. package/node_modules/bcrypt-pbkdf/LICENSE +66 -0
  33. package/node_modules/bcrypt-pbkdf/README.md +45 -0
  34. package/node_modules/bcrypt-pbkdf/index.js +556 -0
  35. package/node_modules/bcrypt-pbkdf/package.json +15 -0
  36. package/node_modules/safer-buffer/LICENSE +21 -0
  37. package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  38. package/node_modules/safer-buffer/Readme.md +156 -0
  39. package/node_modules/safer-buffer/dangerous.js +58 -0
  40. package/node_modules/safer-buffer/package.json +34 -0
  41. package/node_modules/safer-buffer/safer.js +77 -0
  42. package/node_modules/safer-buffer/tests.js +406 -0
  43. package/node_modules/ssh2/.eslintignore +4 -0
  44. package/node_modules/ssh2/.eslintrc.js +5 -0
  45. package/node_modules/ssh2/.github/workflows/ci.yml +110 -0
  46. package/node_modules/ssh2/.github/workflows/lint.yml +27 -0
  47. package/node_modules/ssh2/LICENSE +19 -0
  48. package/node_modules/ssh2/README.md +1529 -0
  49. package/node_modules/ssh2/SFTP.md +413 -0
  50. package/node_modules/ssh2/examples/server-chat.js +238 -0
  51. package/node_modules/ssh2/examples/sftp-server-download-only.js +134 -0
  52. package/node_modules/ssh2/install.js +27 -0
  53. package/node_modules/ssh2/lib/Channel.js +295 -0
  54. package/node_modules/ssh2/lib/agent.js +1123 -0
  55. package/node_modules/ssh2/lib/client.js +2176 -0
  56. package/node_modules/ssh2/lib/http-agents.js +84 -0
  57. package/node_modules/ssh2/lib/index.js +44 -0
  58. package/node_modules/ssh2/lib/keygen.js +582 -0
  59. package/node_modules/ssh2/lib/protocol/Protocol.js +2136 -0
  60. package/node_modules/ssh2/lib/protocol/SFTP.js +4052 -0
  61. package/node_modules/ssh2/lib/protocol/constants.js +356 -0
  62. package/node_modules/ssh2/lib/protocol/crypto/binding.gyp +23 -0
  63. package/node_modules/ssh2/lib/protocol/crypto/poly1305.js +43 -0
  64. package/node_modules/ssh2/lib/protocol/crypto/src/binding.cc +2300 -0
  65. package/node_modules/ssh2/lib/protocol/crypto.js +1602 -0
  66. package/node_modules/ssh2/lib/protocol/handlers.js +16 -0
  67. package/node_modules/ssh2/lib/protocol/handlers.misc.js +1285 -0
  68. package/node_modules/ssh2/lib/protocol/kex.js +1908 -0
  69. package/node_modules/ssh2/lib/protocol/keyParser.js +1484 -0
  70. package/node_modules/ssh2/lib/protocol/node-fs-compat.js +115 -0
  71. package/node_modules/ssh2/lib/protocol/utils.js +356 -0
  72. package/node_modules/ssh2/lib/protocol/zlib.js +255 -0
  73. package/node_modules/ssh2/lib/server.js +1380 -0
  74. package/node_modules/ssh2/lib/utils.js +336 -0
  75. package/node_modules/ssh2/package.json +49 -0
  76. package/node_modules/ssh2/test/common.js +316 -0
  77. package/node_modules/ssh2/test/fixtures/bad_rsa_private_key +26 -0
  78. package/node_modules/ssh2/test/fixtures/https_cert.pem +33 -0
  79. package/node_modules/ssh2/test/fixtures/https_key.pem +52 -0
  80. package/node_modules/ssh2/test/fixtures/id_dsa +12 -0
  81. package/node_modules/ssh2/test/fixtures/id_ecdsa +5 -0
  82. package/node_modules/ssh2/test/fixtures/id_rsa +15 -0
  83. package/node_modules/ssh2/test/fixtures/id_rsa.ppk +26 -0
  84. package/node_modules/ssh2/test/fixtures/id_rsa_enc +30 -0
  85. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa +21 -0
  86. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.pub +1 -0
  87. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.pub.result +7 -0
  88. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.result +7 -0
  89. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc +22 -0
  90. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.pub +1 -0
  91. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.pub.result +7 -0
  92. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.result +7 -0
  93. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm +23 -0
  94. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.pub +1 -0
  95. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.pub.result +7 -0
  96. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.result +7 -0
  97. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa +9 -0
  98. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.pub +1 -0
  99. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.pub.result +7 -0
  100. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.result +7 -0
  101. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc +10 -0
  102. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.pub +1 -0
  103. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.pub.result +8 -0
  104. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.result +7 -0
  105. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm +10 -0
  106. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.pub +1 -0
  107. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.pub.result +8 -0
  108. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.result +7 -0
  109. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519 +7 -0
  110. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.pub +1 -0
  111. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.pub.result +7 -0
  112. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.result +7 -0
  113. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa +27 -0
  114. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.pub +1 -0
  115. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.pub.result +7 -0
  116. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.result +7 -0
  117. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc +28 -0
  118. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.pub +1 -0
  119. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.pub.result +8 -0
  120. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.result +7 -0
  121. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm +29 -0
  122. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.pub +1 -0
  123. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.pub.result +8 -0
  124. package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.result +7 -0
  125. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa +12 -0
  126. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.pub +1 -0
  127. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.pub.result +7 -0
  128. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.result +7 -0
  129. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc +15 -0
  130. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.pub +1 -0
  131. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.pub.result +8 -0
  132. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.result +7 -0
  133. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa +5 -0
  134. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.pub +1 -0
  135. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.pub.result +7 -0
  136. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.result +7 -0
  137. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc +8 -0
  138. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.pub +1 -0
  139. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.pub.result +8 -0
  140. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.result +7 -0
  141. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa +27 -0
  142. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.pub +1 -0
  143. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.pub.result +7 -0
  144. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.result +7 -0
  145. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc +30 -0
  146. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.pub +1 -0
  147. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.pub.result +8 -0
  148. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.result +7 -0
  149. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256 +54 -0
  150. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.pub +1 -0
  151. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.pub.result +6 -0
  152. package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.result +6 -0
  153. package/node_modules/ssh2/test/fixtures/keyParser/ppk_dsa_enc +17 -0
  154. package/node_modules/ssh2/test/fixtures/keyParser/ppk_dsa_enc.result +7 -0
  155. package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa +26 -0
  156. package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa.result +7 -0
  157. package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa_enc +18 -0
  158. package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa_enc.result +7 -0
  159. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa.pub +9 -0
  160. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa.pub.result +7 -0
  161. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa2.pub +10 -0
  162. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa2.pub.result +7 -0
  163. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa3.pub +11 -0
  164. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa3.pub.result +7 -0
  165. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa4.pub +11 -0
  166. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa4.pub.result +7 -0
  167. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa5.pub +8 -0
  168. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa5.pub.result +7 -0
  169. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa6.pub +13 -0
  170. package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa6.pub.result +7 -0
  171. package/node_modules/ssh2/test/fixtures/openssh_new_rsa +27 -0
  172. package/node_modules/ssh2/test/fixtures/ssh_host_dsa_key +12 -0
  173. package/node_modules/ssh2/test/fixtures/ssh_host_ecdsa_key +5 -0
  174. package/node_modules/ssh2/test/fixtures/ssh_host_rsa_key +15 -0
  175. package/node_modules/ssh2/test/test-exec.js +578 -0
  176. package/node_modules/ssh2/test/test-integration-openssh.js +486 -0
  177. package/node_modules/ssh2/test/test-keygen.js +60 -0
  178. package/node_modules/ssh2/test/test-misc-client-server.js +1460 -0
  179. package/node_modules/ssh2/test/test-openssh.js +261 -0
  180. package/node_modules/ssh2/test/test-protocol-crypto.js +631 -0
  181. package/node_modules/ssh2/test/test-protocol-keyparser.js +177 -0
  182. package/node_modules/ssh2/test/test-server-hostkeys.js +138 -0
  183. package/node_modules/ssh2/test/test-sftp.js +842 -0
  184. package/node_modules/ssh2/test/test-shell.js +109 -0
  185. package/node_modules/ssh2/test/test-userauth-agent-openssh.js +110 -0
  186. package/node_modules/ssh2/test/test-userauth-agent.js +171 -0
  187. package/node_modules/ssh2/test/test-userauth.js +611 -0
  188. package/node_modules/ssh2/test/test-worker-imports.js +25 -0
  189. package/node_modules/ssh2/test/test.js +20 -0
  190. package/node_modules/ssh2/util/build_pagent.bat +2 -0
  191. package/node_modules/ssh2/util/pagent.c +88 -0
  192. package/node_modules/ssh2/util/pagent.exe +0 -0
  193. package/node_modules/tweetnacl/.npmignore +4 -0
  194. package/node_modules/tweetnacl/AUTHORS.md +28 -0
  195. package/node_modules/tweetnacl/CHANGELOG.md +221 -0
  196. package/node_modules/tweetnacl/LICENSE +24 -0
  197. package/node_modules/tweetnacl/PULL_REQUEST_TEMPLATE.md +20 -0
  198. package/node_modules/tweetnacl/README.md +459 -0
  199. package/node_modules/tweetnacl/nacl-fast.js +2388 -0
  200. package/node_modules/tweetnacl/nacl-fast.min.js +2 -0
  201. package/node_modules/tweetnacl/nacl.d.ts +98 -0
  202. package/node_modules/tweetnacl/nacl.js +1175 -0
  203. package/node_modules/tweetnacl/nacl.min.js +1 -0
  204. package/node_modules/tweetnacl/package.json +58 -0
  205. package/package.json +10 -2
@@ -0,0 +1,261 @@
1
+ 'use strict';
2
+
3
+ const assert = require('assert');
4
+ const { inspect } = require('util');
5
+
6
+ const {
7
+ fixture,
8
+ mustCall,
9
+ mustCallAtLeast,
10
+ setup: setup_,
11
+ } = require('./common.js');
12
+
13
+ const debug = false;
14
+
15
+ const clientCfg = { username: 'foo', password: 'bar' };
16
+ const serverCfg = { hostKeys: [ fixture('ssh_host_rsa_key') ] };
17
+
18
+ {
19
+ const { client, server } = setup_(
20
+ 'Exec with OpenSSH agent forwarding',
21
+ {
22
+ client: {
23
+ ...clientCfg,
24
+ agent: '/path/to/agent',
25
+ },
26
+ server: serverCfg,
27
+
28
+ debug,
29
+ },
30
+ );
31
+
32
+ server.on('connection', mustCall((conn) => {
33
+ conn.on('authentication', mustCall((ctx) => {
34
+ ctx.accept();
35
+ })).on('ready', mustCall(() => {
36
+ conn.on('session', mustCall((accept, reject) => {
37
+ let sawAuthAgent = false;
38
+ accept().on('auth-agent', mustCall((accept, reject) => {
39
+ sawAuthAgent = true;
40
+ accept && accept();
41
+ })).on('exec', mustCall((accept, reject, info) => {
42
+ assert(sawAuthAgent, 'Expected auth-agent before exec');
43
+ assert(info.command === 'foo --bar',
44
+ `Wrong exec command: ${info.command}`);
45
+ const stream = accept();
46
+ stream.exit(100);
47
+ stream.end();
48
+ conn.end();
49
+ }));
50
+ }));
51
+ }));
52
+ }));
53
+
54
+ client.on('ready', mustCall(() => {
55
+ client.exec('foo --bar', { agentForward: true }, mustCall((err, stream) => {
56
+ assert(!err, `Unexpected exec error: ${err}`);
57
+ stream.resume();
58
+ }));
59
+ }));
60
+ }
61
+
62
+ {
63
+ const { client, server } = setup_(
64
+ 'OpenSSH forwarded UNIX socket connection',
65
+ {
66
+ client: clientCfg,
67
+ server: {
68
+ ...serverCfg,
69
+ ident: 'OpenSSH_7.1',
70
+ },
71
+
72
+ debug,
73
+ },
74
+ );
75
+
76
+ const socketPath = '/foo';
77
+ const events = [];
78
+ const expected = [
79
+ ['client', 'openssh_forwardInStreamLocal'],
80
+ ['server', 'streamlocal-forward@openssh.com', { socketPath }],
81
+ ['client', 'forward callback'],
82
+ ['client', 'unix connection', { socketPath }],
83
+ ['client', 'socket data', '1'],
84
+ ['server', 'socket data', '2'],
85
+ ['client', 'socket end'],
86
+ ['server', 'cancel-streamlocal-forward@openssh.com', { socketPath }],
87
+ ['client', 'cancel callback']
88
+ ];
89
+
90
+ server.on('connection', mustCall((conn) => {
91
+ conn.on('authentication', mustCall((ctx) => {
92
+ ctx.accept();
93
+ })).on('ready', mustCall(() => {
94
+ conn.once('request', mustCall((accept, reject, name, info) => {
95
+ events.push(['server', name, info]);
96
+ assert(name === 'streamlocal-forward@openssh.com',
97
+ `Wrong request name: ${name}`);
98
+ accept();
99
+ conn.openssh_forwardOutStreamLocal(socketPath,
100
+ mustCall((err, ch) => {
101
+ assert(!err, `Unexpected error: ${err}`);
102
+ ch.write('1');
103
+ ch.on('data', mustCallAtLeast((data) => {
104
+ events.push(['server', 'socket data', data.toString()]);
105
+ ch.close();
106
+ }));
107
+ }));
108
+
109
+ conn.on('request', mustCall((accept, reject, name, info) => {
110
+ events.push(['server', name, info]);
111
+ assert(name === 'cancel-streamlocal-forward@openssh.com',
112
+ `Wrong request name: ${name}`);
113
+ accept();
114
+ }));
115
+ }));
116
+ }));
117
+ }));
118
+
119
+ client.on('ready', mustCall(() => {
120
+ // request forwarding
121
+ events.push(['client', 'openssh_forwardInStreamLocal']);
122
+ client.openssh_forwardInStreamLocal(socketPath, mustCall((err) => {
123
+ assert(!err, `Unexpected error: ${err}`);
124
+ events.push(['client', 'forward callback']);
125
+ }));
126
+ client.on('unix connection', mustCall((info, accept, reject) => {
127
+ events.push(['client', 'unix connection', info]);
128
+ const stream = accept();
129
+ stream.on('data', mustCallAtLeast((data) => {
130
+ events.push(['client', 'socket data', data.toString()]);
131
+ stream.write('2');
132
+ })).on('end', mustCall(() => {
133
+ events.push(['client', 'socket end']);
134
+ client.openssh_unforwardInStreamLocal(socketPath,
135
+ mustCall((err) => {
136
+ assert(!err, `Unexpected error: ${err}`);
137
+ events.push(['client', 'cancel callback']);
138
+ client.end();
139
+ }));
140
+ }));
141
+ }));
142
+ })).on('close', mustCall(() => {
143
+ assert.deepStrictEqual(
144
+ events,
145
+ expected,
146
+ 'Events mismatch\n'
147
+ + `Actual:\n${inspect(events)}\n`
148
+ + `Expected:\n${inspect(expected)}`
149
+ );
150
+ }));
151
+ }
152
+
153
+ {
154
+ const { client, server } = setup_(
155
+ 'OpenSSH UNIX socket connection',
156
+ {
157
+ client: clientCfg,
158
+ server: {
159
+ ...serverCfg,
160
+ ident: 'OpenSSH_8.0',
161
+ },
162
+
163
+ debug,
164
+ },
165
+ );
166
+
167
+ const socketPath = '/foo/bar/baz';
168
+ const response = 'Hello World';
169
+
170
+ server.on('connection', mustCall((conn) => {
171
+ conn.on('authentication', mustCall((ctx) => {
172
+ ctx.accept();
173
+ })).on('ready', mustCall(() => {
174
+ conn.on('openssh.streamlocal', mustCall((accept, reject, info) => {
175
+ assert.deepStrictEqual(
176
+ info,
177
+ { socketPath },
178
+ `Wrong info: ${inspect(info)}`
179
+ );
180
+
181
+ const stream = accept();
182
+ stream.on('close', mustCall(() => {
183
+ client.end();
184
+ })).end(response);
185
+ stream.resume();
186
+ }));
187
+ }));
188
+ }));
189
+
190
+ client.on('ready', mustCall(() => {
191
+ client.openssh_forwardOutStreamLocal(socketPath, mustCall((err, stream) => {
192
+ assert(!err, `Unexpected error: ${err}`);
193
+ let buf = '';
194
+ stream.on('data', mustCallAtLeast((data) => {
195
+ buf += data;
196
+ })).on('close', mustCall(() => {
197
+ assert(buf === response, `Wrong response: ${inspect(buf)}`);
198
+ }));
199
+ }));
200
+ }));
201
+ }
202
+
203
+ {
204
+ const { client, server } = setup_(
205
+ 'OpenSSH 5.x workaround for binding on port 0',
206
+ {
207
+ client: clientCfg,
208
+ server: {
209
+ ...serverCfg,
210
+ ident: 'OpenSSH_5.3',
211
+ },
212
+
213
+ debug,
214
+ },
215
+ );
216
+
217
+ const boundAddr = 'good';
218
+ const boundPort = 1337;
219
+ const tcpInfo = {
220
+ destIP: boundAddr,
221
+ destPort: boundPort,
222
+ srcIP: 'remote',
223
+ srcPort: 12345,
224
+ };
225
+
226
+ server.on('connection', mustCall((conn) => {
227
+ conn.on('authentication', mustCall((ctx) => {
228
+ ctx.accept();
229
+ })).on('ready', mustCall(() => {
230
+ conn.on('request', mustCall((accept, reject, name, info) => {
231
+ assert(name === 'tcpip-forward', `Unexpected request: ${name}`);
232
+ assert(info.bindAddr === boundAddr, `Wrong addr: ${info.bindAddr}`);
233
+ assert(info.bindPort === 0, `Wrong port: ${info.bindPort}`);
234
+ accept(boundPort);
235
+ conn.forwardOut(boundAddr,
236
+ 0,
237
+ tcpInfo.srcIP,
238
+ tcpInfo.srcPort,
239
+ mustCall((err, ch) => {
240
+ assert(!err, `Unexpected error: ${err}`);
241
+ client.end();
242
+ }));
243
+ }));
244
+ }));
245
+ }));
246
+
247
+ client.on('ready', mustCall(() => {
248
+ // request forwarding
249
+ client.forwardIn(boundAddr, 0, mustCall((err, port) => {
250
+ assert(!err, `Unexpected error: ${err}`);
251
+ assert(port === boundPort, `Bad bound port: ${port}`);
252
+ }));
253
+ })).on('tcp connection', mustCall((details, accept, reject) => {
254
+ assert.deepStrictEqual(
255
+ details,
256
+ tcpInfo,
257
+ `Wrong tcp details: ${inspect(details)}`
258
+ );
259
+ accept();
260
+ }));
261
+ }