01: package ch.ethz.ssh2;
02:
03: import java.io.IOException;
04: import ch.ethz.ssh2.channel.ChannelManager;
05: import ch.ethz.ssh2.channel.LocalAcceptThread;
06:
07: /**
08: * A <code>LocalPortForwarder</code> forwards TCP/IP connections to a local
09: * port via the secure tunnel to another host (which may or may not be identical
10: * to the remote SSH-2 server).
11: *
12: * @author Christian Plattner, plattner@inf.ethz.ch
13: * @version $Id: LocalPortForwarder.java,v 1.5 2006/02/14 19:43:16 cplattne Exp $
14: */
15: public class LocalPortForwarder {
16: ChannelManager cm;
17:
18: int local_port;
19:
20: String host_to_connect;
21:
22: int port_to_connect;
23:
24: LocalAcceptThread lat;
25:
26: LocalPortForwarder(ChannelManager cm, int local_port,
27: String host_to_connect, int port_to_connect)
28: throws IOException {
29: this .cm = cm;
30: this .local_port = local_port;
31: this .host_to_connect = host_to_connect;
32: this .port_to_connect = port_to_connect;
33:
34: lat = new LocalAcceptThread(cm, local_port, host_to_connect,
35: port_to_connect);
36: lat.setDaemon(true);
37: lat.start();
38: }
39:
40: /**
41: * Stop TCP/IP forwarding of newly arriving connections.
42: *
43: * @throws IOException
44: */
45: public void close() throws IOException {
46: lat.stopWorking();
47: }
48: }
|