public override void Uninstall(IDictionary savedState)
        {
            // Close running application
            foreach (Process p in Process.GetProcessesByName(CLIENT_PROC_NAME))
            {
                p.Kill();
            }

            // Kill service if running
            ProcessManager.LaunchProcess("sc", "stop DNSCrypt");

            // Set NICs back to auto discover
            NICHandler.SetDNSServer(NICHandler.IP_CHOICES.FORCE_AUTO);

            base.Uninstall(savedState);
        }
예제 #2
0
    // Thread function to check NIC settings and force if
    // not right
    private void MonitorNICs(object oIn)
    {
        StateManager CurState = (StateManager)oIn;

        if (CurState.m_bShutdown)
        {
            return;
        }

        RUN_STATE Now = CurState.GetRunState();

        if ((Now == RUN_STATE.DNSCRYPT_FULL) || (Now == RUN_STATE.DNSCRYPT_TCP) || (Now == RUN_STATE.SERVICE_RESTART))
        {
            // Keep monitoring they are set to proxy
            CurState.SetNICsState(NICHandler.IP_CHOICES.LOCALHOST, NICHandler.EnsureNICsState(NICHandler.IP_CHOICES.LOCALHOST));
        }
        else if (Now == RUN_STATE.SERVICE_RUNNING)
        {
            // Set the NICs to proxy
            CurState.SetNICsState(NICHandler.IP_CHOICES.LOCALHOST, NICHandler.EnsureNICsState(NICHandler.IP_CHOICES.LOCALHOST));
        }
        else if (Now == RUN_STATE.OPENDNS_ONLY)
        {
            // Set the NICs to OpenDNS
            CurState.SetNICsState(NICHandler.IP_CHOICES.OPENDNS, NICHandler.EnsureNICsState(NICHandler.IP_CHOICES.OPENDNS));
        }
        else if (Now == RUN_STATE.FAIL_CLOSED)
        {
            // Set NICs to Proxy
            CurState.SetNICsState(NICHandler.IP_CHOICES.LOCALHOST, NICHandler.EnsureNICsState(NICHandler.IP_CHOICES.LOCALHOST));
        }
        else if (Now == RUN_STATE.FAIL_OPEN)
        {
            // Set the NICs to Default
            CurState.SetNICsState(NICHandler.IP_CHOICES.DEFAULT, NICHandler.EnsureNICsState(NICHandler.IP_CHOICES.DEFAULT));
        }
        else if (Now == RUN_STATE.DEFAULT)
        {
            // Set or ensure NICs are original user settings
            CurState.SetNICsState(NICHandler.IP_CHOICES.DEFAULT, NICHandler.EnsureNICsState(NICHandler.IP_CHOICES.DEFAULT));
        }
        else
        {
            // Set or ensure NICs are original user settings
            CurState.SetNICsState(NICHandler.IP_CHOICES.DEFAULT, NICHandler.EnsureNICsState(NICHandler.IP_CHOICES.DEFAULT));
        }
    }
예제 #3
0
    // Called to stop the timer
    public void CleanUp()
    {
        // First
        m_CurState.m_bShutdown = true;

        WriteToLog("Closing OpenDNS Service");

        // Kill timer first
        m_MainTimer.Stop();
        m_MainTimer = null;

        try
        {
            // Stop service
            m_CurState.m_ServiceManager.KillServiceProcess();

            // Clean up any running threads

            if (m_NICThread.IsAlive)
            {
                m_NICThread.Abort();
            }

            if (m_ProxyThread.IsAlive)
            {
                m_ProxyThread.Abort();
            }

            // Set NIC back to default so the user has some DNS
            NICHandler.SetDNSServer(NICHandler.IP_CHOICES.DEFAULT);
        }
        catch (Exception Ex)
        {
            string sMsg = Ex.Message;
        }
        finally
        {
        }
    }
예제 #4
0
 public bool GetNICsSet(ref NICHandler.IP_CHOICES Where)
 {
     Where = m_NICsWhere;
     return m_bNICsSet;
 }
예제 #5
0
 public void SetNICsState(NICHandler.IP_CHOICES Where, bool bNICSet)
 {
     m_bNICsSet = bNICSet;
     m_NICsWhere = Where;
 }