Exemple #1
0
        private void InitializeSftp(SessionChannel channel, string username)
        {
            var user = settingsrepo.GetUser(username);

            if (user != null)
            {
                // check IP user.WhitelistedIps


                SftpSubsystem sftpsub = new SftpSubsystem(_logger, channel.ClientChannelId, user.UserRootDirectory);
                channel.DataReceived += (ss, ee) => sftpsub.OnInput(ee);
                sftpsub.OnOutput     += (ss, ee) => channel.SendData(ee);
                sftpsub.OnClose      += (ss, ee) => channel.SendClose(null);
            }
        }
Exemple #2
0
        private void MessageLoop()
        {
            var bytes = new byte[1024 * 64];

            while (true)
            {
                var len = _process.StandardOutput.BaseStream.Read(bytes, 0, bytes.Length);
                if (len <= 0)
                {
                    break;
                }

                var data = bytes.Length != len
                    ? bytes.Take(len).ToArray()
                    : bytes;

                _channel.SendData(data);
            }
            _channel.SendEof();
            _channel.SendClose((uint)_process.ExitCode);
            EnsureClose();
        }