コード例 #1
0
        /// <summary>
        /// Method to show a dialog form with error messages due to the tap
        /// test interface failure.
        /// </summary>
        /// <param name="tapTestResult">Result of the tap interface test</param>
        private void displayOtherErrorDialogs(int tapTestResult)
        {
            TapInterfaceTestResDialog dialog;

            switch (tapTestResult)
            {
            case -6:
                dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - FOUND MORE THAN ONE TAP INTERFACE: DO NOT KNOW WHICH ONE TO USE" +
                                                       System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                                                       System.Environment.NewLine + "the correct netproxy working.", true, false);
                break;

            case -7:
                dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - FAILED OPENING THE TAP INTERFACE DEVICE" +
                                                       System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                                                       System.Environment.NewLine + "the correct netproxy working.", true, false);
                break;

            case -8:
                dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - FAILED CREATING THE READING EVENT" +
                                                       System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                                                       System.Environment.NewLine + "the correct netproxy working.", true, false);
                break;

            case -9:
                dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - FAILED CREATING THE WRITING EVENT" +
                                                       System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                                                       System.Environment.NewLine + "the correct netproxy working.", true, false);
                break;

            case -10:
                dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - UNKNOWN ERROR" +
                                                       System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                                                       System.Environment.NewLine + "the correct netproxy working.", true, false);
                break;

            default:
                dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - UNKNOWN ERROR" +
                                                       System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                                                       System.Environment.NewLine + "the correct netproxy working.", true, false);
                break;
            }
            dialog.ShowDialog();
            dialog.Dispose();
        }
コード例 #2
0
        protected override void OnBeforeInstall (IDictionary savedState)
        {
            base.OnBeforeInstall(savedState);

            FileInfo fileInfo = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string execTestFile = Context.Parameters["RunInstallationTest"];
            execTestFile = Path.Combine(fileInfo.DirectoryName,execTestFile);
            Process tapTestProcess = Process.Start(execTestFile,"-testtap");
            tapTestProcess.WaitForExit();
            int tapTestResult = tapTestProcess.ExitCode;

            if(tapTestResult == -0) {
                TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" + 
                    System.Environment.NewLine + "The TAP interface is correctly installed and configured",false,false);
                dialog.ShowDialog();
                dialog.Dispose();
                return;
            }

            // The tap interface driver are not installed
            if (tapTestResult == -5) {
                TapInterfaceTestResDialog openVPnDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NO TAP-WIN32 INTERFACE FOUND" +
                                System.Environment.NewLine + "The installation process can be completed only installing the tap interface drivers. " +
                                System.Environment.NewLine + "It is possible to install the openVpn drivers from this windows. ",true,true);
                if((openVPnDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) && (openVPnDialog.installOpenVpn())) {
                        string execOpenVPNFile = Context.Parameters["RunOpenVpnInstallation"];
                        execOpenVPNFile = Path.Combine(fileInfo.DirectoryName,execOpenVPNFile);
                        Process openVPNProcess = Process.Start(execOpenVPNFile);
                        openVPNProcess.WaitForExit();
                        openVPnDialog.Dispose();
                        tapTestResult = openVPNProcess.ExitCode;
                }
                else {
                    throw new Exception(System.Environment.NewLine + System.Environment.NewLine + 
                        "TAP INTERFACE TEST - NO TAP-WIN32 INTERFACE FOUND" +  System.Environment.NewLine + 
                        "The installation process will stop");
                }

                if (tapTestResult!=0) {
                    throw new Exception(System.Environment.NewLine + System.Environment.NewLine + 
                        "OPENVPN INSTALLATION PROCESS - The tap interface drivers has not been correctly installed. " + 
                        System.Environment.NewLine + "The NetProxy installation process will stop");
                }

                if(tryAddressesSetting(execTestFile) == 0) {
                    TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                        System.Environment.NewLine + "The TAP interface is correctly installed and configured",false,false);
                    dialog.ShowDialog();
                    dialog.Dispose();
                } 
                return;
                
            }

            // The ip address and the mac address don't match
            if (tapTestResult == -4) {
                if(tryAddressesSetting(execTestFile) == 0) {
                    TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                        System.Environment.NewLine + "The TAP interface is correctly installed and configured",false,false);
                    dialog.ShowDialog();
                    dialog.Dispose();
                } 
                return;
            }

            // Other error in the tap interface test
            displayOtherErrorDialogs (tapTestResult);
            
        }
