Example #1
0
        internal void ResolveAddress(IDnsCache cache, NetProxy proxy, bool preferIPv6, bool tcp, int retries)
        {
            if ((_domain != null) && (_endPoint == null))
            {
                if (preferIPv6)
                {
                    try
                    {
                        DnsDatagram nsResponse = DnsClient.ResolveViaNameServers(new DnsQuestionRecord(_domain, DnsResourceRecordType.AAAA, DnsClass.IN), null, cache, proxy, true, tcp, retries);
                        if ((nsResponse.Header.RCODE == DnsResponseCode.NoError) && (nsResponse.Answer.Length > 0) && (nsResponse.Answer[0].Type == DnsResourceRecordType.AAAA))
                        {
                            _endPoint = new IPEndPoint((nsResponse.Answer[0].RDATA as DnsAAAARecord).Address, 53);
                        }
                    }
                    catch
                    { }
                }

                if (_endPoint == null)
                {
                    try
                    {
                        DnsDatagram nsResponse = DnsClient.ResolveViaNameServers(new DnsQuestionRecord(_domain, DnsResourceRecordType.A, DnsClass.IN), null, cache, proxy, false, tcp, retries);
                        if ((nsResponse.Header.RCODE == DnsResponseCode.NoError) && (nsResponse.Answer.Length > 0) && (nsResponse.Answer[0].Type == DnsResourceRecordType.A))
                        {
                            _endPoint = new IPEndPoint((nsResponse.Answer[0].RDATA as DnsARecord).Address, 53);
                        }
                    }
                    catch
                    { }
                }
            }
        }
Example #2
0
 public override void InitController()
 {
     //3-19  请求消息列表
     _Proxy = new NetProxy(NetModules.GameAction.ModuleId);
     SocketParser.Instance.RegisterParser(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_MessageSend_Req, Farm_Game_MessageSend_Anw.ParseFrom);//注册对应消息(在服务器发过来时)的Proto解析器
     _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_MessageSend_Req, MsgListCallBack);
 }
Example #3
0
        public void ResolveDomainName(NameServerAddress[] nameServers = null, NetProxy proxy = null, bool preferIPv6 = false, DnsTransportProtocol protocol = DnsTransportProtocol.Udp, int retries = 2, int timeout = 2000)
        {
            if (_ipEndPoint != null)
            {
                DnsClient dnsClient;

                if (nameServers == null)
                {
                    dnsClient = new DnsClient();
                }
                else
                {
                    dnsClient = new DnsClient(nameServers);
                }

                dnsClient.Proxy      = proxy;
                dnsClient.PreferIPv6 = preferIPv6;
                dnsClient.Protocol   = protocol;
                dnsClient.Retries    = retries;
                dnsClient.Timeout    = timeout;

                try
                {
                    string domain = dnsClient.ResolvePTR(_ipEndPoint.Address);
                    _domainEndPoint = new DomainEndPoint(domain, _ipEndPoint.Port);
                }
                catch
                { }
            }
        }
Example #4
0
        public override void InitController()
        {
            _Proxy = new NetProxy(NetModules.Account.ModuleId); //这里是初始化本模块的网络组件
            //1-0手机帐号密码登录协议
            SocketParser.Instance.RegisterParser(NetModules.Account.ModuleId, NetModules.Account.ReqLoginSDK,
                                                 ResponeLoginSDK.ParseFrom);
            _Proxy.AddNetListenner(NetModules.Account.ReqLoginSDK, LoginSDKRespone);
            //1-1
            SocketParser.Instance.RegisterParser(NetModules.Account.ModuleId, NetModules.Account.LogoutSDK,
                                                 ReqLogoutSDK.ParseFrom); //注册对应消息(在服务器发过来时)的Proto解析器
            _Proxy.AddNetListenner(NetModules.Account.LogoutSDK, LogoutCallback);

            //1-2
            SocketParser.Instance.RegisterParser(NetModules.Account.ModuleId, NetModules.Account.ReqLogin,
                                                 ResponeLogin.ParseFrom);       //注册对应消息(在服务器发过来时)的Proto解析器
            _Proxy.AddNetListenner(NetModules.Account.ReqLogin, LoginCallback); //注册对应消息(在服务器发过来时)的回调

            //1-4
            SocketParser.Instance.RegisterParser(NetModules.Account.ModuleId, NetModules.Account.ReqReLogin,
                                                 ResponeLogin.ParseFrom);
            _Proxy.AddNetListenner(NetModules.Account.ReqReLogin, LoginCallback);

            //1-6
            _Proxy.AddNetListenner(NetModules.Account.Farm_Game_Register_Req, RegisterCallBack);
            //1-7
            _Proxy.AddNetListenner(NetModules.Account.Farm_Game_VeriCode_Req, VeriCodeCallBack);
            GetDispatcher().AddListener(LoginEvent.LoginSDKRespone, ReqLoginSend);
        }
