Beispiel #1
0
        public override SocketInfo RequireSocketInfo(ClientRequestPacket crp)
        {
            var si = new SocketInfo();

            if (pacSetting.IsThroughProxy(crp.Protocol, crp.Host, crp.Port, crp.RelativePath))
            {
                rwl.EnterUpgradeableReadLock();
                si.Ips  = currentProxyIPAddress;
                si.Port = currentProxyPort;
                if (si.Ips == null)
                {
                    ProxyInfo newProxy = proxyManager.DequeueFastestProxy(true);
                    ChangeProxy(newProxy, ProxyChangePolicy.DELETE);
                }
                si.Ips  = currentProxyIPAddress;
                si.Port = currentProxyPort;
                rwl.ExitUpgradeableReadLock();

                //through proxy
                if (si.Ips == null)
                {
                    return(null);
                }
                si.Direct = false;
                si.InUse  = true;
            }
            else
            {
                //direct
                si.Ips = dnsCache.GetIPAddress(crp.Host);
                if (si.Ips == null)
                {
                    return(null);
                }
                si.Direct = true;
                si.InUse  = true;
                si.Port   = crp.Port;
                si.ReUse  = false;
            }
            return(si);
        }
Beispiel #2
0
        public override SocketInfo RequireSocketInfo(ClientRequestPacket crp)
        {
            SocketInfo si = new SocketInfo();

            si.Ips = dnsCache.GetIPAddress(crp.Host);
            if (si.Ips == null)
            {
                return(null);
            }
            si.Direct = true;
            si.InUse  = true;
            si.Port   = crp.Port;
            si.ReUse  = false;
            return(si);
        }