예제 #1
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Request(Session session, Channel channel, string subsystem, bool
			 want_reply)
		{
			SetReply(want_reply);
			this.subsystem = subsystem;
			this.DoRequest(session, channel);
		}
예제 #2
0
파일: Channel.cs 프로젝트: shoff/ngit
 internal static void Del(NSch.Channel c)
 {
     lock (pool)
     {
         pool.RemoveElement(c);
     }
 }
예제 #3
0
		/// <exception cref="System.Exception"></exception>
		internal override void DoRequest(Session session, Channel channel)
		{
			base.DoRequest(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"
			// boolean want reply         // 0
			// boolean   single connection
			// string    x11 authentication protocol // "MIT-MAGIC-COOKIE-1".
			// string    x11 authentication cookie
			// uint32    x11 screen number
			packet.Reset();
			buf.PutByte(unchecked((byte)Session.SSH_MSG_CHANNEL_REQUEST));
			buf.PutInt(channel.GetRecipient());
			buf.PutString(Util.Str2byte("x11-req"));
			buf.PutByte(unchecked((byte)(WaitForReply() ? 1 : 0)));
			buf.PutByte(unchecked((byte)0));
			buf.PutString(Util.Str2byte("MIT-MAGIC-COOKIE-1"));
			buf.PutString(ChannelX11.GetFakedCookie(session));
			buf.PutInt(0);
			Write(packet);
			session.x11_forwarding = true;
		}
예제 #4
0
파일: Channel.cs 프로젝트: shoff/ngit
        /// <exception cref="System.IO.IOException"></exception>
        public virtual OutputStream GetOutputStream()
        {
            NSch.Channel channel = this;
            OutputStream @out    = new _OutputStream_268(this, channel);

            // close should be finished silently.
            return(@out);
        }
예제 #5
0
		/// <exception cref="System.Exception"></exception>
		internal virtual void DoRequest(Session session, Channel channel)
		{
			this.session = session;
			this.channel = channel;
			if (channel.connectTimeout > 0)
			{
				SetReply(true);
			}
		}
예제 #6
0
파일: Channel.cs 프로젝트: shoff/ngit
 public _OutputStream_268(Channel _enclosing, NSch.Channel channel)
 {
     this._enclosing = _enclosing;
     this.channel    = channel;
     this.dataLen    = 0;
     this.buffer     = null;
     this.packet     = null;
     this.closed     = false;
     this.b          = new byte[1];
 }
예제 #7
0
		/// <exception cref="System.Exception"></exception>
		internal override void DoRequest(Session session, Channel channel)
		{
			base.DoRequest(session, channel);
			Buffer buf = new Buffer();
			Packet packet = new Packet(buf);
			packet.Reset();
			buf.PutByte(unchecked((byte)Session.SSH_MSG_CHANNEL_REQUEST));
			buf.PutInt(channel.GetRecipient());
			buf.PutString(Util.Str2byte("subsystem"));
			buf.PutByte(unchecked((byte)(WaitForReply() ? 1 : 0)));
			buf.PutString(Util.Str2byte(subsystem));
			Write(packet);
		}
예제 #8
0
파일: Channel.cs 프로젝트: shoff/ngit
 internal static NSch.Channel GetChannel(int id, Session session)
 {
     lock (pool)
     {
         for (int i = 0; i < pool.Count; i++)
         {
             NSch.Channel c = (NSch.Channel)(pool[i]);
             if (c.id == id && c.session == session)
             {
                 return(c);
             }
         }
     }
     return(null);
 }
예제 #9
0
		/// <exception cref="System.Exception"></exception>
		internal override void DoRequest(Session session, Channel channel)
		{
			base.DoRequest(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"
			// boolean want reply        // 0
			packet.Reset();
			buf.PutByte(unchecked((byte)Session.SSH_MSG_CHANNEL_REQUEST));
			buf.PutInt(channel.GetRecipient());
			buf.PutString(Util.Str2byte("shell"));
			buf.PutByte(unchecked((byte)(WaitForReply() ? 1 : 0)));
			Write(packet);
		}
예제 #10
0
		/// <exception cref="System.Exception"></exception>
		internal override void DoRequest(Session session, Channel channel)
		{
			base.DoRequest(session, channel);
			SetReply(false);
			Buffer buf = new Buffer();
			Packet packet = new Packet(buf);
			// byte      SSH_MSG_CHANNEL_REQUEST(98)
			// uint32 recipient channel
			// string request type        // "*****@*****.**"
			// boolean want reply         // 0
			packet.Reset();
			buf.PutByte(unchecked((byte)Session.SSH_MSG_CHANNEL_REQUEST));
			buf.PutInt(channel.GetRecipient());
			buf.PutString(Util.Str2byte("*****@*****.**"));
			buf.PutByte(unchecked((byte)(WaitForReply() ? 1 : 0)));
			Write(packet);
			session.agent_forwarding = true;
		}
예제 #11
0
		/// <exception cref="System.Exception"></exception>
		internal override void DoRequest(Session session, Channel channel)
		{
			base.DoRequest(session, channel);
			Buffer buf = new Buffer();
			Packet packet = new Packet(buf);
			packet.Reset();
			buf.PutByte(unchecked((byte)Session.SSH_MSG_CHANNEL_REQUEST));
			buf.PutInt(channel.GetRecipient());
			buf.PutString(Util.Str2byte("pty-req"));
			buf.PutByte(unchecked((byte)(WaitForReply() ? 1 : 0)));
			buf.PutString(Util.Str2byte(ttype));
			buf.PutInt(tcol);
			buf.PutInt(trow);
			buf.PutInt(twp);
			buf.PutInt(thp);
			buf.PutString(terminal_mode);
			Write(packet);
		}
예제 #12
0
		/// <exception cref="System.Exception"></exception>
		internal override void DoRequest(Session session, Channel channel)
		{
			base.DoRequest(session, channel);
			Buffer buf = new Buffer();
			Packet packet = new Packet(buf);
			//byte      SSH_MSG_CHANNEL_REQUEST
			//uint32    recipient_channel
			//string    "window-change"
			//boolean   FALSE
			//uint32    terminal width, columns
			//uint32    terminal height, rows
			//uint32    terminal width, pixels
			//uint32    terminal height, pixels
			packet.Reset();
			buf.PutByte(unchecked((byte)Session.SSH_MSG_CHANNEL_REQUEST));
			buf.PutInt(channel.GetRecipient());
			buf.PutString(Util.Str2byte("window-change"));
			buf.PutByte(unchecked((byte)(WaitForReply() ? 1 : 0)));
			buf.PutInt(width_columns);
			buf.PutInt(height_rows);
			buf.PutInt(width_pixels);
			buf.PutInt(height_pixels);
			Write(packet);
		}
예제 #13
0
			/// <exception cref="System.IO.IOException"></exception>
			public MyPipedInputStream(Channel _enclosing, PipedOutputStream @out, int size) : 
				base(@out)
			{
				this._enclosing = _enclosing;
				this.buffer = new byte[size];
			}
예제 #14
0
			public _OutputStream_220(Channel _enclosing, NSch.Channel channel)
			{
				this._enclosing = _enclosing;
				this.channel = channel;
				this.dataLen = 0;
				this.buffer = null;
				this.packet = null;
				this.closed = false;
				this.b = new byte[1];
			}
예제 #15
0
			/// <exception cref="System.IO.IOException"></exception>
			public MyPipedInputStream(Channel _enclosing) : base()
			{
				this._enclosing = _enclosing;
			}
예제 #16
0
			/// <exception cref="System.IO.IOException"></exception>
			public PassiveOutputStream(Channel _enclosing, PipedInputStream @in) : base(@in)
			{
				this._enclosing = _enclosing;
			}
예제 #17
0
			/// <exception cref="System.IO.IOException"></exception>
			public PassiveInputStream(Channel _enclosing, PipedOutputStream @out) : base(_enclosing
				)
			{
				this._enclosing = _enclosing;
				this.@out = @out;
			}
예제 #18
0
			/// <exception cref="System.IO.IOException"></exception>
			public PassiveInputStream(Channel _enclosing, PipedOutputStream @out, int size) : 
				base(_enclosing)
			{
				this._enclosing = _enclosing;
				//  public String toString(){
				//      return "Channel: type="+new String(type)+",id="+id+",recipient="+recipient+",window_size="+window_size+",packet_size="+packet_size;
				//  }
				this.@out = @out;
			}
예제 #19
0
		//System.err.println("updatekeys: "+e); 
		/// <exception cref="System.Exception"></exception>
		internal virtual void Write(Packet packet, Channel c, int length)
		{
			long t = GetTimeout();
			while (true)
			{
				if (in_kex)
				{
					if (t > 0L && (Runtime.CurrentTimeMillis() - kex_start_time) > t)
					{
						throw new JSchException("timeout in wating for rekeying process.");
					}
					try
					{
						Sharpen.Thread.Sleep(10);
					}
					catch (Exception)
					{
					}
					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)
					{
						long len = c.rwsize;
						if (len > length)
						{
							len = length;
						}
						if (len != length)
						{
							s = packet.Shift((int)len, (c2smac != null ? c2smac.GetBlockSize() : 0));
						}
						command = packet.buffer.GetCommand();
						recipient = c.GetRecipient();
						length -= (int)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++;
						Sharpen.Runtime.Wait(c, 100);
					}
					catch (Exception)
					{
					}
					finally
					{
						c.notifyme--;
					}
				}
			}
			_write(packet);
		}
예제 #20
0
			/// <exception cref="System.IO.IOException"></exception>
			public MyPipedInputStream(Channel _enclosing, PipedOutputStream @out) : base(@out
				)
			{
				this._enclosing = _enclosing;
			}
예제 #21
0
		//System.err.println(foo+" isn't accessible.");
		internal virtual void AddChannel(Channel channel)
		{
			channel.SetSession(this);
		}
예제 #22
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 = ((Channel)(pool[i]));
						if (c.session == session)
						{
							channels[count++] = c;
						}
					}
					catch (Exception)
					{
					}
				}
			}
			for (int i_1 = 0; i_1 < count; i_1++)
			{
				channels[i_1].Disconnect();
			}
		}