From c13eb02e5166d042cb61727943cf8057661e1d11 Mon Sep 17 00:00:00 2001 From: stackia Date: Thu, 28 Jul 2016 20:34:35 +0800 Subject: [PATCH 1/2] Add an option to switch WCF metadata publishing --- ArchiSteamFarm/GlobalConfig.cs | 5 ++++- ArchiSteamFarm/WCF.cs | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index ae589eeea..b834fa447 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -105,7 +105,10 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] internal readonly ushort WCFPort = DefaultWCFPort; - [JsonProperty(Required = Required.DisallowNull)] + [JsonProperty(Required = Required.DisallowNull)] + internal readonly bool WCFPublishMetadata = false; + + [JsonProperty(Required = Required.DisallowNull)] internal readonly bool Statistics = true; [JsonProperty(Required = Required.DisallowNull)] diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index 65974f808..dec15fb76 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -26,6 +26,7 @@ using System; using System.Linq; using System.ServiceModel; using System.ServiceModel.Channels; +using System.ServiceModel.Description; namespace ArchiSteamFarm { [ServiceContract] @@ -87,8 +88,17 @@ namespace ArchiSteamFarm { } Logging.LogGenericInfo("Starting WCF server..."); - ServiceHost = new ServiceHost(typeof(WCF)); - ServiceHost.AddServiceEndpoint(typeof(IWCF), new BasicHttpBinding(), URL); + ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL)); + if (Program.GlobalConfig.WCFPublishMetadata) + { + ServiceHost.Description.Behaviors.Add(new ServiceMetadataBehavior + { + HttpGetEnabled = true + }); + ServiceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, + MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); + } + ServiceHost.AddServiceEndpoint(typeof(IWCF), new BasicHttpBinding(), string.Empty); try { ServiceHost.Open(); From 8208e9aa77d215f139097d057f0981b3313b8fc8 Mon Sep 17 00:00:00 2001 From: stackia Date: Thu, 28 Jul 2016 23:58:25 +0800 Subject: [PATCH 2/2] Remove the WCFPublishMetadata config option, make it always on --- ArchiSteamFarm/GlobalConfig.cs | 3 --- ArchiSteamFarm/WCF.cs | 13 +++++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index b834fa447..4cbbb3f4b 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -105,9 +105,6 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] internal readonly ushort WCFPort = DefaultWCFPort; - [JsonProperty(Required = Required.DisallowNull)] - internal readonly bool WCFPublishMetadata = false; - [JsonProperty(Required = Required.DisallowNull)] internal readonly bool Statistics = true; diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index dec15fb76..6dfd570f9 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -89,15 +89,12 @@ namespace ArchiSteamFarm { Logging.LogGenericInfo("Starting WCF server..."); ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL)); - if (Program.GlobalConfig.WCFPublishMetadata) + ServiceHost.Description.Behaviors.Add(new ServiceMetadataBehavior { - ServiceHost.Description.Behaviors.Add(new ServiceMetadataBehavior - { - HttpGetEnabled = true - }); - ServiceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, - MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); - } + HttpGetEnabled = true + }); + ServiceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, + MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); ServiceHost.AddServiceEndpoint(typeof(IWCF), new BasicHttpBinding(), string.Empty); try {