diff --git a/ArchiSteamFarm.sln.DotSettings b/ArchiSteamFarm.sln.DotSettings
index fbe580cb6..bc27bc35a 100644
--- a/ArchiSteamFarm.sln.DotSettings
+++ b/ArchiSteamFarm.sln.DotSettings
@@ -324,6 +324,7 @@
AES
API
ASF
+ EWCF
FA
FS
HTML
@@ -337,6 +338,7 @@
TTL
URL
WCF
+ WS
WTF
XML
<Policy Inspect="True" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="I" Suffix="" Style="AaBb" /></Policy>
diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs
index 92577031a..b95ca8b31 100644
--- a/ArchiSteamFarm/GlobalConfig.cs
+++ b/ArchiSteamFarm/GlobalConfig.cs
@@ -38,10 +38,6 @@ namespace ArchiSteamFarm {
internal const byte DefaultConnectionTimeout = 60;
internal const ushort DefaultWCFPort = 1242;
- private const byte DefaultFarmingDelay = 15;
- private const byte DefaultMaxFarmingTime = 10;
- private const ProtocolType DefaultSteamProtocol = ProtocolType.Tcp;
-
// This is hardcoded blacklist which should not be possible to change
internal static readonly HashSet GlobalBlacklist = new HashSet { 267420, 303700, 335590, 368020, 425280, 480730, 566020 };
@@ -64,7 +60,7 @@ namespace ArchiSteamFarm {
internal readonly bool Debug = false;
[JsonProperty(Required = Required.DisallowNull)]
- internal readonly byte FarmingDelay = DefaultFarmingDelay;
+ internal readonly byte FarmingDelay = 15;
[JsonProperty(Required = Required.DisallowNull)]
internal readonly byte GiftsLimiterDelay = 1;
@@ -82,7 +78,7 @@ namespace ArchiSteamFarm {
internal readonly byte LoginLimiterDelay = 10;
[JsonProperty(Required = Required.DisallowNull)]
- internal readonly byte MaxFarmingTime = DefaultMaxFarmingTime;
+ internal readonly byte MaxFarmingTime = 10;
[JsonProperty(Required = Required.DisallowNull)]
internal readonly byte MaxTradeHoldDuration = 15;
@@ -97,16 +93,19 @@ namespace ArchiSteamFarm {
internal readonly ulong SteamOwnerID = 0;
[JsonProperty(Required = Required.DisallowNull)]
- internal readonly ProtocolType SteamProtocol = DefaultSteamProtocol;
+ internal readonly ProtocolType SteamProtocol = ProtocolType.Tcp;
[JsonProperty(Required = Required.DisallowNull)]
internal readonly EUpdateChannel UpdateChannel = EUpdateChannel.Stable;
+ [JsonProperty]
+ internal string WCFHost { get; set; } = "127.0.0.1";
+
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ushort WCFPort = DefaultWCFPort;
- [JsonProperty]
- internal string WCFHost { get; set; } = "127.0.0.1";
+ [JsonProperty(Required = Required.DisallowNull)]
+ internal readonly EWCFProtocol WCFProtocol = EWCFProtocol.NetTcp;
// This constructor is used only by deserializer
private GlobalConfig() { }
@@ -182,5 +181,12 @@ namespace ArchiSteamFarm {
Stable,
Experimental
}
+
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
+ internal enum EWCFProtocol : byte {
+ NetTcp,
+ BasicHttp,
+ WSHttp
+ }
}
}
\ No newline at end of file
diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs
index 00a9f9f30..f88975e56 100644
--- a/ArchiSteamFarm/WCF.cs
+++ b/ArchiSteamFarm/WCF.cs
@@ -39,8 +39,6 @@ namespace ArchiSteamFarm {
}
internal sealed class WCF : IWCF, IDisposable {
- private static string URL = "net.tcp://127.0.0.1:1242/ASF";
-
internal bool IsServerRunning => ServiceHost != null;
private Client Client;
@@ -81,12 +79,7 @@ namespace ArchiSteamFarm {
internal static void Init() {
if (string.IsNullOrEmpty(Program.GlobalConfig.WCFHost)) {
Program.GlobalConfig.WCFHost = Program.GetUserInput(ASF.EUserInputType.WCFHostname);
- if (string.IsNullOrEmpty(Program.GlobalConfig.WCFHost)) {
- return;
- }
}
-
- URL = "net.tcp://" + Program.GlobalConfig.WCFHost + ":" + Program.GlobalConfig.WCFPort + "/ASF";
}
internal string SendCommand(string input) {
@@ -95,17 +88,24 @@ namespace ArchiSteamFarm {
return null;
}
- ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFSendingCommand, input, URL));
+ Binding binding = GetTargetBinding();
+ if (binding == null) {
+ ASF.ArchiLogger.LogNullError(nameof(binding));
+ return null;
+ }
+
+ string url = GetUrlFromBinding(binding);
+ if (string.IsNullOrEmpty(url)) {
+ ASF.ArchiLogger.LogNullError(nameof(url));
+ return null;
+ }
+
+ ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFSendingCommand, input, url));
if (Client == null) {
Client = new Client(
- new NetTcpBinding {
- // We use SecurityMode.None for Mono compatibility
- // Yes, also on Windows, for Mono<->Windows communication
- Security = { Mode = SecurityMode.None },
- SendTimeout = new TimeSpan(0, 0, Program.GlobalConfig.ConnectionTimeout)
- },
- new EndpointAddress(URL)
+ binding,
+ new EndpointAddress(url)
);
}
@@ -117,20 +117,28 @@ namespace ArchiSteamFarm {
return;
}
- ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFStarting, URL));
+ Binding binding = GetTargetBinding();
+ if (binding == null) {
+ ASF.ArchiLogger.LogNullError(nameof(binding));
+ return;
+ }
+
+ string url = GetUrlFromBinding(binding);
+ if (string.IsNullOrEmpty(url)) {
+ ASF.ArchiLogger.LogNullError(nameof(url));
+ return;
+ }
+
+ ASF.ArchiLogger.LogGenericInfo(string.Format(Strings.WCFStarting, url));
try {
- ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL));
+ ServiceHost = new ServiceHost(typeof(WCF), new Uri(url));
ServiceHost.AddServiceEndpoint(
typeof(IWCF),
- new NetTcpBinding {
- // We use SecurityMode.None for Mono compatibility
- // Yes, also on Windows, for Mono<->Windows communication
- Security = { Mode = SecurityMode.None },
- SendTimeout = new TimeSpan(0, 0, Program.GlobalConfig.ConnectionTimeout)
- },
+ binding,
string.Empty
);
+
ServiceHost.Open();
ASF.ArchiLogger.LogGenericInfo(Strings.WCFReady);
@@ -157,6 +165,46 @@ namespace ArchiSteamFarm {
ServiceHost = null;
}
+ private static string GetUrlFromBinding(Binding binding) {
+ if (binding != null) {
+ return binding.Scheme + "://" + Program.GlobalConfig.WCFHost + ":" + Program.GlobalConfig.WCFPort + "/ASF";
+ }
+
+ ASF.ArchiLogger.LogNullError(nameof(binding));
+ return null;
+ }
+
+ private static Binding GetTargetBinding() {
+ Binding result;
+ switch (Program.GlobalConfig.WCFProtocol) {
+ case GlobalConfig.EWCFProtocol.NetTcp:
+ result = new NetTcpBinding {
+ // We use SecurityMode.None for Mono compatibility
+ // Yes, also on Windows, for Mono<->Windows communication
+ Security = { Mode = SecurityMode.None }
+ };
+
+ break;
+ case GlobalConfig.EWCFProtocol.BasicHttp:
+ result = new BasicHttpBinding();
+ break;
+ case GlobalConfig.EWCFProtocol.WSHttp:
+ result = new WSHttpBinding {
+ // We use SecurityMode.None for Mono compatibility
+ // Yes, also on Windows, for Mono<->Windows communication
+ Security = { Mode = SecurityMode.None }
+ };
+
+ break;
+ default:
+ ASF.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(Program.GlobalConfig.WCFProtocol), Program.GlobalConfig.WCFProtocol));
+ goto case GlobalConfig.EWCFProtocol.NetTcp;
+ }
+
+ result.SendTimeout = new TimeSpan(0, 0, Program.GlobalConfig.ConnectionTimeout);
+ return result;
+ }
+
private void StopClient() {
if (Client == null) {
return;
diff --git a/ArchiSteamFarm/config/ASF.json b/ArchiSteamFarm/config/ASF.json
index 5391e558e..0648d2693 100644
--- a/ArchiSteamFarm/config/ASF.json
+++ b/ArchiSteamFarm/config/ASF.json
@@ -27,5 +27,6 @@
"SteamProtocol": 6,
"UpdateChannel": 1,
"WCFHost": "127.0.0.1",
- "WCFPort": 1242
+ "WCFPort": 1242,
+ "WCFProtocol": 0
}
\ No newline at end of file