示例#1
0
        internal override void request(Session session, Channel channel)
        {
            base.request(session, channel);

            Buffer buf = new Buffer();
            Packet packet = new Packet(buf);

            // byte      SSH_MSG_CHANNEL_REQUEST(98)
            // uint32 recipient channel
            // string request type        // "x11-req"
            // bool want reply         // 0
            // bool   single connection
            // string    x11 authentication protocol // "MIT-MAGIC-COOKIE-1".
            // string    x11 authentication cookie
            // uint32    x11 screen number
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString("x11-req".getBytes());
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putByte((byte)0);
            buf.putString("MIT-MAGIC-COOKIE-1".getBytes());
            buf.putString(ChannelX11.getFakedCookie(session));
            buf.putInt(0);
            write(packet);

            session.x11_forwarding = true;
        }
        internal override void request(Session session, Channel channel)
        {
            base.request(session, channel);

            Buffer buf = new Buffer();
            Packet packet = new Packet(buf);

            //byte      SSH_MSG_CHANNEL_REQUEST
            //uint32    recipient_channel
            //string    "window-change"
            //bool   FALSE
            //uint32    terminal width, columns
            //uint32    terminal height, rows
            //uint32    terminal width, pixels
            //uint32    terminal height, pixels
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString("window-change".getBytes());
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putInt(width_columns);
            buf.putInt(height_rows);
            buf.putInt(width_pixels);
            buf.putInt(height_pixels);
            write(packet);
        }
示例#3
0
 internal virtual void request(Session session, Channel channel)
 {
     this.session = session;
     this.channel = channel;
     if (channel.connectTimeout > 0)
     {
         setReply(true);
     }
 }
示例#4
0
        internal override void request(Session session, Channel channel)
        {
            base.request(session, channel);

            Buffer buf = new Buffer();
            Packet packet = new Packet(buf);
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString("subsystem".getBytes());
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString("sftp".getBytes());
            write(packet);
        }
示例#5
0
        internal override void request(Session session, Channel channel)
        {
            base.request(session, channel);

            Buffer buf = new Buffer();
            Packet packet = new Packet(buf);

            // send
            // byte     SSH_MSG_CHANNEL_REQUEST(98)
            // uint32 recipient channel
            // string request type       // "shell"
            // bool want reply        // 0
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString("shell".getBytes());
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            write(packet);
        }
示例#6
0
        internal override void request(Session session, Channel channel)
        {
            base.request(session, channel);

            Buffer buf = new Buffer();
            Packet packet = new Packet(buf);

            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString("pty-req".getBytes());
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString(ttype.getBytes());
            buf.putInt(tcol);
            buf.putInt(trow);
            buf.putInt(twp);
            buf.putInt(thp);
            buf.putString(terminal_mode);
            write(packet);
        }
示例#7
0
        /*[MethodImpl(MethodImplOptions.Synchronized)]*/
        /*public*/
        /*synchronized*/
        internal void write(Packet packet, Channel c, int length)
        {
            while (true)
            {
                if (in_kex)
                {
                    Thread.Sleep(10);
                    continue;
                }
                lock (c)
                {
                    if (c.rwsize >= length)
                    {
                        c.rwsize -= length;
                        break;
                    }
                }
                if (c.close || !c.isConnected())
                {
                    throw new IOException("channel is broken");
                }

                bool sendit = false;
                int s = 0;
                byte command = 0;
                int recipient = -1;
                lock (c)
                {
                    if (c.rwsize > 0)
                    {
                        int len = c.rwsize;
                        if (len > length)
                        {
                            len = length;
                        }
                        if (len != length)
                        {
                            s = packet.shift(len, (c2smac != null ? c2smac.getBlockSize() : 0));
                        }
                        command = packet.buffer.getCommand();
                        recipient = c.getRecipient();
                        length -= len;
                        c.rwsize -= len;
                        sendit = true;
                    }
                }
                if (sendit)
                {
                    _write(packet);
                    if (length == 0)
                    {
                        return;
                    }
                    packet.unshift(command, recipient, s, length);
                }

                lock (c)
                {
                    if (in_kex)
                    {
                        continue;
                    }
                    if (c.rwsize >= length)
                    {
                        c.rwsize -= length;
                        break;
                    }
                    try
                    {
                        c.notifyme++;
                        Monitor.Wait(c, 100);
                    }
                    catch (ThreadInterruptedException )
                    {
                    }
                    finally
                    {
                        c.notifyme--;
                    }
                }

            }
            _write(packet);
        }
示例#8
0
 internal void addChannel(Channel channel)
 {
     channel.setSession(this);
 }
 public void request(Session session, Channel channel, string subsystem, bool want_reply)
 {
     setReply(want_reply);
     this.subsystem = subsystem;
     this.request(session, channel);
 }
示例#10
0
 internal PrivateOutputStream(Channel channel)
 {
     this.channel = channel;
 }
示例#11
0
 internal static void disconnect(Session session)
 {
     Channel[] channels = null;
     int count = 0;
     lock (pool)
     {
         channels = new Channel[pool.Count];
         for (int i = 0; i < pool.Count; i++)
         {
             try
             {
                 Channel c = pool[i];
                 if (c.session == session)
                 {
                     channels[count++] = c;
                 }
             }
             catch // (Exception e)
             {
             }
         }
     }
     for (int i = 0; i < count; i++)
     {
         channels[i].disconnect();
     }
 }
示例#12
0
 internal static void del(Channel c)
 {
     lock (pool)
     {
         pool.Remove(c);
     }
 }