Пример #1
0
        // SHOW ROUTER SETTINGS
        private void btnShowRouterSettings_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if ((nathelper == null) || (!nathelper.GatewayFound))
            {
                RPMessageBox.ShowAlert("A compatible router (UPnP) could not be found on your network.");
                return;
            }

            string strMappings = nathelper.ListMappings();

            RPMessageBox.Show(strMappings, "Router Port Mappings");
        }
Пример #2
0
        void AddPortForwardingRules()
        {
            if (nathelper == null)
            {
                return;
            }
            if (!nathelper.GatewayFound)
            {
                return;
            }

            ChangeActivityStatus("Checking Local IP Address...");

            if (string.IsNullOrWhiteSpace(LocalIP))
            {
                ChangeBlurbText("Remote Potato could not get the local IP address, so could not set up your router.");
            }
            else
            {
                ChangeActivityStatus("Checking for router...");
                string txtError = "";

                // Manual rules
                int    lowestStreamPort  = Convert.ToInt32(Settings.Default.SilverlightStreamingPort);
                int    highestStreamPort = lowestStreamPort + Settings.Default.SilverlightStreamingNumberOfPorts - 1;
                string txtManualRules    = String.Format("You need to forward port {0} and ports {1}-{2} to IP address {3} (this computer)\r\n\r\nNeed help? Visit www.portforward.com", Settings.Default.RPPortWithLiveTV.ToString(), lowestStreamPort.ToString(), highestStreamPort.ToString(), LocalIP);

                if (!nathelper.Discover(ref txtError))
                {
                    ChangeBlurbText("Remote Potato could not find a router on your local network - have you disabled UPnP on your router?\r\n\r\n" + txtManualRules);
                }
                else
                {
                    ChangeActivityStatus("Setting up router...");
                    if (nathelper.ForwardRPPorts(LocalIP) == NATHelper.NatHelperReponseCodes.OK)
                    {
                        RPMessageBox.Show("Your router has been automatically set up for Remote Potato.\r\nClick OK to verify the changes.");
                        // TODO:
                        CheckPortForwarding();
                    }
                    else
                    {
                        ChangeBlurbText("Your router could not be automatically set up (see the debug log for more information)\r\n\r\n." + txtManualRules);
                    }
                }

                nathelper = null;
            }

            // Finished - hide mask
            this.Invoke(new Action(HideActivityMask));
        }
Пример #3
0
        public static void AskThenAddFirewallRules()
        {
            if (RPMessageBox.ShowQuestion("Do you use Windows Firewall?  If so, we can add rules to your firewall to allow Remote Potato to be accessed over the Internet.  You will only ever need to do this once, unless you change port numbers.\r\n\r\nDo you want to do this now?", "Add Firewall Rules?") == DialogResult.No)
            {
                return;
            }

            if (AddFirewallRules())
            {
                RPMessageBox.Show("The rules were successfully added to Windows Firewall.\r\n\r\nRemember, you do not need to do this again unless you change port numbers.");
            }
            else
            {
                RPMessageBox.ShowAlert("There was an error adding the rules to Windows Firewall - see debug log for more information.\r\n\r\nClick the 'Re-add firewall rules' button to try this again.");
            }
        }
Пример #4
0
        void TryToChangeMediaLibraryAccount()
        {
            lblStatus.Text = "Please wait - making changes...";
            Application.DoEvents();

            string AccountName = txtMediaLibraryUsername.Text.Trim();
            string Password    = txtMediaLibraryPassword.Text.Trim();

            if (string.IsNullOrEmpty(AccountName))
            {
                lblStatus.Text = "You must enter the details of a user of this machine.";
                return;
            }

            if (string.IsNullOrEmpty(Password))
            {
                // Services require a login with a password if limited in registry  see http://stackoverflow.com/questions/1047854/cant-run-a-service-under-an-account-which-has-no-password
                if (Functions.IsBlankPasswordLimitedOnMachine)
                {
                    if (RPMessageBox.ShowQuestion("Blank passwords for services are currently limited on this machine.\r\n\r\nDo you wish to lift this security restriction so that Remote Potato can run?", "Allow blank passwords on machine?")
                        == DialogResult.Yes)
                    {
                        Functions.SetBlankPasswordLimitOnMachine(false);
                    }
                    else
                    {
                        RPMessageBox.Show("To allow Remote Potato to run, please use an account that has a Username and a Password");
                        return;
                    }
                }
            }
            else  // re-instate blank password limit?
            {
                if (!Functions.IsBlankPasswordLimitedOnMachine)
                {
                    if (RPMessageBox.ShowQuestion("Blank passwords for services are currently allowed on this machine.  Unless you require this security relaxation for other services or remotely access user accounts on this machine that have no password, you should re-enable this security restriction.\r\n\r\nDo you wish to forbid blank passwords for services?", "Forbid blank passwords on machine?")
                        == DialogResult.Yes)
                    {
                        Functions.SetBlankPasswordLimitOnMachine(true);
                    }
                }
            }

            if (!ValidateCredentials(AccountName, Password))
            {
                lblStatus.Text = "The log on details that you entered were incorrect.";
                return;
            }



            //if (!SetServiceLogon("Remote Potato Service", AccountName, Password, true)) return;
            string strErrorText = string.Empty;

            if (!ServiceManager.SetRPServiceLogon(AccountName, Password, false, ref strErrorText))
            {
                lblStatus.Text = "Could not use this account - please check the details:" + strErrorText;
                return;
            }

            if (!SetLogOnAsServiceRight(AccountName))
            {
                RPMessageBox.ShowAlert("Could not add required security priviliges to this account - please check that you running as an Administrator, and that you have entered the details correctly.");
                lblStatus.Text = "Error setting priviliges.";
                return;
            }

            lblStatus.Text = string.Empty;
            CommitAndClose();
        }