private bool Handle(HttpListenerContext context)
        {
            context.Response.StatusCode = 200;
            context.Response.Headers.Add(Constants.HeaderAccessControlAllowOrigin);
            context.Response.Headers.Add("Server", $"RemoteFork/1.3a");

            string httpUrl = context.Request.RawUrl;

            Console.WriteLine("URL:" + httpUrl);
            if (httpUrl.IndexOf("/treeview") == 0)
            {
                if (context.Request.QueryString.GetValues(null)?.FirstOrDefault(s => PluginRequestHandler.PluginParamRegex.IsMatch(s ?? string.Empty)) != null)
                {
                    var Handler = new PluginRequestHandler();
                    Handler.Handle(context);
                }
                else
                {
                    var Handler = new RootRequestHandler();
                    Handler.Handle(context);
                }
            }
            else if (httpUrl.IndexOf("/proxym3u8") == 0)
            {
                var Handler = new ProxyM3u8();
                Handler.Handle(context, true);
            }
            else
            {
                if (httpUrl.StartsWith("/parserlink"))
                {
                    var Handler = new ParseLinkRequestHandler();
                    Handler.Handle(context, true);
                }
                else
                {
                    if (httpUrl.StartsWith("/test"))
                    {
                        var Handler = new TestRequestHandler();
                        Handler.Handle(context, true);
                    }
                }
            }
            return(true);
        }
示例#2
0
 public ActionResult Parserlink()
 {
     HttpContext.Response.Headers["Access-Control-Allow-Origin"] = "*";
     ViewData["Message"] = new ParseLinkRequestHandler().Handle(HttpContext);
     return(View());
 }