Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Sep 26, 2017
1 parent f2187c5 commit 7ab4027
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ArchiSteamFarm/GlobalConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ internal sealed class GlobalConfig {
[JsonProperty(Required = Required.DisallowNull)]
internal readonly bool Statistics = true;

[JsonProperty(Required = Required.DisallowNull)]
internal readonly ProtocolTypes SteamProtocols = ProtocolTypes.Tcp;

[JsonProperty(Required = Required.DisallowNull)]
internal readonly EUpdateChannel UpdateChannel = EUpdateChannel.Stable;

Expand All @@ -125,6 +122,9 @@ internal string SSteamOwnerID {
[JsonProperty(Required = Required.DisallowNull)]
internal ulong SteamOwnerID { get; private set; }

[JsonProperty(Required = Required.DisallowNull)]
internal ProtocolTypes SteamProtocols { get; private set; } = ProtocolTypes.Tcp;

// This constructor is used only by deserializer
private GlobalConfig() { }

Expand Down Expand Up @@ -174,6 +174,13 @@ internal static GlobalConfig Load(string filePath) {
return null;
}

if (globalConfig.SteamProtocols.HasFlag(ProtocolTypes.WebSocket) && !OS.SupportsWebSockets()) {
globalConfig.SteamProtocols &= ProtocolTypes.WebSocket;
if (globalConfig.SteamProtocols == 0) {
globalConfig.SteamProtocols = ProtocolTypes.Tcp;
}
}

GlobalConfig result = globalConfig;
return result;
}
Expand Down
12 changes: 12 additions & 0 deletions ArchiSteamFarm/OS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ limitations under the License.

using System;
using System.IO;
using System.Net.WebSockets;
using System.Runtime.InteropServices;
using ArchiSteamFarm.Localization;

Expand All @@ -45,6 +46,17 @@ internal static void Init(bool headless) {
}
}

// TODO: We should really get rid of this once https://github.com/SteamRE/SteamKit/issues/455 or https://github.com/dotnet/corefx/issues/9503 is solved
internal static bool SupportsWebSockets() {
try {
using (new ClientWebSocket()) {
return true;
}
} catch (PlatformNotSupportedException) {
return false;
}
}

internal static void UnixSetFileAccessExecutable(string path) {
if (string.IsNullOrEmpty(path) || !File.Exists(path)) {
ASF.ArchiLogger.LogNullError(nameof(path));
Expand Down

0 comments on commit 7ab4027

Please sign in to comment.