Example #5
0
        public void ConfigureProxy(NetProxyType proxyType, string proxyAddress, ushort proxyPort, NetworkCredential proxyCredentials)
        {
            if (_type == MeshNodeType.Anonymous)
            {
                throw new NotSupportedException("Mesh tor profile does not support proxy configuration.");
            }

            if (proxyType == NetProxyType.None)
            {
                _proxy = null;
            }
            else
            {
                _proxy = new NetProxy(proxyType, proxyAddress, proxyPort, proxyCredentials);
            }

            //update proxy for networks
            lock (_networks)
            {
                foreach (KeyValuePair <BinaryNumber, MeshNetwork> network in _networks)
                {
                    network.Value.ProxyUpdated();
                }
            }
        }
Example #6
0
 public override void InitController()
 {
     //  标识: module = 3,sub = 8
     _Proxy = new NetProxy(NetModules.FarmGameProtocal.ModuleId);
     SocketParser.Instance.RegisterParser(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_pay_Req, Farm_Game_pay_Anw.ParseFrom);
     _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_pay_Req, AnwCallBack);
 }
Example #7
0
 public override void InitController()
 {
     //  3-10
     _Proxy = new NetProxy(NetModules.GameAction.ModuleId);
     SocketParser.Instance.RegisterParser(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_OilUpgrade_Req, Farm_Game_OilUpgrade_Anw.ParseFrom);
     _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_OilUpgrade_Req, OilUpgradeCallBack);
 }
Example #8
0
        public void VerifyRevocationList(NetProxy proxy = null, int timeout = 10000)
        {
            if (_revocationUri != null)
            {
                bool revoked = false;
                RevocationCertificate revokeCert = null;

                try
                {
                    revoked = RevocationCertificate.IsRevoked(this, out revokeCert, proxy, timeout);

                    if (_issuerSignature.SigningCertificate != null)
                    {
                        _issuerSignature.SigningCertificate.VerifyRevocationList(proxy, timeout);
                    }
                }
                catch (InvalidCertificateException)
                {
                    throw;
                }
                catch
                { }

                if (revoked)
                {
                    throw new InvalidCertificateException("Certificate serial number '" + _serialNumber + "' issued to '" + _issuedTo.Name + "' has been revoked on " + revokeCert.RevokedOnUTC + " UTC by the certificate authority and hence is invalid.");
                }
            }
        }
        public NetworkDumbFuzzer(string listenAddress, int listenPort, string remoteAddress, int remotePort)
        {
            proxy = new NetProxy(listenAddress, listenPort, remoteAddress, remotePort);
            proxy.ClientDataReceived += new ClientDataReceivedEventHandler(proxy_ClientDataReceived);
            proxy.ServerDataReceived += new ServerDataReceivedEventHandler(proxy_ServerDataReceived);

            proxy.Run();
        }
Example #10
0
 public void DisableProxy()
 {
     if (_proxy != null)
     {
         _proxy = null;
         ProxyUpdated?.BeginInvoke(this, EventArgs.Empty, null, null);
     }
 }
Example #11
0
 /// <summary>
 /// connect not timer.
 /// </summary>
 public void InitConnect()
 {
     if (_netProxy == null)
     {
         _netProxy = NetProxy.Create(Setting.Url);
     }
     _netProxy.CheckConnect();
 }
