Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
feat: adding option to allow for tls outside of the transport
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Frowen committed Dec 7, 2020
1 parent 5deec82 commit bebeb0e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/SimpleWebTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class SimpleWebTransport : Transport


[Header("Ssl Settings")]
[Tooltip("Sets connect scheme to wss. Useful when client needs to connect using wss when TLS is outside of transport, NOTE: if sslEnabled is true clientUseWss is also true")]
bool clientUseWss;

public bool sslEnabled;
[Tooltip("Path to json file that contains path to cert and its password\n\nUse Json file so that cert password is not included in client builds\n\nSee cert.example.Json")]
public string sslCertJson = "./cert.json";
Expand Down Expand Up @@ -126,7 +129,8 @@ public void ProcessMessages()
}

#region Client
string GetScheme() => sslEnabled ? SecureScheme : NormalScheme;
string GetClientScheme() => (sslEnabled || clientUseWss) ? SecureScheme : NormalScheme;
string GetServerScheme() => sslEnabled ? SecureScheme : NormalScheme;
public override bool ClientConnected()
{
// not null and not NotConnected (we want to return true if connecting or disconnecting)
Expand All @@ -144,7 +148,7 @@ public override void ClientConnect(string hostname)

UriBuilder builder = new UriBuilder
{
Scheme = GetScheme(),
Scheme = GetClientScheme(),
Host = hostname,
Port = port
};
Expand Down Expand Up @@ -335,7 +339,7 @@ public override Uri ServerUri()
{
UriBuilder builder = new UriBuilder
{
Scheme = GetScheme(),
Scheme = GetServerScheme(),
Host = Dns.GetHostName(),
Port = port
};
Expand Down

0 comments on commit bebeb0e

Please sign in to comment.