comparison src/ch/ethz/ssh2/LocalPortForwarder.java @ 308:42b15aaa7ac7 ganymed

merge
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 14:21:50 -0700
parents 071eccdff8ea
children
comparison
equal deleted inserted replaced
306:90e47d99ea54 308:42b15aaa7ac7
15 /** 15 /**
16 * A <code>LocalPortForwarder</code> forwards TCP/IP connections to a local 16 * A <code>LocalPortForwarder</code> forwards TCP/IP connections to a local
17 * port via the secure tunnel to another host (which may or may not be identical 17 * port via the secure tunnel to another host (which may or may not be identical
18 * to the remote SSH-2 server). Checkout {@link Connection#createLocalPortForwarder(int, String, int)} 18 * to the remote SSH-2 server). Checkout {@link Connection#createLocalPortForwarder(int, String, int)}
19 * on how to create one. 19 * on how to create one.
20 * 20 *
21 * @author Christian Plattner 21 * @author Christian Plattner
22 * @version 2.50, 03/15/10 22 * @version 2.50, 03/15/10
23 */ 23 */
24 public class LocalPortForwarder 24 public class LocalPortForwarder {
25 { 25 final ChannelManager cm;
26 final ChannelManager cm;
27 26
28 final String host_to_connect; 27 final String host_to_connect;
29 28
30 final int port_to_connect; 29 final int port_to_connect;
31 30
32 final LocalAcceptThread lat; 31 final LocalAcceptThread lat;
33 32
34 LocalPortForwarder(ChannelManager cm, int local_port, String host_to_connect, int port_to_connect) 33 LocalPortForwarder(ChannelManager cm, int local_port, String host_to_connect, int port_to_connect)
35 throws IOException 34 throws IOException {
36 { 35 this.cm = cm;
37 this.cm = cm; 36 this.host_to_connect = host_to_connect;
38 this.host_to_connect = host_to_connect; 37 this.port_to_connect = port_to_connect;
39 this.port_to_connect = port_to_connect; 38 lat = new LocalAcceptThread(cm, local_port, host_to_connect, port_to_connect);
39 lat.setDaemon(true);
40 lat.start();
41 }
40 42
41 lat = new LocalAcceptThread(cm, local_port, host_to_connect, port_to_connect); 43 LocalPortForwarder(ChannelManager cm, InetSocketAddress addr, String host_to_connect, int port_to_connect)
42 lat.setDaemon(true); 44 throws IOException {
43 lat.start(); 45 this.cm = cm;
44 } 46 this.host_to_connect = host_to_connect;
47 this.port_to_connect = port_to_connect;
48 lat = new LocalAcceptThread(cm, addr, host_to_connect, port_to_connect);
49 lat.setDaemon(true);
50 lat.start();
51 }
45 52
46 LocalPortForwarder(ChannelManager cm, InetSocketAddress addr, String host_to_connect, int port_to_connect) 53 /**
47 throws IOException 54 * Return the local socket address of the {@link ServerSocket} used to accept connections.
48 { 55 * @return
49 this.cm = cm; 56 */
50 this.host_to_connect = host_to_connect; 57 public InetSocketAddress getLocalSocketAddress() {
51 this.port_to_connect = port_to_connect; 58 return (InetSocketAddress) lat.getServerSocket().getLocalSocketAddress();
59 }
52 60
53 lat = new LocalAcceptThread(cm, addr, host_to_connect, port_to_connect); 61 /**
54 lat.setDaemon(true); 62 * Stop TCP/IP forwarding of newly arriving connections.
55 lat.start(); 63 *
56 } 64 * @throws IOException
57 65 */
58 /** 66 public void close() throws IOException {
59 * Return the local socket address of the {@link ServerSocket} used to accept connections. 67 lat.stopWorking();
60 * @return 68 }
61 */
62 public InetSocketAddress getLocalSocketAddress()
63 {
64 return (InetSocketAddress) lat.getServerSocket().getLocalSocketAddress();
65 }
66
67 /**
68 * Stop TCP/IP forwarding of newly arriving connections.
69 *
70 * @throws IOException
71 */
72 public void close() throws IOException
73 {
74 lat.stopWorking();
75 }
76 } 69 }