Exemple #1
0
        public string GetCurPacFileContent()
        {
            var bs        = setting.GetBasicSetting();
            var url       = VgcApis.Models.Consts.Webs.FakeRequestUrl;
            var reqParams = GenReqParamFromUrl(url, bs);

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

            return(pacResp.Item1);
        }
Exemple #2
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);
        }