コード例 #3
0
  /// <summary>
  /// Method to show a dialog form with error messages due to the tap 
  /// test interface failure.
  /// </summary>
  /// <param name="tapTestResult">Result of the tap interface test</param>
 private void displayOtherErrorDialogs(int tapTestResult)
 {
     TapInterfaceTestResDialog dialog;
     switch(tapTestResult) {
         case -6:
             dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - FOUND MORE THAN ONE TAP INTERFACE: DO NOT KNOW WHICH ONE TO USE" +
                 System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                 System.Environment.NewLine + "the correct netproxy working.",true,false);
             break;
         case -7:
             dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - FAILED OPENING THE TAP INTERFACE DEVICE" +
                 System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                 System.Environment.NewLine + "the correct netproxy working.",true,false);
             break;
         case -8:
             dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - FAILED CREATING THE READING EVENT" +
                 System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                 System.Environment.NewLine + "the correct netproxy working.",true,false);
             break;
         case -9:
             dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - FAILED CREATING THE WRITING EVENT" +
                 System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                 System.Environment.NewLine + "the correct netproxy working.",true,false);
             break;
         case -10:
             dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - UNKNOWN ERROR" +
                 System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                 System.Environment.NewLine + "the correct netproxy working.",true,false);
             break;
         default:
             dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - UNKNOWN ERROR" +
                 System.Environment.NewLine + "This doesn't influence the installation process but it will preclude " +
                 System.Environment.NewLine + "the correct netproxy working.",true,false);
             break;
     }
     dialog.ShowDialog();
     dialog.Dispose();
 }
コード例 #4
0
        /// <summary>
        /// Method that tries to set the ip, subnet mask, default gateway 
        /// and mac addresses using the .exe file specified as paramerer. 
        /// The exec file set also the MTU registry to 1500 and the 
        /// AllowNonAdmin registy to 1.
        /// </summary>
        /// <param name="execTestFile">Executable file to change the addresses</param>
        /// <returns>0 if everything went fine, a negative number otherwise</returns>
        private int tryAddressesSetting(string execTestFile)
        {
            int tapTestResult = -4;
            NetworkParametersForm netParamForm = new NetworkParametersForm();
            showNetworkParametersFromDialog(netParamForm);
            DialogResult dr = netParamForm.ShowDialog();
            if(dr == System.Windows.Forms.DialogResult.OK) {
                string adapterDescriptor = netParamForm.getAdapterDescriptor();
                string ip = netParamForm.getIPAddress();
                string mask = netParamForm.getMaskAddress();
                string gateway = netParamForm.getGatewayAddress();
                string mac = netParamForm.getMACAddress();
                string ipOptions;
                if(String.IsNullOrEmpty(gateway)) {
                    ipOptions = "-updateIP -d \"" + adapterDescriptor + "\" -ip " + ip + " -mask " + mask;
                }
                else {
                    ipOptions = "-updateIP -d \"" + adapterDescriptor + "\" -ip " + ip + " -mask " + mask + " -gateway " + gateway;
                }
                Process setIPProcess = Process.Start(execTestFile,ipOptions);
                setIPProcess.WaitForExit();
                tapTestResult = setIPProcess.ExitCode;
                if(tapTestResult != 0) {
                    TapInterfaceTestResDialog netParametersDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NETWORK PARAMERS SETTING" +
                        System.Environment.NewLine + "The ip, netmask and gateway addresses have not been setted properly. " +
                        System.Environment.NewLine + "This won't stop the installation process but it will preclude " +
                        System.Environment.NewLine + "the correct netproxy working.",true,false);
                    netParametersDialog.ShowDialog();
                    netParametersDialog.Dispose();
                    return -1;
                }
                string macOptions = "-updateMac -d \"" + adapterDescriptor + "\" -a " + mac;
                Process setMacProcess = Process.Start(execTestFile,macOptions);
                setMacProcess.WaitForExit();
                tapTestResult = setMacProcess.ExitCode;
                if(tapTestResult != 0) {
                    TapInterfaceTestResDialog netParametersDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NETWORK PARAMERS SETTING" +
                        System.Environment.NewLine + "The mac address has not been setted properly. " +
                        System.Environment.NewLine + "This won't stop the installation process but it will preclude " +
                        System.Environment.NewLine + "the correct netproxy working.",true,false);
                    netParametersDialog.ShowDialog();
                    netParametersDialog.Dispose();
                    return -2;
                }

                // Run again the test to check the network parameters for the just installed tap interface
                Process tapTestProcess = Process.Start(execTestFile,"-testtap");
                tapTestProcess.WaitForExit();
                tapTestResult = tapTestProcess.ExitCode;
            }
            if((dr == System.Windows.Forms.DialogResult.Cancel) || (tapTestResult == -4)) {
                //netParamForm.Dispose();
                TapInterfaceTestResDialog netParametersDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NETWORK PARAMERS SETTING" +
                    System.Environment.NewLine + "The network parameters have not been setted properly. " +
                    System.Environment.NewLine + "This won't stop the installation process but it will preclude " +
                    System.Environment.NewLine + "the correct netproxy working.",true,false);
                netParametersDialog.ShowDialog();
                netParametersDialog.Dispose();
                return -3;
            }
            //netParamForm.Dispose();
            return 0;
        }
