コード例 #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
ファイル: RequestX11.cs プロジェクト: LunarLanding/ngit
		/// <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
ファイル: Request.cs プロジェクト: yayanyang/monodevelop
		/// <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
ファイル: RequestShell.cs プロジェクト: LunarLanding/ngit
		/// <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
ファイル: RequestPtyReq.cs プロジェクト: LunarLanding/ngit
		/// <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
ファイル: Channel.cs プロジェクト: LunarLanding/ngit
			/// <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
ファイル: Channel.cs プロジェクト: LunarLanding/ngit
			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
ファイル: Channel.cs プロジェクト: LunarLanding/ngit
			/// <exception cref="System.IO.IOException"></exception>
			public MyPipedInputStream(Channel _enclosing) : base()
			{
				this._enclosing = _enclosing;
			}
コード例 #16
0
ファイル: Channel.cs プロジェクト: LunarLanding/ngit
			/// <exception cref="System.IO.IOException"></exception>
			public PassiveOutputStream(Channel _enclosing, PipedInputStream @in) : base(@in)
			{
				this._enclosing = _enclosing;
			}
コード例 #17
0
ファイル: Channel.cs プロジェクト: LunarLanding/ngit
			/// <exception cref="System.IO.IOException"></exception>
			public PassiveInputStream(Channel _enclosing, PipedOutputStream @out) : base(_enclosing
				)
			{
				this._enclosing = _enclosing;
				this.@out = @out;
			}
コード例 #18
0
ファイル: Channel.cs プロジェクト: LunarLanding/ngit
			/// <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
ファイル: Session.cs プロジェクト: yayanyang/monodevelop
		//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
ファイル: Channel.cs プロジェクト: LunarLanding/ngit
			/// <exception cref="System.IO.IOException"></exception>
			public MyPipedInputStream(Channel _enclosing, PipedOutputStream @out) : base(@out
				)
			{
				this._enclosing = _enclosing;
			}
コード例 #21
0
ファイル: Session.cs プロジェクト: yayanyang/monodevelop
		//System.err.println(foo+" isn't accessible.");
		internal virtual void AddChannel(Channel channel)
		{
			channel.SetSession(this);
		}
コード例 #22
0
ファイル: Channel.cs プロジェクト: LunarLanding/ngit
		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();
			}
		}