diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index b19d4c6bb2ee6..4807a7ceb2280 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -102,7 +102,7 @@ internal sealed class GlobalConfig { internal readonly ushort WCFPort = DefaultWCFPort; [JsonProperty] - internal string WCFHostname { get; set; } = "localhost"; + internal string WCFHost { get; set; } = "127.0.0.1"; // This constructor is used only by deserializer private GlobalConfig() { } diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index a35d6e7737f3c..070b5f9569c15 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -96,7 +96,7 @@ internal static class Program { Console.Write("<" + botName + "> Please enter your 2 factor auth code from your authenticator app: "); break; case ASF.EUserInputType.WCFHostname: - Console.Write("<" + botName + "> Please enter your WCF hostname: "); + Console.Write("<" + botName + "> Please enter your WCF host: "); break; default: Console.Write("<" + botName + "> Please enter not documented yet value of \"" + userInputType + "\": "); diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index 00417686b272a..f9fd16cbaf5c6 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -39,7 +39,7 @@ internal interface IWCF { } internal sealed class WCF : IWCF, IDisposable { - private static string URL = "http://localhost:1242/ASF"; + private static string URL = "net.tcp://127.0.0.1:1242/ASF"; internal bool IsServerRunning => ServiceHost != null; @@ -76,14 +76,14 @@ internal sealed class WCF : IWCF, IDisposable { } internal static void Init() { - if (string.IsNullOrEmpty(Program.GlobalConfig.WCFHostname)) { - Program.GlobalConfig.WCFHostname = Program.GetUserInput(ASF.EUserInputType.WCFHostname); - if (string.IsNullOrEmpty(Program.GlobalConfig.WCFHostname)) { + if (string.IsNullOrEmpty(Program.GlobalConfig.WCFHost)) { + Program.GlobalConfig.WCFHost = Program.GetUserInput(ASF.EUserInputType.WCFHostname); + if (string.IsNullOrEmpty(Program.GlobalConfig.WCFHost)) { return; } } - URL = "http://" + Program.GlobalConfig.WCFHostname + ":" + Program.GlobalConfig.WCFPort + "/ASF"; + URL = "net.tcp://" + Program.GlobalConfig.WCFHost + ":" + Program.GlobalConfig.WCFPort + "/ASF"; } internal string SendCommand(string input) { @@ -93,7 +93,7 @@ internal sealed class WCF : IWCF, IDisposable { } if (Client == null) { - Client = new Client(new BasicHttpBinding(), new EndpointAddress(URL)); + Client = new Client(new NetTcpBinding(), new EndpointAddress(URL)); } return Client.HandleCommand(input); @@ -104,15 +104,15 @@ internal sealed class WCF : IWCF, IDisposable { return; } - ASF.ArchiLogger.LogGenericInfo("Starting WCF server..."); + ASF.ArchiLogger.LogGenericInfo("Starting WCF server on " + URL + " ..."); try { ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL)); - ServiceHost.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true }); + ServiceHost.Description.Behaviors.Add(new ServiceMetadataBehavior()); - ServiceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); - ServiceHost.AddServiceEndpoint(typeof(IWCF), new BasicHttpBinding(), string.Empty); + ServiceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexTcpBinding(), "mex"); + ServiceHost.AddServiceEndpoint(typeof(IWCF), new NetTcpBinding(), string.Empty); ServiceHost.Open(); ASF.ArchiLogger.LogGenericInfo("WCF server ready!"); diff --git a/ArchiSteamFarm/config/ASF.json b/ArchiSteamFarm/config/ASF.json index 46ea6d8d1350d..acfb958c61f96 100644 --- a/ArchiSteamFarm/config/ASF.json +++ b/ArchiSteamFarm/config/ASF.json @@ -15,7 +15,7 @@ "MaxTradeHoldDuration": 15, "ForceHttp": false, "HttpTimeout": 60, - "WCFHostname": "localhost", + "WCFHost": "127.0.0.1", "WCFPort": 1242, "Statistics": true, "Blacklist": [