1 | /******************************************************************************
|
---|
2 | *
|
---|
3 | * Copyright (c) 1998,99 by Mindbright Technology AB, Stockholm, Sweden.
|
---|
4 | * www.mindbright.se, [email protected]
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | *****************************************************************************
|
---|
17 | * $Author: mats $
|
---|
18 | * $Date: 1999/09/06 18:54:29 $
|
---|
19 | * $Name: rel1-2-1 $
|
---|
20 | *****************************************************************************/
|
---|
21 | package mindbright.ssh;
|
---|
22 |
|
---|
23 | import java.util.Random;
|
---|
24 | import java.io.IOException;
|
---|
25 |
|
---|
26 | public class SSHFtpPlugin extends SSHProtocolPlugin {
|
---|
27 |
|
---|
28 | public void initiate(SSHClient client) {
|
---|
29 | client.delRemotePortForward("ftp");
|
---|
30 | if(client.havePORTFtp) {
|
---|
31 | Random rnd = new Random();
|
---|
32 | int rndval;
|
---|
33 | while((rndval = (rnd.nextInt() & 0xfff0)) < 8192)
|
---|
34 | ;
|
---|
35 | client.firstFTPPort = rndval;
|
---|
36 | for(int i = 0; i < SSHFtpTunnel.MAX_REMOTE_LISTEN; i++) {
|
---|
37 | client.addRemotePortForward(client.firstFTPPort + i,
|
---|
38 | SSHFtpTunnel.TUNNEL_NAME + i,
|
---|
39 | client.firstFTPPort + i, "ftp");
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | public SSHListenChannel localListener(String localHost, int localPort,
|
---|
45 | String remoteHost, int remotePort,
|
---|
46 | SSHChannelController controller) throws IOException {
|
---|
47 | return new SSHFtpListenChannel(localHost, localPort, remoteHost, remotePort, controller);
|
---|
48 | }
|
---|
49 |
|
---|
50 | }
|
---|