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