From f44797c027ab9fc94c260e1ddf13628fc107676e Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Mon, 13 Dec 2010 12:35:05 +0000 Subject: [PATCH] Hosts config sertting implemented --- Builder/IISMainHandler/build.txt | 2 +- Common/BBCodes/helpers/UrlProcessor.cs | 16 +--------------- Common/Config.cs | 6 ++++++ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index a1b04e2..34f7d67 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -1814 \ No newline at end of file +1818 \ No newline at end of file diff --git a/Common/BBCodes/helpers/UrlProcessor.cs b/Common/BBCodes/helpers/UrlProcessor.cs index c88d74d..55fb547 100644 --- a/Common/BBCodes/helpers/UrlProcessor.cs +++ b/Common/BBCodes/helpers/UrlProcessor.cs @@ -27,20 +27,6 @@ namespace FLocal.Common.BBCodes { return System.Web.HttpUtility.HtmlEncode(str); } - public static HashSet KnownAliases = new HashSet { - "forum.local", - "forum.b.gz.ru", - "www.snto-msu.net", - "hq.sectorb.msk.ru", - "petaflop.b.gz.ru", - "194.88.210.5", - "forumlocal.ru", - "forumbgz.ru", - "forum.hn", - }; - - public const string DOMAIN = ".forum.hn"; - public static UrlInfo Process(string url) { if (url.StartsWith("/")) { return new UrlInfo(true, url); @@ -51,7 +37,7 @@ namespace FLocal.Common.BBCodes { } catch(UriFormatException) { throw new Core.FLocalException("wrong url: " + url); } - if (KnownAliases.Contains(uri.Host.ToLower()) || uri.Host.ToLower().EndsWith(DOMAIN)) { + if (Config.instance.AdditionalHosts.Contains(uri.Host.ToLower()) || uri.Host.ToLower().EndsWith(Config.instance.BaseHost)) { return new UrlInfo(true, uri.PathAndQuery); } else { return new UrlInfo(false, uri.ToString()); diff --git a/Common/Config.cs b/Common/Config.cs index 59eefb9..ffbdab3 100644 --- a/Common/Config.cs +++ b/Common/Config.cs @@ -33,6 +33,10 @@ namespace FLocal.Common { public readonly bool IsMigrationEnabled; + public readonly string BaseHost; + + public readonly HashSet AdditionalHosts; + protected Config(NameValueCollection data) : base(data) { this.InitTime = DateTime.Now.ToLongTimeString(); this.mainConnection = new MySQLConnector.Connection(data["ConnectionString"], MySQLConnector.PostgresDBTraits.instance); @@ -46,6 +50,8 @@ namespace FLocal.Common { this.ActivityThreshold = TimeSpan.FromMinutes(int.Parse(data["ActivityThreshold"])); this.IsIndexingDisabled = parseBool(data["DisableIndexing"]); this.IsMigrationEnabled = parseBool(data["EnableMigration"]); + this.BaseHost = data["BaseHost"]; + this.AdditionalHosts = new HashSet(from host in data["AdditionalHosts"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) select host.Trim()); } public static void Init(NameValueCollection data) {