1
1
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
3
Copyright (c) 2002,2003,2004,2005,2006 ymnk, JCraft,Inc. All rights reserved.
3
Copyright (c) 2002-2008 ymnk, JCraft,Inc. All rights reserved.
5
5
Redistribution and use in source and binary forms, with or without
6
6
modification, are permitted provided that the following conditions are met:
40
40
//static private final int LOCAL_WINDOW_SIZE_MAX=0x100000;
41
41
static private final int LOCAL_MAXIMUM_PACKET_SIZE=0x4000;
43
static private final int TIMEOUT=10*1000;
43
45
SocketFactory factory=null;
46
private Socket socket=null;
47
private ForwardedTCPIPDaemon daemon=null;
50
54
setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX);
51
55
setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX);
52
56
setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE);
59
64
Class c=Class.forName(target);
60
ForwardedTCPIPDaemon daemon=(ForwardedTCPIPDaemon)c.newInstance();
61
daemon.setChannel(this);
65
daemon=(ForwardedTCPIPDaemon)c.newInstance();
67
PipedOutputStream out=new PipedOutputStream();
68
io.setInputStream(new PassiveInputStream(out
72
daemon.setChannel(this, getInputStream(), out);
62
73
Object[] foo=getPort(session, rport);
63
74
daemon.setArg((Object[])foo[3]);
64
76
new Thread(daemon).start();
69
Socket socket=(factory==null) ?
70
new Socket(target, lport) :
79
socket=(factory==null) ?
80
Util.createSocket(target, lport, TIMEOUT) :
71
81
factory.createSocket(target, lport);
72
82
socket.setTcpNoDelay(true);
73
83
io.setInputStream(socket.getInputStream());
74
84
io.setOutputStream(socket.getOutputStream());
86
sendOpenConfirmation();
78
88
catch(Exception e){
79
System.out.println(e);
89
sendOpenFailure(SSH_OPEN_ADMINISTRATIVELY_PROHIBITED);
84
95
thread=Thread.currentThread();
85
96
Buffer buf=new Buffer(rmpsize);
86
97
Packet packet=new Packet(buf);
89
while(thread!=null && io!=null && io.in!=null){
100
while(thread!=null &&
90
103
i=io.in.read(buf.buffer,
92
105
buf.buffer.length-14
122
135
int orgport=buf.getInt();
125
System.out.println("addr: "+new String(addr));
126
System.out.println("port: "+port);
127
System.out.println("orgaddr: "+new String(orgaddr));
128
System.out.println("orgport: "+orgport);
138
System.err.println("addr: "+new String(addr));
139
System.err.println("port: "+port);
140
System.err.println("orgaddr: "+new String(orgaddr));
141
System.err.println("orgport: "+orgport);
131
144
synchronized(pool){