@@ -47,20 +47,22 @@ export class SftpSessionHandler {
47
47
flags : number ,
48
48
attrs : Attributes ,
49
49
) : void => {
50
- logger . verbose ( 'SFTP file open request (SSH_FXP_OPEN)' ) ;
51
- logger . debug ( 'Request:' , {
52
- reqId,
53
- filename,
54
- flags,
55
- attrs,
56
- } ) ;
50
+ logger . verbose (
51
+ 'Request: SFTP file open (SSH_FXP_OPEN)' ,
52
+ {
53
+ reqId,
54
+ filename,
55
+ flags,
56
+ attrs,
57
+ } ,
58
+ ) ;
57
59
const handle = generateHandle ( ) ;
58
60
logger . debug ( `Opening ${ filename } : ${ handle } ` ) ;
59
61
this . permanentFileSystem . loadFile ( filename )
60
62
. then ( ( file ) => {
61
63
logger . debug ( 'Contents:' , file ) ;
62
64
this . openFiles . set ( handle , file ) ;
63
- logger . debug ( 'Response:' , { reqId, handle } ) ;
65
+ logger . verbose ( 'Response: Handle ' , { reqId, handle } ) ;
64
66
this . sftpConnection . handle (
65
67
reqId ,
66
68
Buffer . from ( handle ) ,
@@ -69,7 +71,10 @@ export class SftpSessionHandler {
69
71
. catch ( ( reason : unknown ) => {
70
72
logger . warn ( 'Failed to load file' , { reqId, filename } ) ;
71
73
logger . warn ( reason ) ;
72
- logger . debug ( 'Response: Status (FAILURE)' , { reqId } , SFTP_STATUS_CODE . FAILURE ) ;
74
+ logger . verbose ( 'Response: Status (FAILURE)' , {
75
+ reqId,
76
+ code : SFTP_STATUS_CODE . FAILURE ,
77
+ } ) ;
73
78
this . sftpConnection . status ( reqId , SFTP_STATUS_CODE . FAILURE ) ;
74
79
} ) ;
75
80
} ;
@@ -86,23 +91,37 @@ export class SftpSessionHandler {
86
91
offset : number ,
87
92
length : number ,
88
93
) : void => {
89
- logger . verbose ( 'SFTP read file request (SSH_FXP_READ)' ) ;
90
- logger . debug ( 'Request:' , {
91
- reqId,
92
- handle,
93
- offset,
94
- length,
95
- } ) ;
94
+ logger . verbose (
95
+ 'Request: SFTP read file (SSH_FXP_READ)' ,
96
+ {
97
+ reqId,
98
+ handle,
99
+ offset,
100
+ length,
101
+ } ,
102
+ ) ;
96
103
const file = this . openFiles . get ( handle . toString ( ) ) ;
97
104
if ( ! file ) {
98
105
logger . info ( 'There is no open file associated with this handle' , { reqId, handle } ) ;
99
- logger . debug ( 'Response: Status (FAILURE)' , { reqId } , SFTP_STATUS_CODE . FAILURE ) ;
106
+ logger . verbose (
107
+ 'Response: Status (FAILURE)' ,
108
+ {
109
+ reqId,
110
+ code : SFTP_STATUS_CODE . FAILURE ,
111
+ } ,
112
+ ) ;
100
113
this . sftpConnection . status ( reqId , SFTP_STATUS_CODE . FAILURE ) ;
101
114
return ;
102
115
}
103
116
104
117
if ( offset >= file . size ) {
105
- logger . debug ( 'Response: Status (EOF)' , { reqId } , SFTP_STATUS_CODE . EOF ) ;
118
+ logger . verbose (
119
+ 'Response: Status (EOF)' ,
120
+ {
121
+ reqId,
122
+ code : SFTP_STATUS_CODE . EOF ,
123
+ } ,
124
+ ) ;
106
125
this . sftpConnection . status ( reqId , SFTP_STATUS_CODE . EOF ) ;
107
126
return ;
108
127
}
@@ -114,7 +133,8 @@ export class SftpSessionHandler {
114
133
} )
115
134
. then ( async ( response ) => {
116
135
const data = await response . buffer ( ) ;
117
- logger . debug ( 'Response: Data' , { reqId, data } ) ;
136
+ logger . verbose ( 'Response: Data' , { reqId } ) ;
137
+ logger . silly ( 'Sent data...' , { data } ) ;
118
138
this . sftpConnection . data (
119
139
reqId ,
120
140
data ,
@@ -128,7 +148,13 @@ export class SftpSessionHandler {
128
148
length,
129
149
} ) ;
130
150
logger . warn ( reason ) ;
131
- logger . debug ( 'Response: Status (FAILURE)' , { reqId } , SFTP_STATUS_CODE . FAILURE ) ;
151
+ logger . verbose (
152
+ 'Response: Status (FAILURE)' ,
153
+ {
154
+ reqId,
155
+ code : SFTP_STATUS_CODE . FAILURE ,
156
+ } ,
157
+ ) ;
132
158
this . sftpConnection . status ( reqId , SFTP_STATUS_CODE . FAILURE ) ;
133
159
} ) ;
134
160
} ;
@@ -141,7 +167,7 @@ export class SftpSessionHandler {
141
167
*/
142
168
// eslint-disable-next-line class-methods-use-this
143
169
public writeHandler = ( ) : void => {
144
- logger . verbose ( 'SFTP write file request (SSH_FXP_WRITE)' ) ;
170
+ logger . verbose ( 'Request: SFTP write file (SSH_FXP_WRITE)' ) ;
145
171
} ;
146
172
147
173
/**
@@ -154,8 +180,10 @@ export class SftpSessionHandler {
154
180
reqId : number ,
155
181
itemPath : Buffer ,
156
182
) : void => {
157
- logger . verbose ( 'SFTP read open file statistics request (SSH_FXP_FSTAT)' ) ;
158
- logger . debug ( 'Request:' , { reqId, itemPath } ) ;
183
+ logger . verbose (
184
+ 'Request: SFTP read open file statistics (SSH_FXP_FSTAT)' ,
185
+ { reqId, itemPath } ,
186
+ ) ;
159
187
this . genericStatHandler ( reqId , itemPath ) ;
160
188
} ;
161
189
@@ -167,7 +195,7 @@ export class SftpSessionHandler {
167
195
*/
168
196
// eslint-disable-next-line class-methods-use-this
169
197
public fsetStatHandler = ( ) : void => {
170
- logger . verbose ( 'SFTP write open file statistics request (SSH_FXP_FSETSTAT)' ) ;
198
+ logger . verbose ( 'Request: SFTP write open file statistics (SSH_FXP_FSETSTAT)' ) ;
171
199
} ;
172
200
173
201
/**
@@ -177,10 +205,18 @@ export class SftpSessionHandler {
177
205
* https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.3
178
206
*/
179
207
public closeHandler = ( reqId : number , handle : Buffer ) : void => {
180
- logger . verbose ( 'SFTP close file request (SSH_FXP_CLOSE)' ) ;
181
- logger . debug ( 'Request:' , { reqId, handle } ) ;
208
+ logger . verbose (
209
+ 'Request: SFTP close file (SSH_FXP_CLOSE)' ,
210
+ { reqId, handle } ,
211
+ ) ;
182
212
this . openFiles . delete ( handle . toString ( ) ) ;
183
- logger . debug ( 'Response: Status (OK)' , { reqId } , SFTP_STATUS_CODE . OK ) ;
213
+ logger . verbose (
214
+ 'Response: Status (OK)' ,
215
+ {
216
+ reqId,
217
+ code : SFTP_STATUS_CODE . OK ,
218
+ } ,
219
+ ) ;
184
220
this . sftpConnection . status ( reqId , SFTP_STATUS_CODE . OK ) ;
185
221
} ;
186
222
@@ -191,15 +227,17 @@ export class SftpSessionHandler {
191
227
* https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.7
192
228
*/
193
229
public openDirHandler = ( reqId : number , dirPath : string ) : void => {
194
- logger . verbose ( 'SFTP open directory request (SSH_FXP_OPENDIR)' ) ;
195
- logger . debug ( 'Request:' , { reqId, dirPath } ) ;
230
+ logger . verbose (
231
+ 'SFTP open directory request (SSH_FXP_OPENDIR)' ,
232
+ { reqId, dirPath } ,
233
+ ) ;
196
234
const handle = generateHandle ( ) ;
197
235
logger . debug ( `Opening ${ dirPath } :` , handle ) ;
198
236
this . permanentFileSystem . loadDirectory ( dirPath )
199
237
. then ( ( fileEntries ) => {
200
238
logger . debug ( 'Contents:' , fileEntries ) ;
201
239
this . openDirectories . set ( handle , fileEntries ) ;
202
- logger . debug ( 'Response:' , { reqId, handle } ) ;
240
+ logger . verbose ( 'Response: Handle ' , { reqId, handle } ) ;
203
241
this . sftpConnection . handle (
204
242
reqId ,
205
243
Buffer . from ( handle ) ,
@@ -208,7 +246,13 @@ export class SftpSessionHandler {
208
246
. catch ( ( reason : unknown ) => {
209
247
logger . warn ( 'Failed to load path' , { reqId, dirPath } ) ;
210
248
logger . warn ( reason ) ;
211
- logger . debug ( 'Response: Status (FAILURE)' , { reqId } , SFTP_STATUS_CODE . FAILURE ) ;
249
+ logger . verbose (
250
+ 'Response: Status (FAILURE)' ,
251
+ {
252
+ reqId,
253
+ code : SFTP_STATUS_CODE . FAILURE ,
254
+ } ,
255
+ ) ;
212
256
this . sftpConnection . status ( reqId , SFTP_STATUS_CODE . FAILURE ) ;
213
257
} ) ;
214
258
} ;
@@ -220,15 +264,23 @@ export class SftpSessionHandler {
220
264
* https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.7
221
265
*/
222
266
public readDirHandler = ( reqId : number , handle : Buffer ) : void => {
223
- logger . verbose ( 'SFTP read directory request (SSH_FXP_READDIR)' ) ;
267
+ logger . verbose (
268
+ 'Request: SFTP read directory (SSH_FXP_READDIR)' ,
269
+ { reqId, handle } ,
270
+ ) ;
224
271
const names = this . openDirectories . get ( handle . toString ( ) ) ?? [ ] ;
225
- logger . debug ( 'Request:' , { reqId, handle, names } ) ;
226
272
if ( names . length !== 0 ) {
227
- logger . debug ( 'Response:' , { reqId, names } ) ;
273
+ logger . verbose ( 'Response: Name ' , { reqId, names } ) ;
228
274
this . openDirectories . set ( handle . toString ( ) , [ ] ) ;
229
275
this . sftpConnection . name ( reqId , names ) ;
230
276
} else {
231
- logger . debug ( 'Response: Status (EOF)' , { reqId } , SFTP_STATUS_CODE . EOF ) ;
277
+ logger . verbose (
278
+ 'Response: Status (EOF)' ,
279
+ {
280
+ reqId,
281
+ code : SFTP_STATUS_CODE . EOF ,
282
+ } ,
283
+ ) ;
232
284
this . openDirectories . delete ( handle . toString ( ) ) ;
233
285
this . sftpConnection . status ( reqId , SFTP_STATUS_CODE . EOF ) ;
234
286
}
@@ -244,8 +296,10 @@ export class SftpSessionHandler {
244
296
reqId : number ,
245
297
itemPath : Buffer ,
246
298
) : void => {
247
- logger . verbose ( 'SFTP read file statistics without following symbolic links request (SSH_FXP_LSTAT)' ) ;
248
- logger . debug ( 'Request:' , { reqId, itemPath } ) ;
299
+ logger . verbose (
300
+ 'Request: SFTP read file statistics without following symbolic links (SSH_FXP_LSTAT)' ,
301
+ { reqId, itemPath } ,
302
+ ) ;
249
303
this . genericStatHandler ( reqId , itemPath ) ;
250
304
} ;
251
305
@@ -259,8 +313,10 @@ export class SftpSessionHandler {
259
313
reqId : number ,
260
314
itemPath : Buffer ,
261
315
) : void => {
262
- logger . verbose ( 'SFTP read file statistics following symbolic links request (SSH_FXP_STAT)' ) ;
263
- logger . debug ( 'Request:' , { reqId, itemPath } ) ;
316
+ logger . verbose (
317
+ 'Request: SFTP read file statistics following symbolic links (SSH_FXP_STAT)' ,
318
+ { reqId, itemPath } ,
319
+ ) ;
264
320
this . genericStatHandler ( reqId , itemPath ) ;
265
321
} ;
266
322
@@ -272,7 +328,7 @@ export class SftpSessionHandler {
272
328
*/
273
329
// eslint-disable-next-line class-methods-use-this
274
330
public removeHandler = ( ) : void => {
275
- logger . verbose ( 'SFTP remove file request (SSH_FXP_REMOVE)' ) ;
331
+ logger . verbose ( 'Request: SFTP remove file (SSH_FXP_REMOVE)' ) ;
276
332
} ;
277
333
278
334
/**
@@ -283,7 +339,7 @@ export class SftpSessionHandler {
283
339
*/
284
340
// eslint-disable-next-line class-methods-use-this
285
341
public rmDirHandler = ( ) : void => {
286
- logger . verbose ( 'SFTP remove directory request (SSH_FXP_RMDIR)' ) ;
342
+ logger . verbose ( 'Request: SFTP remove directory (SSH_FXP_RMDIR)' ) ;
287
343
} ;
288
344
289
345
/**
@@ -293,8 +349,10 @@ export class SftpSessionHandler {
293
349
* https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.11
294
350
*/
295
351
public realPathHandler = ( reqId : number , relativePath : string ) : void => {
296
- logger . verbose ( 'SFTP canonicalize path request (SSH_FXP_REALPATH)' ) ;
297
- logger . debug ( 'Request:' , { reqId, relativePath } ) ;
352
+ logger . verbose (
353
+ 'Request: SFTP canonicalize path (SSH_FXP_REALPATH)' ,
354
+ { reqId, relativePath } ,
355
+ ) ;
298
356
const resolvedPath = path . resolve ( '/' , relativePath ) ;
299
357
this . permanentFileSystem . getItemAttributes ( resolvedPath )
300
358
. then ( ( attrs ) => {
@@ -303,11 +361,20 @@ export class SftpSessionHandler {
303
361
attrs ,
304
362
) ;
305
363
const names = [ fileEntry ] ;
306
- logger . debug ( 'Response:' , { reqId, names } ) ;
364
+ logger . verbose (
365
+ 'Response: Name' ,
366
+ { reqId, names } ,
367
+ ) ;
307
368
this . sftpConnection . name ( reqId , names ) ;
308
369
} )
309
370
. catch ( ( ) => {
310
- logger . debug ( 'Response: Status (EOF)' , { reqId } , SFTP_STATUS_CODE . NO_SUCH_FILE ) ;
371
+ logger . verbose (
372
+ 'Response: Status (EOF)' ,
373
+ {
374
+ reqId,
375
+ code : SFTP_STATUS_CODE . NO_SUCH_FILE ,
376
+ } ,
377
+ ) ;
311
378
this . sftpConnection . status ( reqId , SFTP_STATUS_CODE . NO_SUCH_FILE ) ;
312
379
} ) ;
313
380
} ;
@@ -320,7 +387,7 @@ export class SftpSessionHandler {
320
387
*/
321
388
// eslint-disable-next-line class-methods-use-this
322
389
public readLinkHandler = ( ) : void => {
323
- logger . verbose ( 'SFTP read link request (SSH_FXP_READLINK)' ) ;
390
+ logger . verbose ( 'Request: SFTP read link (SSH_FXP_READLINK)' ) ;
324
391
} ;
325
392
326
393
/**
@@ -331,7 +398,7 @@ export class SftpSessionHandler {
331
398
*/
332
399
// eslint-disable-next-line class-methods-use-this
333
400
public setStatHandler = ( ) : void => {
334
- logger . verbose ( 'SFTP set file attributes request (SSH_FXP_SETSTAT)' ) ;
401
+ logger . verbose ( 'Request: SFTP set file attributes (SSH_FXP_SETSTAT)' ) ;
335
402
} ;
336
403
337
404
/**
@@ -342,7 +409,7 @@ export class SftpSessionHandler {
342
409
*/
343
410
// eslint-disable-next-line class-methods-use-this
344
411
public mkDirHandler = ( ) : void => {
345
- logger . verbose ( 'SFTP create directory request (SSH_FXP_MKDIR)' ) ;
412
+ logger . verbose ( 'Request: SFTP create directory (SSH_FXP_MKDIR)' ) ;
346
413
} ;
347
414
348
415
/**
@@ -353,7 +420,7 @@ export class SftpSessionHandler {
353
420
*/
354
421
// eslint-disable-next-line class-methods-use-this
355
422
public renameHandler = ( ) : void => {
356
- logger . verbose ( 'SFTP file rename request (SSH_FXP_RENAME)' ) ;
423
+ logger . verbose ( 'Request: SFTP file rename (SSH_FXP_RENAME)' ) ;
357
424
} ;
358
425
359
426
/**
@@ -364,20 +431,29 @@ export class SftpSessionHandler {
364
431
*/
365
432
// eslint-disable-next-line class-methods-use-this
366
433
public symLinkHandler = ( ) : void => {
367
- logger . verbose ( 'SFTP create symlink request (SSH_FXP_SYMLINK)' ) ;
434
+ logger . verbose ( 'Request: SFTP create symlink (SSH_FXP_SYMLINK)' ) ;
368
435
} ;
369
436
370
437
private readonly genericStatHandler = ( reqId : number , itemPath : Buffer ) : void => {
371
438
this . permanentFileSystem . getItemAttributes ( itemPath . toString ( ) )
372
439
. then ( ( attrs ) => {
373
- logger . debug ( 'Response:' , { reqId, attrs } ) ;
440
+ logger . verbose (
441
+ 'Response: Attrs' ,
442
+ { reqId, attrs } ,
443
+ ) ;
374
444
this . sftpConnection . attrs (
375
445
reqId ,
376
446
attrs ,
377
447
) ;
378
448
} )
379
449
. catch ( ( ) => {
380
- logger . debug ( 'Response: Status (NO_SUCH_FILE)' , { reqId } , SFTP_STATUS_CODE . NO_SUCH_FILE ) ;
450
+ logger . verbose (
451
+ 'Response: Status (NO_SUCH_FILE)' ,
452
+ {
453
+ reqId,
454
+ code : SFTP_STATUS_CODE . NO_SUCH_FILE ,
455
+ } ,
456
+ ) ;
381
457
this . sftpConnection . status ( reqId , SFTP_STATUS_CODE . NO_SUCH_FILE ) ;
382
458
} ) ;
383
459
} ;
0 commit comments