コード例 #5
0
        protected override void OnBeforeInstall(IDictionary savedState)
        {
            base.OnBeforeInstall(savedState);

            FileInfo fileInfo     = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string   execTestFile = Context.Parameters["RunInstallationTest"];

            execTestFile = Path.Combine(fileInfo.DirectoryName, execTestFile);
            Process tapTestProcess = Process.Start(execTestFile, "-testtap");

            tapTestProcess.WaitForExit();
            int tapTestResult = tapTestProcess.ExitCode;

            if (tapTestResult == -0)
            {
                TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                                                                                 System.Environment.NewLine + "The TAP interface is correctly installed and configured", false, false);
                dialog.ShowDialog();
                dialog.Dispose();
                return;
            }

            // The tap interface driver are not installed
            if (tapTestResult == -5)
            {
                TapInterfaceTestResDialog openVPnDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NO TAP-WIN32 INTERFACE FOUND" +
                                                                                        System.Environment.NewLine + "The installation process can be completed only installing the tap interface drivers. " +
                                                                                        System.Environment.NewLine + "It is possible to install the openVpn drivers from this windows. ", true, true);
                if ((openVPnDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) && (openVPnDialog.installOpenVpn()))
                {
                    string execOpenVPNFile = Context.Parameters["RunOpenVpnInstallation"];
                    execOpenVPNFile = Path.Combine(fileInfo.DirectoryName, execOpenVPNFile);
                    Process openVPNProcess = Process.Start(execOpenVPNFile);
                    openVPNProcess.WaitForExit();
                    openVPnDialog.Dispose();
                    tapTestResult = openVPNProcess.ExitCode;
                }
                else
                {
                    throw new Exception(System.Environment.NewLine + System.Environment.NewLine +
                                        "TAP INTERFACE TEST - NO TAP-WIN32 INTERFACE FOUND" + System.Environment.NewLine +
                                        "The installation process will stop");
                }

                if (tapTestResult != 0)
                {
                    throw new Exception(System.Environment.NewLine + System.Environment.NewLine +
                                        "OPENVPN INSTALLATION PROCESS - The tap interface drivers has not been correctly installed. " +
                                        System.Environment.NewLine + "The NetProxy installation process will stop");
                }

                if (tryAddressesSetting(execTestFile) == 0)
                {
                    TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                                                                                     System.Environment.NewLine + "The TAP interface is correctly installed and configured", false, false);
                    dialog.ShowDialog();
                    dialog.Dispose();
                }
                return;
            }

            // The ip address and the mac address don't match
            if (tapTestResult == -4)
            {
                if (tryAddressesSetting(execTestFile) == 0)
                {
                    TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                                                                                     System.Environment.NewLine + "The TAP interface is correctly installed and configured", false, false);
                    dialog.ShowDialog();
                    dialog.Dispose();
                }
                return;
            }

            // Other error in the tap interface test
            displayOtherErrorDialogs(tapTestResult);
        }
