示例#1
0
        public Channel(string servername, string rd, int cid, SSHChannel channel, Socket socket)
        {
            _serverName = servername;
            _remoteDescription = rd;
            _connectionID = cid;
            _wroteClosedLog = false;

            if(channel!=null)
                _channel = new SynchronizedSSHChannel(channel);
            _socket = new SynchronizedSocket(socket);
            _buffer = new byte[0x1000];
            _channelReady = new ManualResetEvent(false);
        }
示例#2
0
        protected ChannelEntry RegisterChannelEventReceiver(SSHChannel ch, ISSHChannelEventReceiver r)
        {
            lock(this) {
                ChannelEntry e = new ChannelEntry();
                e._channel = ch;
                e._receiver = r;
                e._localID = _channel_sequence++;

                for(int i=0; i<_channel_entries.Count; i++) {
                    if(_channel_entries[i]==null) {
                        _channel_entries[i] = e;
                        return e;
                    }
                }
                _channel_entries.Add(e);
                return e;
            }
        }
示例#3
0
 internal void RegisterChannel(int local_id, SSHChannel ch)
 {
     FindChannelEntry(local_id)._channel = ch;
 }
 public void EstablishPortforwarding(ISSHChannelEventReceiver receiver, SSHChannel channel)
 {
 }
 //authentication process for keyboard-interactive
 private void InputAuthenticationResponse(byte[] buf, int offset, int length)
 {
     for(int i=offset; i<offset+length; i++) {
         byte b = buf[i];
         if(_passwordBuffer==null) _passwordBuffer = new MemoryStream();
         if(b==13 || b==10) { //CR/LF
             byte[] pwd = _passwordBuffer.ToArray();
             if(pwd.Length>0) {
                 _passwordBuffer.Close();
                 string[] response = new string[1];
                 response[0] = Encoding.ASCII.GetString(pwd);
                 OnData(Encoding.ASCII.GetBytes("\r\n"), 0, 2); //�\������s���Ȃ��Ɗi�D����
                 if(((Granados.SSHCV2.SSH2Connection)_connection).DoKeyboardInteractiveAuth(response)==AuthenticationResult.Success)
                     _channel = _connection.OpenShell(this);
                 _passwordBuffer = null;
             }
         }
         else if(b==3 || b==27) { //Ctrl+C, ESC
             GEnv.GetConnectionCommandTarget(this).Disconnect();
             return;
         }
         else
             _passwordBuffer.WriteByte(b);
     }
 }
 public void OpenShell()
 {
     _channel = _connection.OpenShell(this);
 }
示例#7
0
 public SynchronizedSSHChannel(SSHChannel ch)
 {
     _channel = ch;
     _connection = _channel.Connection;
     _closed = false;
 }
示例#8
0
 public void FixChannel(SSHChannel ch)
 {
     _channel = new SynchronizedSSHChannel(ch);
     Env.Log.LogChannelOpened(_remoteDescription, _connectionID);
 }
示例#9
0
 public override void EstablishPortforwarding(ISSHChannelEventReceiver receiver, SSHChannel channel)
 {
     try {
         Channel ch = (Channel)receiver;
         ch.FixChannel(channel);
         ch.OnChannelReady();
         ch.StartAsyncReceive();
     }
     catch(Exception ex) {
         Debug.WriteLine(ex.StackTrace);
         Util.InterThreadWarning(ex.Message);
     }
 }