private async Task <IExternalProxy> OnGetCustomUpStreamProxyFunc(SessionEventArgsBase arg)
        {
            arg.GetState().PipelineInfo.AppendLine(nameof(OnGetCustomUpStreamProxyFunc));


            //await writeToConsole(arg.WebSession.Request.Headers);
            if (arg.WebSession.Request.Headers.HeaderExists("x-forwarded-host"))
            {
                var host = arg.WebSession.Request.Headers.GetHeaders("x-forwarded-host")[0].Value;
                var port = Int32.Parse(arg.WebSession.Request.Headers.GetHeaders("x-forwarded-port")[0].Value);

                return(new ExternalProxy
                {
                    BypassLocalhost = false,
                    HostName = arg.WebSession.Request.Headers.GetHeaders("x-forwarded-host")[0].Value,
                    Port = Int32.Parse(arg.WebSession.Request.Headers.GetHeaders("x-forwarded-port")[0].Value),
                    Password = "",
                    UserName = "",
                    UseDefaultCredentials = false
                });
            }
            else
            {
                return(new ExternalProxy
                {
                    BypassLocalhost = false,
                    HostName = "127.0.0.1",
                    Port = 8001,
                    Password = "",
                    UserName = "",
                    UseDefaultCredentials = false
                });
            }
        }
Beispiel #2
0
        private async Task <IExternalProxy> OnGetCustomUpStreamProxyFunc(SessionEventArgsBase arg)
        {
            arg.GetState().PipelineInfo.AppendLine(nameof(OnGetCustomUpStreamProxyFunc));

            TorInfo torInfo;

            lock (_syncObj)
            {
                torInfo = _tors[_currProxy];
                _currProxy++;
                if (_currProxy >= _tors.Count)
                {
                    _currProxy = 0;
                }
            }

            WriteToConsole($"using tor proxy: {torInfo.HostName}:{torInfo.Port}");

            // this is just to show the functionality, provided values are junk
            return(new ExternalProxy
            {
                BypassLocalhost = false,
                ProxyType = ExternalProxyType.Socks5,
                HostName = torInfo.HostName,
                Port = torInfo.Port,
                UseDefaultCredentials = false
            });
        }
Beispiel #3
0
        private async Task <IExternalProxy> onCustomUpStreamProxyFailureFunc(SessionEventArgsBase arg)
        {
            arg.GetState().PipelineInfo.AppendLine(nameof(onCustomUpStreamProxyFailureFunc));

            // this is just to show the functionality, provided values are junk
            return(new ExternalProxy
            {
                BypassLocalhost = false, HostName = "127.0.0.10", Port = 9191, Password = "******", UserName = "******",
                UseDefaultCredentials = false
            });
        }