Ejemplo n.º 1
0
    // Actually checks to see if data can go to the internet (via UDP 53)
    private void DoCheckDNSNetwork(object oIn)
    {
        try
        {
            StateManager CurState = (StateManager)oIn;

            byte[] bIDOut = new byte[8];

            // First, try a DNS ping through proxy (whether it's on or not)
            EDNSPacket Packet = SendUdpNetworkPacket(g_sProxyIP, g_sIDIP, 53, 0x10, false, bIDOut);

            DNSPacket.PacketExplode pe = new DNSPacket.PacketExplode(Packet.GetResponsePacket());

            // Retry over TCP if truncated
            if (pe.IsTruncated())
            {
                Packet = SendTcpNetworkPacket(g_sProxyIP, g_sIDIP, 53, 0x10, false, bIDOut);
            }

            if (Packet.GetResponsePacket().Length > 0)
            {
                // We got a result through the proxy; all is well
                CurState.SetEncryptedState(true);
                CurState.SetNetworkState(true, true);
            }
            else
            {
                // We did not get a response through the proxy, so encryption is a no-go
                CurState.SetEncryptedState(false);

                // Try a second DNS ping, this time through the OpenDNS resolver
                Packet = SendUdpNetworkPacket(g_sResolverIP, g_sIDIP, 53, 0x10, false, bIDOut);
                if (Packet.GetResponsePacket().Length > 0)
                {
                    // We have at least SOME internet connection
                    CurState.SetNetworkState(true, true);
                }
                else
                {
                    // We could not reach the network at all
                    CurState.SetNetworkState(false, true);
                }
            }
        }
        catch (Exception Ex)
        {
            // Do nothing
        }
    }
Ejemplo n.º 2
0
    // Actually checks to see if data can go to the internet (via UDP 53)
    private void DoCheckDNSNetwork(object oIn)
    {
        try
        {
            StateManager CurState = (StateManager)oIn;

            byte[] bIDOut = new byte[8];

            // First, try a DNS ping through proxy (whether it's on or not)
            EDNSPacket Packet = SendUdpNetworkPacket(g_sProxyIP, g_sIDIP, 53, 0x10, false, bIDOut);

            DNSPacket.PacketExplode pe = new DNSPacket.PacketExplode(Packet.GetResponsePacket());

            // Retry over TCP if truncated
            if (pe.IsTruncated())
            {
                Packet = SendTcpNetworkPacket(g_sProxyIP, g_sIDIP, 53, 0x10, false, bIDOut);
            }

            if (Packet.GetResponsePacket().Length > 0)
            {
                // We got a result through the proxy; all is well
                CurState.SetEncryptedState(true);
                CurState.SetNetworkState(true, true);
            }
            else
            {
                // We did not get a response through the proxy, so encryption is a no-go
                CurState.SetEncryptedState(false);

                // Try a second DNS ping, this time through the OpenDNS resolver
                Packet = SendUdpNetworkPacket(g_sResolverIP, g_sIDIP, 53, 0x10, false, bIDOut);
                if (Packet.GetResponsePacket().Length > 0)
                {
                    // We have at least SOME internet connection
                    CurState.SetNetworkState(true, true);
                }
                else
                {
                    // We could not reach the network at all
                    CurState.SetNetworkState(false, true);
                }
            }

        }
        catch (Exception Ex)
        {
            // Do nothing
        }
    }