Example #12
0
        public static DnsClientConnection GetConnection(DnsTransportProtocol protocol, NameServerAddress server, NetProxy proxy)
        {
            switch (protocol)
            {
            case DnsTransportProtocol.Udp:
                return(new UdpClientConnection(server, proxy));

            case DnsTransportProtocol.Https:
                return(new HttpsClientConnection(server, proxy));

            case DnsTransportProtocol.HttpsJson:
                return(new HttpsJsonClientConnection(server, proxy));

            case DnsTransportProtocol.Tcp:
            {
                ConcurrentDictionary <NetProxy, DnsClientConnection> existingTcpConnection = _existingTcpConnections.GetOrAdd(server, delegate(NameServerAddress nameServer)
                    {
                        return(new ConcurrentDictionary <NetProxy, DnsClientConnection>());
                    });

                NetProxy proxyKey = proxy;

                if (proxyKey == null)
                {
                    proxyKey = NetProxy.None;
                }

                return(existingTcpConnection.GetOrAdd(proxyKey, delegate(NetProxy netProxyKey)
                    {
                        return new TcpClientConnection(server, proxy);
                    }));
            }

            case DnsTransportProtocol.Tls:
            {
                ConcurrentDictionary <NetProxy, DnsClientConnection> existingTlsConnection = _existingTlsConnections.GetOrAdd(server, delegate(NameServerAddress nameServer)
                    {
                        return(new ConcurrentDictionary <NetProxy, DnsClientConnection>());
                    });

                NetProxy proxyKey = proxy;

                if (proxyKey == null)
                {
                    proxyKey = NetProxy.None;
                }

                return(existingTlsConnection.GetOrAdd(proxyKey, delegate(NetProxy netProxyKey)
                    {
                        return new TlsClientConnection(server, proxy);
                    }));
            }

            default:
                throw new NotSupportedException("DnsClient protocol not supported: " + protocol.ToString());
            }
        }
Example #13
0
        /// <summary>
        /// Автозаполнение таблицы работниками
        /// </summary>
        private void FillGrid(bool clear)
        {
            //если таблица пуста - добавляем первого работника
            if (dataGridView1.RowCount <= 1)
            {
                if (!clear)
                {
                    if (NetProxy.IsShifted(int.Parse(Year), Month))
                    {
                        foreach (Person person in PersonProxy.GetPersons())
                        {
                            dataGridView1.Rows.Add(person.ID, person.LastName + " " + person.FirstName + " " + person.Patronymic);
                        }
                    }
                }
                else
                {
                    foreach (Person person in PersonProxy.GetPersons())
                    {
                        dataGridView1.Rows.Add(person.ID, person.LastName + " " + person.FirstName + " " + person.Patronymic);
                    }
                }
            }
            else
            {
                //проверка на уже введеного сотрудника
                //во избежание дублирования
                int rowCount = dataGridView1.RowCount - 1;

                foreach (Person person in PersonProxy.GetPersons())
                {
                    bool exists = false;
                    for (int i = 0; i < rowCount; i++)
                    {
                        object idCellValue = dataGridView1.Rows[i].Cells[0].Value;

                        if (idCellValue != null)
                        {
                            int cellValue = int.Parse(idCellValue.ToString());

                            if (cellValue != person.ID)
                            {
                                continue;
                            }
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        dataGridView1.Rows.Add(person.ID, person.LastName + " " + person.FirstName + " " + person.Patronymic);
                    }
                }
            }
        }
        public void ResolveIPAddress(NameServerAddress[] nameServers = null, NetProxy proxy = null, bool preferIPv6 = false, DnsTransportProtocol protocol = DnsTransportProtocol.Udp, int retries = 2, int timeout = 2000)
        {
            string domain;

            if (_dohEndPoint != null)
            {
                domain = _dohEndPoint.Host;
            }
            else if (_domainEndPoint != null)
            {
                domain = _domainEndPoint.Address;
            }
            else
            {
                return;
            }

            if (domain == "localhost")
            {
                _ipEndPoint = new IPEndPoint((preferIPv6 ? IPAddress.IPv6Loopback : IPAddress.Loopback), this.Port);
                return;
            }

            if (IPAddress.TryParse(domain, out IPAddress address))
            {
                _ipEndPoint = new IPEndPoint(address, this.Port);
                return;
            }

            DnsClient dnsClient;

            if (nameServers == null)
            {
                dnsClient = new DnsClient();
            }
            else
            {
                dnsClient = new DnsClient(nameServers);
            }

            dnsClient.Proxy      = proxy;
            dnsClient.PreferIPv6 = preferIPv6;
            dnsClient.Protocol   = protocol;
            dnsClient.Retries    = retries;
            dnsClient.Timeout    = timeout;

            IPAddress[] serverIPs = dnsClient.ResolveIP(domain, preferIPv6);

            if (serverIPs.Length == 0)
            {
                throw new DnsClientException("No IP address was found for name server: " + domain);
            }

            _ipEndPoint = new IPEndPoint(serverIPs[0], this.Port);
        }
Example #15
0
 public override void InitController()
 {
     //2-7
     _Proxy = new NetProxy(NetModules.FarmGameProtocal.ModuleId);
     SocketParser.Instance.RegisterParser(NetModules.FarmGameProtocal.ModuleId, NetModules.FarmGameProtocal.Farm_Game_ShopInfo_Req, Farm_Game_ShopInfo_Anw.ParseFrom);
     _Proxy.AddNetListenner(NetModules.FarmGameProtocal.Farm_Game_ShopInfo_Req, AnwShopInfoCallBack);
     //3-6
     _Proxy = new NetProxy(NetModules.GameAction.ModuleId);
     SocketParser.Instance.RegisterParser(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_buyOrSell_Req, Farm_Game_buyOrSell_Anw.ParseFrom);
     _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_buyOrSell_Req, AnwBuyOrSellCallBack);
 }