コード例 #6
0
        /// <summary>
        /// Method that tries to set the ip, subnet mask, default gateway
        /// and mac addresses using the .exe file specified as paramerer.
        /// The exec file set also the MTU registry to 1500 and the
        /// AllowNonAdmin registy to 1.
        /// </summary>
        /// <param name="execTestFile">Executable file to change the addresses</param>
        /// <returns>0 if everything went fine, a negative number otherwise</returns>
        private int tryAddressesSetting(string execTestFile)
        {
            int tapTestResult = -4;
            NetworkParametersForm netParamForm = new NetworkParametersForm();

            showNetworkParametersFromDialog(netParamForm);
            DialogResult dr = netParamForm.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                string adapterDescriptor = netParamForm.getAdapterDescriptor();
                string ip      = netParamForm.getIPAddress();
                string mask    = netParamForm.getMaskAddress();
                string gateway = netParamForm.getGatewayAddress();
                string mac     = netParamForm.getMACAddress();
                string ipOptions;
                if (String.IsNullOrEmpty(gateway))
                {
                    ipOptions = "-updateIP -d \"" + adapterDescriptor + "\" -ip " + ip + " -mask " + mask;
                }
                else
                {
                    ipOptions = "-updateIP -d \"" + adapterDescriptor + "\" -ip " + ip + " -mask " + mask + " -gateway " + gateway;
                }
                Process setIPProcess = Process.Start(execTestFile, ipOptions);
                setIPProcess.WaitForExit();
                tapTestResult = setIPProcess.ExitCode;
                if (tapTestResult != 0)
                {
                    TapInterfaceTestResDialog netParametersDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NETWORK PARAMERS SETTING" +
                                                                                                  System.Environment.NewLine + "The ip, netmask and gateway addresses have not been setted properly. " +
                                                                                                  System.Environment.NewLine + "This won't stop the installation process but it will preclude " +
                                                                                                  System.Environment.NewLine + "the correct netproxy working.", true, false);
                    netParametersDialog.ShowDialog();
                    netParametersDialog.Dispose();
                    return(-1);
                }
                string  macOptions    = "-updateMac -d \"" + adapterDescriptor + "\" -a " + mac;
                Process setMacProcess = Process.Start(execTestFile, macOptions);
                setMacProcess.WaitForExit();
                tapTestResult = setMacProcess.ExitCode;
                if (tapTestResult != 0)
                {
                    TapInterfaceTestResDialog netParametersDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NETWORK PARAMERS SETTING" +
                                                                                                  System.Environment.NewLine + "The mac address has not been setted properly. " +
                                                                                                  System.Environment.NewLine + "This won't stop the installation process but it will preclude " +
                                                                                                  System.Environment.NewLine + "the correct netproxy working.", true, false);
                    netParametersDialog.ShowDialog();
                    netParametersDialog.Dispose();
                    return(-2);
                }

                // Run again the test to check the network parameters for the just installed tap interface
                Process tapTestProcess = Process.Start(execTestFile, "-testtap");
                tapTestProcess.WaitForExit();
                tapTestResult = tapTestProcess.ExitCode;
            }
            if ((dr == System.Windows.Forms.DialogResult.Cancel) || (tapTestResult == -4))
            {
                //netParamForm.Dispose();
                TapInterfaceTestResDialog netParametersDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NETWORK PARAMERS SETTING" +
                                                                                              System.Environment.NewLine + "The network parameters have not been setted properly. " +
                                                                                              System.Environment.NewLine + "This won't stop the installation process but it will preclude " +
                                                                                              System.Environment.NewLine + "the correct netproxy working.", true, false);
                netParametersDialog.ShowDialog();
                netParametersDialog.Dispose();
                return(-3);
            }
            //netParamForm.Dispose();
            return(0);
        }