Hosts config sertting implemented

main
Inga 🏳‍🌈 14 years ago
parent a5f83ccdd9
commit f44797c027
  1. 2
      Builder/IISMainHandler/build.txt
  2. 16
      Common/BBCodes/helpers/UrlProcessor.cs
  3. 6
      Common/Config.cs

@ -27,20 +27,6 @@ namespace FLocal.Common.BBCodes {
return System.Web.HttpUtility.HtmlEncode(str);
}
public static HashSet<string> KnownAliases = new HashSet<string> {
"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());

@ -33,6 +33,10 @@ namespace FLocal.Common {
public readonly bool IsMigrationEnabled;
public readonly string BaseHost;
public readonly HashSet<string> 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<string>(from host in data["AdditionalHosts"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) select host.Trim());
}
public static void Init(NameValueCollection data) {

Loading…
Cancel
Save