Example #16
0
        public override void InitController()
        {
            _Proxy = new NetProxy(NetModules.GameAction.ModuleId);
            //module =3 ,sub = 17
            SocketParser.Instance.RegisterParser(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_Chant_Req, Farm_Game_Chat_Anw.ParseFrom);

            //3-22 请求聊天记录
            _Proxy = new NetProxy(NetModules.GameAction.ModuleId);
            SocketParser.Instance.RegisterParser(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_ChatLog_Req, Farm_Game_ChatLog_Anw.ParseFrom);
            _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_ChatLog_Req, ChatLogCallBack);
        }
Example #17
0
        public void RecursiveResolveIPAddress(DnsCache cache = null, NetProxy proxy = null, bool preferIPv6 = false, int retries = 2, int timeout = 2000, bool useTcp = false)
        {
            lock (_ipEndPointResolverLock)
            {
                if (_ipEndPointExpires && (DateTime.UtcNow < _ipEndPointExpiresOn))
                {
                    return;
                }

                string domain;

                if (_dohEndPoint != null)
                {
                    domain = _dohEndPoint.Host;
                }
                else if (_domainEndPoint != null)
                {
                    domain = _domainEndPoint.Address;
                }
                else
                {
                    return;
                }

                if (domain == "localhost")
                {
                    _ipEndPoint = new IPEndPoint((preferIPv6 ? IPAddress.IPv6Loopback : IPAddress.Loopback), this.Port);
                    return;
                }

                if (IPAddress.TryParse(domain, out IPAddress address))
                {
                    _ipEndPoint = new IPEndPoint(address, this.Port);
                    return;
                }

                IPEndPoint ipEndPoint = null;

                IPAddress[] addresses = DnsClient.RecursiveResolveIP(domain, cache, proxy, preferIPv6, retries, timeout, useTcp);
                if (addresses.Length > 0)
                {
                    ipEndPoint = new IPEndPoint(addresses[0], this.Port);
                }

                if (ipEndPoint == null)
                {
                    throw new DnsClientException("No IP address was found for name server: " + domain);
                }

                _ipEndPoint          = ipEndPoint;
                _ipEndPointExpires   = true;
                _ipEndPointExpiresOn = DateTime.UtcNow.AddSeconds(IP_ENDPOINT_DEFAULT_TTL);
            }
        }
        public void RecursiveResolveIPAddress(IDnsCache cache = null, NetProxy proxy = null, bool preferIPv6 = false, DnsTransportProtocol protocol = DnsTransportProtocol.Udp, int retries = 2, int timeout = 2000, DnsTransportProtocol recursiveResolveProtocol = DnsTransportProtocol.Udp)
        {
            string domain;

            if (_dohEndPoint != null)
            {
                domain = _dohEndPoint.Host;
            }
            else if (_domainEndPoint != null)
            {
                domain = _domainEndPoint.Address;
            }
            else
            {
                return;
            }

            if (domain == "localhost")
            {
                _ipEndPoint = new IPEndPoint((preferIPv6 ? IPAddress.IPv6Loopback : IPAddress.Loopback), this.Port);
                return;
            }

            if (IPAddress.TryParse(domain, out IPAddress address))
            {
                _ipEndPoint = new IPEndPoint(address, this.Port);
                return;
            }

            if (preferIPv6)
            {
                DnsDatagram nsResponse = DnsClient.RecursiveResolve(new DnsQuestionRecord(domain, DnsResourceRecordType.AAAA, DnsClass.IN), null, cache, proxy, true, protocol, retries, timeout, recursiveResolveProtocol);
                if ((nsResponse.Header.RCODE == DnsResponseCode.NoError) && (nsResponse.Answer.Length > 0) && (nsResponse.Answer[0].Type == DnsResourceRecordType.AAAA))
                {
                    _ipEndPoint = new IPEndPoint((nsResponse.Answer[0].RDATA as DnsAAAARecord).Address, this.Port);
                }
            }

            if (_ipEndPoint == null)
            {
                DnsDatagram nsResponse = DnsClient.RecursiveResolve(new DnsQuestionRecord(domain, DnsResourceRecordType.A, DnsClass.IN), null, cache, proxy, false, protocol, retries, timeout, recursiveResolveProtocol);
                if ((nsResponse.Header.RCODE == DnsResponseCode.NoError) && (nsResponse.Answer.Length > 0) && (nsResponse.Answer[0].Type == DnsResourceRecordType.A))
                {
                    _ipEndPoint = new IPEndPoint((nsResponse.Answer[0].RDATA as DnsARecord).Address, this.Port);
                }
            }

            if (_ipEndPoint == null)
            {
                throw new DnsClientException("No IP address was found for name server: " + domain);
            }
        }
        public async Task RecursiveResolveIPAddressAsync(IDnsCache cache = null, NetProxy proxy = null, bool preferIPv6 = false, bool randomizeName = false, int retries = 2, int timeout = 2000)
        {
            if (_ipEndPointExpires && (DateTime.UtcNow < _ipEndPointExpiresOn))
            {
                return;
            }

            string domain;

            if (_dohEndPoint != null)
            {
                domain = _dohEndPoint.Host;
            }
            else if (_domainEndPoint != null)
            {
                domain = _domainEndPoint.Address;
            }
            else
            {
                return;
            }

            if (domain == "localhost")
            {
                _ipEndPoint = new IPEndPoint((preferIPv6 ? IPAddress.IPv6Loopback : IPAddress.Loopback), this.Port);
                return;
            }

            if (IPAddress.TryParse(domain, out IPAddress address))
            {
                _ipEndPoint = new IPEndPoint(address, this.Port);
                return;
            }

            IPEndPoint ipEndPoint = null;

            IReadOnlyList <IPAddress> addresses = await DnsClient.RecursiveResolveIPAsync(domain, cache, proxy, preferIPv6, randomizeName, retries, timeout);

            if (addresses.Count > 0)
            {
                ipEndPoint = new IPEndPoint(addresses[0], this.Port);
            }

            if (ipEndPoint == null)
            {
                throw new DnsClientException("No IP address was found for name server: " + domain);
            }

            _ipEndPoint          = ipEndPoint;
            _ipEndPointExpires   = true;
            _ipEndPointExpiresOn = DateTime.UtcNow.AddSeconds(IP_ENDPOINT_DEFAULT_TTL);
        }
        internal void ClientProfileProxyUpdated()
        {
            NetProxy proxy = _profile.Proxy;

            _dhtClient.ProxyEnabled  = (proxy != null);
            _dhtSeedingTracker.Proxy = proxy;

            if (proxy != null)
            {
                //stop tcp relay for all networks since this client switched to proxy and can no longer provide tcp relay service
                TcpRelayService.StopAllTcpRelays();
            }
        }
