comparison src/com/trilead/ssh2/DynamicPortForwarder.java @ 0:0ce5cc452d02

initial version
author Carl Byington <carl@five-ten-sg.com>
date Thu, 22 May 2014 10:41:19 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0ce5cc452d02
1 /*
2 * ConnectBot: simple, powerful, open-source SSH client for Android
3 * Copyright 2007 Kenny Root, Jeffrey Sharkey
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package com.trilead.ssh2;
19
20 import java.io.IOException;
21 import java.net.InetSocketAddress;
22
23 import com.trilead.ssh2.channel.ChannelManager;
24 import com.trilead.ssh2.channel.DynamicAcceptThread;
25
26 /**
27 * A <code>DynamicPortForwarder</code> forwards TCP/IP connections to a local
28 * port via the secure tunnel to another host which is selected via the
29 * SOCKS protocol. Checkout {@link Connection#createDynamicPortForwarder(int)}
30 * on how to create one.
31 *
32 * @author Kenny Root
33 * @version $Id: $
34 */
35 public class DynamicPortForwarder {
36 ChannelManager cm;
37
38 DynamicAcceptThread dat;
39
40 DynamicPortForwarder(ChannelManager cm, int local_port)
41 throws IOException {
42 this.cm = cm;
43 dat = new DynamicAcceptThread(cm, local_port);
44 dat.setDaemon(true);
45 dat.start();
46 }
47
48 DynamicPortForwarder(ChannelManager cm, InetSocketAddress addr) throws IOException {
49 this.cm = cm;
50 dat = new DynamicAcceptThread(cm, addr);
51 dat.setDaemon(true);
52 dat.start();
53 }
54
55 /**
56 * Stop TCP/IP forwarding of newly arriving connections.
57 *
58 * @throws IOException
59 */
60 public void close() throws IOException {
61 dat.stopWorking();
62 }
63 }