It can actually take screenshots of the VM
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using RemoteFrameBuffer.Common;
|
||||
using System.Text;
|
||||
|
||||
namespace RemoteFrameBuffer.Client
|
||||
{
|
||||
@@ -8,15 +9,42 @@ namespace RemoteFrameBuffer.Client
|
||||
|
||||
public RemoteFrameBufferClientProtocol_3_3(Stream s) : base(s)
|
||||
{
|
||||
this.Phase = RfbClientProtocolPhase.Constructed;
|
||||
}
|
||||
|
||||
public override void Handshake()
|
||||
public override void Handshake(CancellationToken token)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Initialization()
|
||||
{
|
||||
|
||||
if (this.Phase != RfbClientProtocolPhase.Constructed)
|
||||
{
|
||||
throw new InvalidOperationException("In wrong phase when calling Handshake");
|
||||
}
|
||||
this.Phase = RfbClientProtocolPhase.Handshake;
|
||||
Byte[] buf;
|
||||
// Request protocol version
|
||||
this.vncStream.Write(Encoding.ASCII.GetBytes("RFB 003.003\n"));
|
||||
// Read security type
|
||||
buf = new Byte[4];
|
||||
CancellationTokenSource readTimeout = new CancellationTokenSource(TimeSpan.FromSeconds(5));
|
||||
CancellationTokenSource readTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token, readTimeout.Token);
|
||||
this.vncStream.ReadExactlyAsync(buf, 0, buf.Length, readTokenSource.Token).AsTask().Wait();
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
Array.Reverse(buf);
|
||||
}
|
||||
this.SecurityType = (RemoteFramebufferSecurityType)BitConverter.ToUInt32(buf, 0);
|
||||
Console.Error.WriteLine($"Server uses security type {this.SecurityType}");
|
||||
switch (this.SecurityType)
|
||||
{
|
||||
case RemoteFramebufferSecurityType.Invalid:
|
||||
throw new Exception("Connection failed");
|
||||
case RemoteFramebufferSecurityType.None:
|
||||
break;// RFB 3.3 straight up jumps to initialization here
|
||||
case RemoteFramebufferSecurityType.VncAuthentication:
|
||||
throw new NotImplementedException("VNC Authentication is not implemented");
|
||||
default:
|
||||
throw new NotSupportedException("RFB version 3.3 doesn't support the security type returned by the server");
|
||||
}
|
||||
this.Phase = RfbClientProtocolPhase.HandshakeDone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user