Example #21
0
        public UdpClientConnection(NameServerAddress server, NetProxy proxy)
            : base(DnsTransportProtocol.Udp, server, proxy)
        {
            if (proxy != null)
            {
                if (proxy.Type == NetProxyType.Http)
                {
                    throw new NotSupportedException("DnsClient cannot use HTTP proxy with UDP protocol.");
                }
            }

            _timeout = 2000;
        }
Example #22
0
        private void ConditionalHttpReload()
        {
            bool     handlerChanged = false;
            NetProxy proxy          = _service.DnsServer.Proxy;

            if (_httpHandler is null)
            {
                SocketsHttpHandler httpHandler = new SocketsHttpHandler();
                httpHandler.Proxy                    = proxy;
                httpHandler.AllowAutoRedirect        = true;
                httpHandler.MaxAutomaticRedirections = 10;

                _httpHandler   = httpHandler;
                handlerChanged = true;
            }
            else
            {
                if (_httpHandler.Proxy != proxy)
                {
                    SocketsHttpHandler httpHandler = new SocketsHttpHandler();
                    httpHandler.Proxy                    = proxy;
                    httpHandler.AllowAutoRedirect        = true;
                    httpHandler.MaxAutomaticRedirections = 10;

                    SocketsHttpHandler oldHttpHandler = _httpHandler;
                    _httpHandler   = httpHandler;
                    handlerChanged = true;

                    oldHttpHandler.Dispose();
                }
            }

            if (_httpClient is null)
            {
                HttpClient httpClient = new HttpClient(_httpHandler);

                _httpClient = httpClient;
            }
            else
            {
                if (handlerChanged)
                {
                    HttpClient httpClient = new HttpClient(_httpHandler);

                    HttpClient oldHttpClient = _httpClient;
                    _httpClient = httpClient;

                    oldHttpClient.Dispose();
                }
            }
        }
