Host checking implemented

main
Inga 🏳‍🌈 14 years ago
parent d5177a4ecb
commit b129c61946
  1. 2
      Builder/IISMainHandler/build.txt
  2. 14
      IISMainHandler/MainHandler.cs

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Web; using System.Web;
using System.Configuration; using System.Configuration;
using FLocal.Common;
namespace FLocal.IISHandler { namespace FLocal.IISHandler {
public class MainHandler : IHttpHandler { public class MainHandler : IHttpHandler {
@ -19,14 +20,19 @@ namespace FLocal.IISHandler {
throw new HttpException(403, "You have come from the static page '" + referer + "'"); throw new HttpException(403, "You have come from the static page '" + referer + "'");
} }
if(!FLocal.Common.Config.isInitialized) { if(!Config.isInitialized) {
lock(typeof(FLocal.Common.Config)) { lock(typeof(Config)) {
if(!FLocal.Common.Config.isInitialized) { if(!Config.isInitialized) {
FLocal.Common.Config.Init(ConfigurationManager.AppSettings); Config.Init(ConfigurationManager.AppSettings);
} }
} }
} }
Uri current = httpcontext.Request.Url;
if(!current.Host.EndsWith(Config.instance.BaseHost)) {
throw new FLocal.Core.FLocalException("Wrong host: " + current.Host + " (expected *" + Config.instance.BaseHost + ")");
}
WebContext context = new WebContext(httpcontext); WebContext context = new WebContext(httpcontext);
try { try {
ISpecificHandler handler = HandlersFactory.getHandler(context); ISpecificHandler handler = HandlersFactory.getHandler(context);

Loading…
Cancel
Save