Exemplo n.º 1
0
        void WebRequestDispatcher(HttpListenerContext context)
        {
            var request = context.Request;

            // e.g. http://localhost:3000/pac/?&port=5678&ip=1.2.3.4&proto=socks&type=whitelist&key=rnd
            var reqUrl      = request.Url.AbsoluteUri;
            var queryParams = Lib.Utils.GetQureryParamsFrom(reqUrl);

            var bs        = setting.GetBasicSetting();
            var defValues = new Model.Data.QueryParams(bs);

            queryParams.ReplaceNullValueWith(defValues);
            var pacParams = queryParams.ToPacUrlParams();

            var pacResp = pacGenerator.GenPacFileResponse(
                bs.isUseCustomPac,
                pacParams,
                setting.GetCustomPacSetting(),
                customPacFileCache);

            var response = context.Response;

            if (!pacParams.isDebug)
            {
                Write(response, pacResp.Item1, pacResp.Item2);
                return;
            }

            var debugResp = GenPacDebuggerResponse(
                GenPrefix(bs.pacServPort),
                pacResp.Item1);

            Write(response, debugResp.Item1, debugResp.Item2);
        }
Exemplo n.º 2
0
        private static Model.Data.PacUrlParams GenReqParamFromUrl(
            string reqUrl,
            Model.Data.BasicSettings bs)
        {
            // e.g. http://localhost:3000/pac/?&port=5678&ip=1.2.3.4&proto=socks&type=whitelist&key=rnd
            var queryParams = Misc.Utils.GetQureryParamsFrom(reqUrl);
            var defValues   = new Model.Data.QueryParams(bs);

            queryParams.ReplaceNullValueWith(defValues);
            var pacParams = queryParams.ToPacUrlParams();

            return(pacParams);
        }