Example #23
0
        public TimetableForm(string year, int month)
        {
            InitializeComponent();
            PersonProxy = new PersonProxy();
            NetProxy    = new NetProxy();

            Year  = year;
            Month = month;

            PaintGrid();
            //FilterForm = Application.OpenForms["filterForm"] as FilterForm;
            //FilterForm = new FilterForm();
            //FilterForm.PersonSelected += new EventHandler<FilterEventArgs>(filterForm_PersonSelected);
        }
Example #24
0
        private byte[] GetRequestData()
        {
            StringBuilder param = new StringBuilder();
            var           pairs = _params.ToArray();

            foreach (var pair in pairs)
            {
                if (param.Length > 0)
                {
                    param.Append("&");
                }
                param.AppendFormat("{0}={1}", pair.Key, NetProxy.Encoding(pair.Value));
            }
            return(Encoding.UTF8.GetBytes(string.Format("?d={0}", NetProxy.GetSign(param.ToString(), _session.Setting.SignKey))));
        }
 public async Task RecursiveResolveDomainNameAsync(IDnsCache cache = null, NetProxy proxy = null, bool preferIPv6 = false, bool randomizeName = false, int retries = 2, int timeout = 2000)
 {
     if (_ipEndPoint != null)
     {
         try
         {
             IReadOnlyList <string> ptrDomains = DnsClient.ParseResponsePTR(await DnsClient.RecursiveResolveQueryAsync(new DnsQuestionRecord(_ipEndPoint.Address, DnsClass.IN), cache, proxy, preferIPv6, randomizeName, retries, timeout));
             if (ptrDomains != null)
             {
                 _domainEndPoint = new DomainEndPoint(ptrDomains[0], _ipEndPoint.Port);
             }
         }
         catch
         { }
     }
 }
Example #26
0
 public void RecursiveResolveDomainName(DnsCache cache = null, NetProxy proxy = null, bool preferIPv6 = false, int retries = 2, int timeout = 2000, bool useTcp = false)
 {
     if (_ipEndPoint != null)
     {
         try
         {
             string ptrDomain = DnsClient.ParseResponsePTR(DnsClient.RecursiveQuery(new DnsQuestionRecord(_ipEndPoint.Address, DnsClass.IN), cache, proxy, preferIPv6, retries, timeout, useTcp));
             if (ptrDomain != null)
             {
                 _domainEndPoint = new DomainEndPoint(ptrDomain, _ipEndPoint.Port);
             }
         }
         catch
         { }
     }
 }
