Guest User

Untitled

a guest
Jun 6th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1.  
  2. // ................... Crashes ......................
  3.  
  4. - (void)startSSH:(id)nothing;
  5. {
  6. NSAutoreleasePool * pool = [NSAutoreleasePool new];
  7.  
  8.  
  9. mTunnel = [[SSHTunnelManager sharedInstance] tunnelWithSSHHost:[sshHost stringValue] sshUser:[sshUser stringValue] sshPassword:[sshPassword stringValue]
  10. localPort:[localPort intValue] remotePort:[remotePort intValue]];
  11.  
  12.  
  13. @synchronized(self) {
  14.  
  15. if (![mTunnel isConnected]) {
  16.  
  17. NSString * error = nil;
  18. if (![mTunnel start:&error]) {
  19. //NSRunAlertPanel(@"SHH tunnel could not connect.", error, @"OK", nil, nil);
  20. NSLog(@"SHH tunnel could not connect. %@", error);
  21. mTunnel = nil;
  22. } else {
  23. NSLog(@"SHH tunnel is connected.");
  24. }
  25. }
  26.  
  27. }
  28.  
  29. NSLog(@"releasing pool from thread %@", [NSThread currentThread]);
  30. [pool release];
  31. }
  32.  
  33.  
  34.  
  35.  
  36. // ................... Works ......................
  37.  
  38. - (void)startSSH:(id)nothing;
  39. {
  40. NSAutoreleasePool * pool = [NSAutoreleasePool new];
  41.  
  42.  
  43. @synchronized(self) {
  44.  
  45. mTunnel = [[SSHTunnelManager sharedInstance] tunnelWithSSHHost:[sshHost stringValue] sshUser:[sshUser stringValue] sshPassword:[sshPassword stringValue]
  46. localPort:[localPort intValue] remotePort:[remotePort intValue]];
  47.  
  48.  
  49. if (![mTunnel isConnected]) {
  50.  
  51. NSString * error = nil;
  52. if (![mTunnel start:&error]) {
  53. //NSRunAlertPanel(@"SHH tunnel could not connect.", error, @"OK", nil, nil);
  54. NSLog(@"SHH tunnel could not connect. %@", error);
  55. mTunnel = nil;
  56. } else {
  57. NSLog(@"SHH tunnel is connected.");
  58. }
  59. }
  60.  
  61. }
  62.  
  63. NSLog(@"releasing pool from thread %@", [NSThread currentThread]);
  64. [pool release];
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. - (SSHTunnel *)tunnelWithSSHHost:(NSString *)sshHost sshUser:(NSString *)sshUser sshPassword:(NSString *)sshPassword
  75. localPort:(uint16_t)localPort remotePort:(uint16_t)remotePort;
  76. {
  77. SSHTunnel * tunnel = nil;
  78.  
  79. @synchronized(self) {
  80.  
  81. if ([mSSHTunnels count] > 0) {
  82. tunnel = [mSSHTunnels objectAtIndex:0];
  83. }
  84.  
  85.  
  86. if (!tunnel) {
  87. NSLog(@"Creating tunnel on thread %@", [NSThread currentThread]);
  88.  
  89. tunnel = [[SSHTunnel alloc] initWithSSHHost:sshHost sshUser:sshUser sshPassword:sshPassword localPort:localPort remotePort:remotePort];
  90. [mSSHTunnels addObject:tunnel];
  91. [tunnel autorelease];
  92. }
  93. }
  94.  
  95. return tunnel;
  96. }
Add Comment
Please, Sign In to add comment