@@ -317,7 +317,8 @@ - (void)launchTask:(id) dummy
317
317
318
318
// Prepare to set up the arguments for the task
319
319
taskArguments = [[NSMutableArray alloc ] init ];
320
-
320
+ #define TA (_name,_value ) [taskArguments addObjectsFromArray: @[_name,_value]]
321
+
321
322
// Enable verbose mode for message parsing
322
323
[taskArguments addObject: @" -v" ];
323
324
@@ -329,58 +330,58 @@ - (void)launchTask:(id) dummy
329
330
if (connectionMuxingEnabled) {
330
331
331
332
// Enable automatic connection muxing/sharing, for faster connections
332
- [taskArguments addObject: @" -o ControlMaster=auto" ] ;
333
+ TA ( @" -o" , @" ControlMaster=auto" ) ;
333
334
334
335
// Set a custom control path to isolate connection sharing to Sequel Pro, to prevent picking up
335
336
// existing masters without forwarding enabled and to isolate from interactive sessions. Use a short
336
337
// hashed path to aid length limit issues.
337
338
unsigned char hashedPathResult[16 ];
338
339
NSString *pathString = [NSString stringWithFormat: @" %@ @%@ :%ld " , sshLogin?sshLogin: @" " , sshHost, (long )(sshPort?sshPort: 0 )];
339
340
CC_MD5 ([pathString UTF8String ], (unsigned int )strlen ([pathString UTF8String ]), hashedPathResult);
340
- [taskArguments addObject: [NSString stringWithFormat: @" -o ControlPath=%@ /SPSSH-%@ " , [NSFileManager temporaryDirectory ], [[[NSData dataWithBytes: hashedPathResult length: 16 ] dataToHexString ] substringToIndex: 8 ]]];
341
+ NSString *hashedString = [[[NSData dataWithBytes: hashedPathResult length: 16 ] dataToHexString ] substringToIndex: 8 ];
342
+ TA (@" -o" ,([NSString stringWithFormat: @" ControlPath=%@ /SPSSH-%@ " , [NSFileManager temporaryDirectory ], hashedString]));
341
343
} else {
342
344
343
345
// Disable muxing if requested
344
- [taskArguments addObject: @" -S none" ] ;
345
- [taskArguments addObject: @" -o ControlMaster=no" ] ;
346
+ TA ( @" -S" , @" none" ) ;
347
+ TA ( @" -o" , @" ControlMaster=no" ) ;
346
348
}
347
349
348
350
// If the port forwarding fails, exit - as this is the primary use case for the instance
349
- [taskArguments addObject: @" -o ExitOnForwardFailure=yes" ] ;
351
+ TA ( @" -o" , @" ExitOnForwardFailure=yes" ) ;
350
352
351
353
// Specify a connection timeout based on the preferences value
352
- [taskArguments addObject: [ NSString stringWithFormat: @" -o ConnectTimeout=%ld " , (long )connectionTimeout]] ;
354
+ TA ( @" -o " ,([ NSString stringWithFormat: @" ConnectTimeout=%ld " , (long )connectionTimeout])) ;
353
355
354
356
// Allow three password prompts
355
- [taskArguments addObject: @" -o NumberOfPasswordPrompts=3" ] ;
357
+ TA ( @" -o" , @" NumberOfPasswordPrompts=3" ) ;
356
358
357
359
// Specify an identity file if available
358
360
if (identityFilePath) {
359
- [taskArguments addObject: @" -i" ];
360
- [taskArguments addObject: identityFilePath];
361
+ TA (@" -i" , identityFilePath);
361
362
}
362
363
363
364
// If keepalive is set in the preferences, use the same value for the SSH tunnel
364
365
if (useKeepAlive && keepAliveInterval) {
365
- [taskArguments addObject: @" -o TCPKeepAlive=no" ];
366
- [taskArguments addObject: [NSString stringWithFormat: @" -o ServerAliveInterval=%ld " , (long )ceil (keepAliveInterval)]];
367
- [taskArguments addObject: @" -o ServerAliveCountMax=1" ];
366
+ TA ( @" -o" , @" TCPKeepAlive=no" );
367
+ TA ( @" -o " , ( [NSString stringWithFormat: @" ServerAliveInterval=%ld " , (long )ceil (keepAliveInterval)]));
368
+ TA ( @" -o" , @" ServerAliveCountMax=1" );
368
369
}
369
370
370
371
// Specify the port, host, and authentication details
371
372
if (sshPort) {
372
- [taskArguments addObject: [NSString stringWithFormat: @" -p %ld " , (long )sshPort]] ;
373
+ TA ( @" -p " , ( [NSString stringWithFormat: @" %ld " , (long )sshPort])) ;
373
374
}
374
375
if ([sshLogin length ]) {
375
376
[taskArguments addObject: [NSString stringWithFormat: @" %@ @%@ " , sshLogin, sshHost]];
376
377
} else {
377
378
[taskArguments addObject: sshHost];
378
379
}
379
380
if (useHostFallback) {
380
- [taskArguments addObject: [ NSString stringWithFormat: @" -L %ld :127.0.0.1:%ld " , (long )localPort, (long )remotePort]] ;
381
- [taskArguments addObject: [ NSString stringWithFormat: @" -L %ld :%@ :%ld " , (long )localPortFallback, remoteHost, (long )remotePort]] ;
381
+ TA ( @" -L " ,([ NSString stringWithFormat: @" %ld :127.0.0.1:%ld " , (long )localPort, (long )remotePort])) ;
382
+ TA ( @" -L " ,([ NSString stringWithFormat: @" %ld :%@ :%ld " , (long )localPortFallback, remoteHost, (long )remotePort])) ;
382
383
} else {
383
- [taskArguments addObject: [NSString stringWithFormat: @" -L %ld :%@ :%ld " , (long )localPort, remoteHost, (long )remotePort]] ;
384
+ TA ( @" -L " , ( [NSString stringWithFormat: @" %ld :%@ :%ld " , (long )localPort, remoteHost, (long )remotePort])) ;
384
385
}
385
386
386
387
[task setArguments: taskArguments];
@@ -451,6 +452,7 @@ - (void)launchTask:(id) dummy
451
452
[[NSRunLoop currentRunLoop ] runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0 ]];
452
453
453
454
SPClear (taskEnvironment);
455
+ #undef TA
454
456
SPClear (taskArguments);
455
457
456
458
[pool release ];
0 commit comments