Example #27
0
        public override void InitController()
        {
            _Proxy = new NetProxy(NetModules.GameAction.ModuleId);
            //  3-15

            _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_ScanQRcodeOrRecommand_Req, AnwScanQRcodeOrRecommandCallBack);
            //  3-13
            SocketParser.Instance.RegisterParser(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_DogUpgrad_Req,
                                                 Farm_Game_DogUpgrad_Req.ParseFrom);
            _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_DogUpgrad_Req, PersonInfoCallBack);

            //3-18

            SocketParser.Instance.RegisterParser(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_CoinOrExpChange_Anw, Farm_Game_CoinOrExpChange_Anw.ParseFrom);
            _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_CoinOrExpChange_Anw, ReFlashCoin);
        }
Example #28
0
        static void Main(string[] args)
        {
            logger.Info("WebProxy Tester Starting Up!!");

            File.WriteAllText("c:\\webproxy.txt", "");

            //Proxy proxy = new Proxy("0.0.0.0", 8080);
            //WebProxy webProxy = new WebProxy(proxy);
            //webProxy.NewHttpRequest += new HttpRequestEventHandler(webProxy_NewHttpRequest);
            //webProxy.NewHttpResponse += new HttpResponseEventHandler(webProxy_NewHttpResponse);
            //proxy.Run();

            NetProxy netProxy = new NetProxy("0.0.0.0", 8080, "127.0.0.1", 8081);

            netProxy.Run();
        }
Example #29
0
 public void RecursiveResolveDomainName(DnsCache cache = null, NetProxy proxy = null, bool preferIPv6 = false, DnsTransportProtocol protocol = DnsTransportProtocol.Udp, int retries = 2, int timeout = 2000, DnsTransportProtocol recursiveResolveProtocol = DnsTransportProtocol.Udp)
 {
     if (_ipEndPoint != null)
     {
         try
         {
             DnsDatagram nsResponse = DnsClient.RecursiveResolve(new DnsQuestionRecord(_ipEndPoint.Address, DnsClass.IN), null, cache, proxy, preferIPv6, protocol, retries, timeout, recursiveResolveProtocol);
             if ((nsResponse.Header.RCODE == DnsResponseCode.NoError) && (nsResponse.Answer.Length > 0) && (nsResponse.Answer[0].Type == DnsResourceRecordType.PTR))
             {
                 _domainEndPoint = new DomainEndPoint((nsResponse.Answer[0].RDATA as DnsPTRRecord).PTRDomainName, _ipEndPoint.Port);
             }
         }
         catch
         { }
     }
 }
Example #30
0
        public override void InitController()
        {
            //2-5
            _Proxy = new NetProxy(NetModules.FarmGameProtocal.ModuleId);
            SocketParser.Instance.RegisterParser(NetModules.FarmGameProtocal.ModuleId, NetModules.FarmGameProtocal.Farm_Game_StoreInfo_Req, Farm_Game_StoreInfo_Anw.ParseFrom);//注册对应消息(在服务器发过来时)的Proto解析器
            _Proxy.AddNetListenner(NetModules.FarmGameProtocal.Farm_Game_StoreInfo_Req, StoreInfoCallBack);

            //2-9
            _Proxy = new NetProxy(NetModules.FarmGameProtocal.ModuleId);
            SocketParser.Instance.RegisterParser(NetModules.FarmGameProtocal.ModuleId, NetModules.FarmGameProtocal.Farm_Game_Store_Update, Farm_Game_Store_Update.ParseFrom);//注册对应消息(在服务器发过来时)的Proto解析器
            _Proxy.AddNetListenner(NetModules.FarmGameProtocal.Farm_Game_Store_Update, StoreUpdateCallBack);

            //3-6
            _Proxy = new NetProxy(NetModules.GameAction.ModuleId);
            SocketParser.Instance.RegisterParser(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_buyOrSell_Req, Farm_Game_buyOrSell_Anw.ParseFrom);//注册对应消息(在服务器发过来时)的Proto解析器
            //_Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_buyOrSell_Req, StoreSellCallBack);
        }