Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PasswordProvidedEventArgs"/> class.
        /// </summary>
        /// <param name="challenge">The VNC the server sent.</param>
        /// <param name="response">The bytes of the response from the client.</param>
        /// <param name="passwordChallenge">
        /// A class which implements the <see cref="IVncPasswordChallenge"/> interface, which is able to validate the password.
        /// </param>
        public PasswordProvidedEventArgs(IVncPasswordChallenge passwordChallenge, byte[] challenge, byte[] response)
        {
            if (challenge == null)
            {
                throw new ArgumentNullException(nameof(challenge));
            }

            if (response == null)
            {
                throw new ArgumentNullException(nameof(response));
            }

            if (challenge.Length != 16)
            {
                throw new ArgumentOutOfRangeException(nameof(challenge), "Challenge must be 16 bytes.");
            }

            if (response.Length != 16)
            {
                throw new ArgumentOutOfRangeException(nameof(response), "Response must be 16 bytes.");
            }

            if (passwordChallenge == null)
            {
                throw new ArgumentNullException(nameof(passwordChallenge));
            }

            this.challenge         = challenge;
            this.response          = response;
            this.passwordChallenge = passwordChallenge;
        }
Beispiel #2
0
        public LibVncServer(IVncFramebufferSource framebufferSource, IVncRemoteKeyboard keyboard, IVncRemoteController controller, ILogger logger)
        {
            this.fbSource   = framebufferSource ?? throw new ArgumentNullException(nameof(framebufferSource));
            this.keyboard   = keyboard;
            this.controller = controller;

            this.logger            = logger ?? throw new ArgumentNullException(nameof(logger));
            this.passwordChallenge = new VncPasswordChallenge();

            this.newClientHook  = new NativeMethods.RfbNewClientHookPtr(this.RfbNewClientHook);
            this.clientGoneHook = new NativeMethods.ClientGoneHookPtr(this.ClientGoneHook);
            this.clientFramebufferUpdateRequestHook = new NativeMethods.ClientFramebufferUpdateRequestHookPtr(this.ClientFramebufferUpdateRequestHook);
            this.rfbKbdAddEventHook   = new NativeMethods.RfbKbdAddEventProcPtr(this.RfbKbdAddEventHook);
            this.rfbPtrAddEventProc   = new NativeMethods.RfbPtrAddEventProcPtr(this.RfbPtrAddEventHook);
            this.rfbPasswordCheckProc = new NativeMethods.rfbPasswordCheckProcPtr(this.RfbPasswordCheckHook);

            this.newClientHookPtr  = Marshal.GetFunctionPointerForDelegate(this.newClientHook);
            this.clientGoneHookPtr = Marshal.GetFunctionPointerForDelegate(this.clientGoneHook);
            this.clientFramebufferUpdateRequestHookPtr = Marshal.GetFunctionPointerForDelegate(this.clientFramebufferUpdateRequestHook);
            this.rfbKbdAddEventHookPtr   = Marshal.GetFunctionPointerForDelegate(this.rfbKbdAddEventHook);
            this.rfbPtrAddEventProcPtr   = Marshal.GetFunctionPointerForDelegate(this.rfbPtrAddEventProc);
            this.rfbPasswordCheckProcPtr = Marshal.GetFunctionPointerForDelegate(this.rfbPasswordCheckProc);

#if !NETSTANDARD2_0 && !NET45
            NativeLogging.Logger = logger;
#endif
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VncClient"/> class.
        /// </summary>
        /// <param name="passwordChallenge">
        /// A <see cref="IVncPasswordChallenge"/> which can generate password challenges.
        /// </param>
        public VncClient(IVncPasswordChallenge passwordChallenge)
        {
            if (passwordChallenge == null)
            {
                throw new ArgumentNullException(nameof(passwordChallenge));
            }

            this.passwordChallenge = passwordChallenge;
            this.MaxUpdateRate     = 15;
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VncServerSession"/> class.
        /// </summary>
        /// <param name="passwordChallenge">
        /// The <see cref="IVncPasswordChallenge"/> to use to generate password challenges.
        /// </param>
        /// <param name="logger">
        /// The logger to use when logging diagnostic messages.
        /// </param>
        public VncServerSession(IVncPasswordChallenge passwordChallenge, ILog logger)
        {
            if (passwordChallenge == null)
            {
                throw new ArgumentNullException(nameof(passwordChallenge));
            }

            this.passwordChallenge = passwordChallenge;
            this.logger            = logger;
            this.MaxUpdateRate     = 15;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VncServerSession"/> class.
        /// </summary>
        /// <param name="passwordChallenge">
        /// The <see cref="IVncPasswordChallenge"/> to use to generate password challenges.
        /// </param>
        /// <param name="logger">
        /// The logger to use when logging diagnostic messages.
        /// </param>
        public VncServerSession(IVncPasswordChallenge passwordChallenge, ILog logger)
        {
            if (passwordChallenge == null)
            {
                throw new ArgumentNullException(nameof(passwordChallenge));
            }

            this.passwordChallenge = passwordChallenge;
            this.logger            = logger;
            this.MaxUpdateRate     = 15;

            this.Encoders.Add(new TightEncoder(this));
            this.Encoders.Add(new ZlibEncoder());
        }