From d322c315dda050d95567edcfcb1855c69b214b99 Mon Sep 17 00:00:00 2001 From: Elijah R Date: Wed, 24 Apr 2024 16:20:35 -0400 Subject: [PATCH] add configurable headers, bump v --- CollabVMSharp/CollabVMClient.cs | 7 ++++++- CollabVMSharp/CollabVMSharp.csproj | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CollabVMSharp/CollabVMClient.cs b/CollabVMSharp/CollabVMClient.cs index 2d36a80..0bfec87 100644 --- a/CollabVMSharp/CollabVMClient.cs +++ b/CollabVMSharp/CollabVMClient.cs @@ -42,6 +42,7 @@ public class CollabVMClient { private Dictionary> commandsSeparatedArgs; private Dictionary> commandsOneArg; private bool _usesAccountAuth; + private Dictionary _headers; // Tasks and related private TaskCompletionSource GotNodeList; private TaskCompletionSource GotConnectionToNode; @@ -91,7 +92,8 @@ public class CollabVMClient { /// Username to join the VM as. If null, the server will assign a guest name. /// Node to connect to. If null, a VM will not be automatically joined. /// HTTP proxy to connect with. If null, a proxy will not be used. - public CollabVMClient(string url, string? username = null, string? node = null, string? proxy = null) { + /// Additional headers to use when connecting to the server. + public CollabVMClient(string url, string? username = null, string? node = null, string? proxy = null, Dictionary? headers = null) { if (!Uri.TryCreate(url, UriKind.Absolute, out this.url)) { throw new UriFormatException("An invalid URI string was passed."); } @@ -110,6 +112,8 @@ public class CollabVMClient { this.framebuffer = new Image(1, 1); this.socket = new(); this.socket.Options.AddSubProtocol("guacamole"); + this._headers = headers ?? new(); + foreach (var header in _headers) this.socket.Options.SetRequestHeader(header.Key, header.Value); this.socket.Options.SetRequestHeader("Origin", "https://computernewb.com"); if (proxy != null) { this._proxy = new WebProxy(proxy); @@ -510,6 +514,7 @@ public class CollabVMClient { this.NOPRecieve.Interval = 10000; this.socket = new(); this.socket.Options.AddSubProtocol("guacamole"); + foreach (var header in _headers) this.socket.Options.SetRequestHeader(header.Key, header.Value); this.socket.Options.SetRequestHeader("Origin", "https://computernewb.com"); if (_proxy != null) { this.socket.Options.Proxy = this._proxy; diff --git a/CollabVMSharp/CollabVMSharp.csproj b/CollabVMSharp/CollabVMSharp.csproj index 565f759..93edc20 100644 --- a/CollabVMSharp/CollabVMSharp.csproj +++ b/CollabVMSharp/CollabVMSharp.csproj @@ -3,7 +3,7 @@ net6.0 10 - 2.5.0 + 2.6.0 True CollabVMSharp