Skip to content

Commit

Permalink
Closes #373
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Dec 11, 2016
1 parent 9d0cc07 commit cf4e917
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ArchiSteamFarm/GlobalConfig.cs
Expand Up @@ -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() { }
Expand Down
2 changes: 1 addition & 1 deletion ArchiSteamFarm/Program.cs
Expand Up @@ -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 + "\": ");
Expand Down
20 changes: 10 additions & 10 deletions ArchiSteamFarm/WCF.cs
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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!");
Expand Down
2 changes: 1 addition & 1 deletion ArchiSteamFarm/config/ASF.json
Expand Up @@ -15,7 +15,7 @@
"MaxTradeHoldDuration": 15,
"ForceHttp": false,
"HttpTimeout": 60,
"WCFHostname": "localhost",
"WCFHost": "127.0.0.1",
"WCFPort": 1242,
"Statistics": true,
"Blacklist": [
Expand Down

0 comments on commit cf4e917

Please sign in to comment.