Mercurial > 510Connectbot
comparison src/ch/ethz/ssh2/transport/TransportManager.java @ 319:776a220dbcc6 ganymed
add ecdsa key support everywhere
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 31 Jul 2014 08:20:47 -0700 |
parents | 071eccdff8ea |
children | 5afb8c1a54b9 |
comparison
equal
deleted
inserted
replaced
318:5351641c8a46 | 319:776a220dbcc6 |
---|---|
160 | 160 |
161 public byte[] getSessionIdentifier() { | 161 public byte[] getSessionIdentifier() { |
162 return km.sessionId; | 162 return km.sessionId; |
163 } | 163 } |
164 | 164 |
165 public void close() { | 165 public void close(Throwable cause, boolean useDisconnectPacket) { |
166 // It is safe now to acquire the semaphore. | 166 if (useDisconnectPacket == false) { |
167 // OK, hard shutdown - do not acquire the semaphore, | |
168 // perhaps somebody is inside (and waits until | |
169 // the remote side is ready to accept new data). | |
170 try { | |
171 socket.close(); | |
172 } | |
173 catch (IOException ignore) { | |
174 } | |
175 // OK, whoever tried to send data, should now agree that | |
176 // there is no point in further waiting =) | |
177 // It is safe now to acquire the semaphore. | |
178 } | |
179 | |
167 synchronized (connectionSemaphore) { | 180 synchronized (connectionSemaphore) { |
168 if (!connectionClosed) { | 181 if (!connectionClosed) { |
169 try { | 182 if (useDisconnectPacket == true) { |
170 tc.sendMessage(new PacketDisconnect( | 183 try { |
171 PacketDisconnect.Reason.SSH_DISCONNECT_BY_APPLICATION, "").getPayload()); | 184 if (tc != null) |
172 } | 185 tc.sendMessage(new PacketDisconnect(PacketDisconnect.Reason.SSH_DISCONNECT_BY_APPLICATION, "").getPayload()); |
173 catch (IOException ignore) { | 186 } |
174 // | 187 catch (IOException ignore) { |
175 } | 188 } |
176 | 189 |
177 try { | 190 try { |
178 socket.close(); | 191 socket.close(); |
179 } | 192 } |
180 catch (IOException ignore) { | 193 catch (IOException ignore) { |
181 // | 194 } |
182 } | 195 |
183 | 196 connectionClosed = true; |
184 connectionClosed = true; | 197 reasonClosedCause = cause; |
185 | 198 |
186 synchronized (this) { | 199 synchronized (this) { |
187 for (ConnectionMonitor cmon : connectionMonitors) { | 200 for (ConnectionMonitor cmon : connectionMonitors) { |
188 cmon.connectionLost(reasonClosedCause); | 201 try { |
202 cmon.connectionLost(reasonClosedCause); | |
203 } | |
204 catch (Exception ignore) { | |
205 } | |
189 } | 206 } |
190 } | 207 } |
191 } | 208 } |
192 | 209 |
193 connectionSemaphore.notifyAll(); | 210 connectionSemaphore.notifyAll(); |
194 } | |
195 } | |
196 | |
197 public void close(IOException cause) { | |
198 // Do not acquire the semaphore, perhaps somebody is inside (and waits until | |
199 // the remote side is ready to accept new data | |
200 try { | |
201 socket.close(); | |
202 } | |
203 catch (IOException ignore) { | |
204 } | |
205 | |
206 // It is safe now to acquire the semaphore. | |
207 synchronized (connectionSemaphore) { | |
208 connectionClosed = true; | |
209 reasonClosedCause = cause; | |
210 connectionSemaphore.notifyAll(); | |
211 } | |
212 | |
213 synchronized (this) { | |
214 for (ConnectionMonitor cmon : connectionMonitors) { | |
215 cmon.connectionLost(reasonClosedCause); | |
216 } | |
217 } | 211 } |
218 } | 212 } |
219 | 213 |
220 protected void startReceiver() throws IOException { | 214 protected void startReceiver() throws IOException { |
221 final Thread receiveThread = new Thread(new Runnable() { | 215 final Thread receiveThread = new Thread(new Runnable() { |