|
15 | 15 | */
|
16 | 16 | package net.schmizz.sshj.transport;
|
17 | 17 |
|
| 18 | +import com.hierynomus.sshj.common.ThreadNameProvider; |
18 | 19 | import com.hierynomus.sshj.key.KeyAlgorithm;
|
19 | 20 | import com.hierynomus.sshj.key.KeyAlgorithms;
|
20 | 21 | import com.hierynomus.sshj.transport.IdentificationStringParser;
|
21 | 22 | import net.schmizz.concurrent.ErrorDeliveryUtil;
|
22 | 23 | import net.schmizz.concurrent.Event;
|
23 | 24 | import net.schmizz.sshj.AbstractService;
|
24 | 25 | import net.schmizz.sshj.Config;
|
25 |
| -import net.schmizz.sshj.SSHClient; |
26 | 26 | import net.schmizz.sshj.Service;
|
27 | 27 | import net.schmizz.sshj.common.*;
|
28 | 28 | import net.schmizz.sshj.transport.verification.AlgorithmsVerifier;
|
|
32 | 32 | import java.io.IOException;
|
33 | 33 | import java.io.InputStream;
|
34 | 34 | import java.io.OutputStream;
|
| 35 | +import java.net.InetSocketAddress; |
35 | 36 | import java.util.List;
|
36 | 37 | import java.util.concurrent.TimeUnit;
|
37 | 38 | import java.util.concurrent.locks.ReentrantLock;
|
@@ -128,8 +129,8 @@ static final class ConnInfo {
|
128 | 129 | public TransportImpl(Config config) {
|
129 | 130 | this.config = config;
|
130 | 131 | this.loggerFactory = config.getLoggerFactory();
|
131 |
| - this.serviceAccept = new Event<TransportException>("service accept", TransportException.chainer, loggerFactory); |
132 |
| - this.close = new Event<TransportException>("transport close", TransportException.chainer, loggerFactory); |
| 132 | + this.serviceAccept = new Event<>("service accept", TransportException.chainer, loggerFactory); |
| 133 | + this.close = new Event<>("transport close", TransportException.chainer, loggerFactory); |
133 | 134 | this.nullService = new NullService(this);
|
134 | 135 | this.service = nullService;
|
135 | 136 | this.log = loggerFactory.getLogger(getClass());
|
@@ -163,9 +164,20 @@ public void init(String remoteHost, int remotePort, InputStream in, OutputStream
|
163 | 164 | throw new TransportException(e);
|
164 | 165 | }
|
165 | 166 |
|
| 167 | + ThreadNameProvider.setThreadName(reader, this); |
166 | 168 | reader.start();
|
167 | 169 | }
|
168 | 170 |
|
| 171 | + /** |
| 172 | + * Get Remote Socket Address using Connection Information |
| 173 | + * |
| 174 | + * @return Remote Socket Address or null when not connected |
| 175 | + */ |
| 176 | + @Override |
| 177 | + public InetSocketAddress getRemoteSocketAddress() { |
| 178 | + return connInfo == null ? null : new InetSocketAddress(getRemoteHost(), getRemotePort()); |
| 179 | + } |
| 180 | + |
169 | 181 | /**
|
170 | 182 | * TransportImpl implements its own default DisconnectListener.
|
171 | 183 | */
|
@@ -209,7 +221,7 @@ private void sendClientIdent() throws IOException {
|
209 | 221 | *
|
210 | 222 | * @param buffer The buffer to read from.
|
211 | 223 | * @return empty string if full ident string has not yet been received
|
212 |
| - * @throws IOException |
| 224 | + * @throws IOException Thrown when protocol version is not supported |
213 | 225 | */
|
214 | 226 | private String readIdentification(Buffer.PlainBuffer buffer)
|
215 | 227 | throws IOException {
|
@@ -542,7 +554,7 @@ private void gotServiceAccept()
|
542 | 554 | * Got an SSH_MSG_UNIMPLEMENTED, so lets see where we're at and act accordingly.
|
543 | 555 | *
|
544 | 556 | * @param packet The 'unimplemented' packet received
|
545 |
| - * @throws TransportException |
| 557 | + * @throws TransportException Thrown when key exchange is ongoing |
546 | 558 | */
|
547 | 559 | private void gotUnimplemented(SSHPacket packet)
|
548 | 560 | throws SSHException {
|
|
0 commit comments