~ubuntu-branches/ubuntu/trusty/jsch/trusty-proposed

« back to all changes in this revision

Viewing changes to src/com/jcraft/jsch/ChannelForwardedTCPIP.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2008-03-21 11:41:01 UTC
  • mfrom: (3.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080321114101-2g9w5l8ynwf6pbsq
Tags: 0.1.37-3
Add OSGi manifest patch. Thanks to Roberto Jimenoca. Closes: #471209.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
2
2
/*
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.
4
4
 
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;
42
42
 
 
43
  static private final int TIMEOUT=10*1000;
 
44
 
43
45
  SocketFactory factory=null;
 
46
  private Socket socket=null;
 
47
  private ForwardedTCPIPDaemon daemon=null;
44
48
  String target;
45
49
  int lport;
46
50
  int rport;
50
54
    setLocalWindowSizeMax(LOCAL_WINDOW_SIZE_MAX);
51
55
    setLocalWindowSize(LOCAL_WINDOW_SIZE_MAX);
52
56
    setLocalPacketSize(LOCAL_MAXIMUM_PACKET_SIZE);
 
57
    io=new IO();
 
58
    connected=true;
53
59
  }
54
60
 
55
 
  void init (){
 
61
  public void run(){
56
62
    try{ 
57
 
      io=new IO();
58
63
      if(lport==-1){
59
64
        Class c=Class.forName(target);
60
 
        ForwardedTCPIPDaemon daemon=(ForwardedTCPIPDaemon)c.newInstance();
61
 
        daemon.setChannel(this);
 
65
        daemon=(ForwardedTCPIPDaemon)c.newInstance();
 
66
 
 
67
        PipedOutputStream out=new PipedOutputStream();
 
68
        io.setInputStream(new PassiveInputStream(out
 
69
                                                 , 32*1024
 
70
                                                 ), false);
 
71
 
 
72
        daemon.setChannel(this, getInputStream(), out);
62
73
        Object[] foo=getPort(session, rport);
63
74
        daemon.setArg((Object[])foo[3]);
 
75
 
64
76
        new Thread(daemon).start();
65
 
        connected=true;
66
 
        return;
67
77
      }
68
78
      else{
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());
75
 
        connected=true;
76
85
      }
 
86
      sendOpenConfirmation();
77
87
    }
78
88
    catch(Exception e){
79
 
      System.out.println(e);
 
89
      sendOpenFailure(SSH_OPEN_ADMINISTRATIVELY_PROHIBITED);
 
90
      close=true;
 
91
      disconnect();
 
92
      return; 
80
93
    }
81
 
  }
82
94
 
83
 
  public void run(){
84
95
    thread=Thread.currentThread();
85
96
    Buffer buf=new Buffer(rmpsize);
86
97
    Packet packet=new Packet(buf);
87
98
    int i=0;
88
99
    try{
89
 
      while(thread!=null && io!=null && io.in!=null){
 
100
      while(thread!=null && 
 
101
            io!=null && 
 
102
            io.in!=null){
90
103
        i=io.in.read(buf.buffer, 
91
104
                     14, 
92
105
                     buf.buffer.length-14
106
119
      }
107
120
    }
108
121
    catch(Exception e){
109
 
      //System.out.println(e);
 
122
      //System.err.println(e);
110
123
    }
111
124
    //thread=null;
112
125
    //eof();
122
135
    int orgport=buf.getInt();
123
136
 
124
137
    /*
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);
129
142
    */
130
143
 
131
144
    synchronized(pool){
143
156
        break;
144
157
      }
145
158
      if(target==null){
146
 
        System.out.println("??");
 
159
        System.err.println("??");
147
160
      }
148
161
    }
149
162
  }
254
267
      delPort(session, rport[i]);
255
268
    }
256
269
  }
 
270
 
257
271
  public int getRemotePort(){return rport;}
258
272
  void setSocketFactory(SocketFactory factory){
259
273
    this.factory=factory;