示例#1
0
        static void Main()
        {
            if (OSVersionPlatform.GetConcretePlatform() == PlatformID.Unix)
            {
                ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) =>
                {
                    if (sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors)
                    {
                        foreach (X509ChainStatus status in chain.ChainStatus)
                        {
                            if (status.Status != X509ChainStatusFlags.RevocationStatusUnknown)
                            {
                                return(false);
                            }
                        }
                    }
                    return(true);
                };
            }



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
示例#2
0
        private static void RunApplication()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


            if (OSVersionPlatform.GetConcretePlatform() == PlatformID.Unix)
            {
                ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) =>
                {
                    if (sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors)
                    {
                        foreach (X509ChainStatus status in chain.ChainStatus)
                        {
                            if (status.Status != X509ChainStatusFlags.RevocationStatusUnknown)
                            {
                                return(false);
                            }
                        }
                    }
                    return(true);
                };
            }

            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
            System.Windows.Forms.Application.Run(new MinerForm());
        }
示例#3
0
        public static void InstallMiner(string userAgent, AvailableMiner miner, string destinationFolder)
        {
            //support Windows and OS X for now, we'll go for Linux in the future
            if (OSVersionPlatform.GetConcretePlatform() == PlatformID.Unix)
            {
                throw new NotImplementedException();
            }

            string minerDownloadFile = Path.Combine(Path.GetTempPath(), "miner.zip");

            File.Delete(minerDownloadFile);

            WebClient webClient = new WebClient();

            webClient.Headers.Add("user-agent", userAgent);

            webClient.DownloadFile(new Uri(miner.Url), minerDownloadFile);
            try
            {
                //first delete the folder contents. this became necessary with cgminer 3.8.0 because
                //ck stopped shipping cgminer-nogpu.exe, which would leave an old executable behind
                //and gum up the works later (running an older exe to find the installed version)
                DeleteFolderContents(destinationFolder);

                Unzipper.UnzipFileToFolder(minerDownloadFile, destinationFolder);
            }
            finally
            {
                File.Delete(minerDownloadFile);
            }
        }
示例#4
0
        public static string GetWorkGroupName()
        {
            string result = String.Empty;

            if (OSVersionPlatform.GetConcretePlatform() == PlatformID.MacOSX)
            {
                //OS X
                string      configFilePath = @"/Library/Preferences/SystemConfiguration/com.apple.smb.server.plist";
                PlistParser parser         = new PlistParser(configFilePath);

                const string workgroupKey = "Workgroup";
                if (parser.ContainsKey(workgroupKey))
                {
                    result = parser[workgroupKey].ToString();
                }
                else
                {
                    const string defaultWorkgroup = "WORKGROUP";
                    result = defaultWorkgroup;
                }
            }
            else if (OSVersionPlatform.GetGenericPlatform() == PlatformID.Unix)
            {
                //Linux
                string        configFilePath = @"/etc/samba/smb.conf";
                IniFileParser parser         = new IniFileParser(configFilePath);
                result = parser.GetValue("Global", "Workgroup");
            }
            else
            {
                //Windows
                using (ManagementObject managementObject = new ManagementObject(String.Format("Win32_ComputerSystem.Name='{0}'", Environment.MachineName)))
                {
                    object workgroup = managementObject["Workgroup"];

                    //Workgroup is NULL under XP and Server OS
                    //instead read Domain
                    if (workgroup == null)
                    {
                        workgroup = managementObject["Domain"];
                        const string LocalSuffix = ".local";
                        if (workgroup != null)
                        {
                            string domain = (string)workgroup;
                            if (domain.EndsWith(LocalSuffix))
                            {
                                domain = Path.GetFileNameWithoutExtension(domain);
                            }
                            workgroup = domain;
                        }
                    }

                    result = workgroup.ToString();
                }
            }
            return(result);
        }
示例#5
0
        public static string GetPathToInstalledMiner()
        {
            string executablePath = string.Empty;
            string minerName      = GetMinerName();

            switch (OSVersionPlatform.GetConcretePlatform())
            {
            case PlatformID.MacOSX:
                //try local path first
                executablePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"Miners/{0}/bin/{0}", minerName));

                if (!File.Exists(executablePath))
                {
                    //try global path (Homebrew)
                    executablePath = string.Format(@"/usr/local/bin/{0}", minerName);
                }

                break;

            //support Unix - there is no bin folder for the executables like on Mac OS X
            case PlatformID.Unix:
                //try local path first
                executablePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"Miners/{0}/{0}", minerName));

                if (!File.Exists(executablePath))
                {
                    //try /usr/local/bin
                    executablePath = string.Format(@"/usr/local/bin/{0}", minerName);
                }

                if (!File.Exists(executablePath))
                {
                    //try /usr/bin
                    executablePath = string.Format(@"/usr/bin/{0}", minerName);
                }

                break;

            default:
                executablePath = string.Format(@"Miners\{0}\{0}.exe", minerName);
                break;
            }

            return(executablePath);
        }
示例#6
0
        private void nextButton_Click(object sender, EventArgs e)
        {
            if (!ValidateInput())
            {
                return;
            }

            if (wizardTabControl.SelectedTab == chooseMinerPage)
            {
                MinerBackend minerBackend = GetSelectedMinerBackend();
                if (MinerIsInstalled(minerBackend))
                {
                    wizardTabControl.SelectedIndex += 2;
                }
                else
                {
                    wizardTabControl.SelectedIndex += 1;
                }
            }
            else
            {
                if (wizardTabControl.SelectedIndex < wizardTabControl.TabPages.Count - 1)
                {
                    wizardTabControl.SelectedIndex += 1;
                }
                else
                {
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }


            if (wizardTabControl.SelectedTab == downloadingMinerPage)
            {
                if (OSVersionPlatform.GetConcretePlatform() == PlatformID.Unix)
                {
                    showLinuxInstallationInstructions();
                }
                else
                {
                    DownloadChosenMiner();
                }
            }
        }
示例#7
0
        private void UpdateButtons()
        {
            bool nextButtonEnabled  = true;
            bool closeButtonEnabled = true;
            bool backButtonEnabled  = true;

            if (wizardTabControl.SelectedIndex == wizardTabControl.TabPages.Count - 1)
            {
                nextButton.Text = "Finish";
            }
            else
            {
                nextButton.Text = "Next >";
            }

            backButtonEnabled = wizardTabControl.SelectedIndex > 0;

            if (wizardTabControl.SelectedTab == chooseCoinPage)
            {
                nextButtonEnabled = coinComboBox.Text != "-";
            }
            else if (wizardTabControl.SelectedTab == configurePoolPage)
            {
                int dummy;
                nextButtonEnabled = !String.IsNullOrEmpty(hostEdit.Text) &&
                                    !String.IsNullOrEmpty(portEdit.Text) &&
                                    !String.IsNullOrEmpty(usernameEdit.Text) &&
                                    Int32.TryParse(portEdit.Text, out dummy);
            }
            else if (wizardTabControl.SelectedTab == downloadingMinerPage)
            {
                //no downloading miners under Linux
                if (OSVersionPlatform.GetConcretePlatform() != PlatformID.Unix)
                {
                    nextButtonEnabled  = false;
                    backButtonEnabled  = false;
                    closeButtonEnabled = false;
                }
            }

            nextButton.Enabled  = nextButtonEnabled;
            closeButton.Enabled = closeButtonEnabled;
            backButton.Enabled  = backButtonEnabled;
        }
示例#8
0
        public static List <AvailableMiner> GetAvailableMiners(string userAgent)
        {
            WebClient webClient = new ApiWebClient();

            webClient.Headers.Add("user-agent", userAgent);

            string platform = "win64";

            if (OSVersionPlatform.GetConcretePlatform() == PlatformID.MacOSX)
            {
                platform = "osx64";
            }

            string url      = "https://raw.githubusercontent.com/zawawawa/gatelessgate/Misc/Miners-" + platform + ".json";
            string response = webClient.DownloadString(new Uri(url));

            List <AvailableMiner> availableMiners = JsonConvert.DeserializeObject <List <AvailableMiner> >(response);

            return(availableMiners);
        }
示例#9
0
        public static List <AvailableMiner> GetAvailableMiners(string userAgent)
        {
            WebClient webClient = new ApiWebClient();

            webClient.Headers.Add("user-agent", userAgent);

            string platform = "win32";

            if (OSVersionPlatform.GetConcretePlatform() == PlatformID.MacOSX)
            {
                platform = "osx64";
            }

            //include www. to avoid redirect
            string url      = "http://www.LiquidHashapp.com/miners?platform=" + platform;
            string response = webClient.DownloadString(new Uri(url));

            List <AvailableMiner> availableMiners = JsonConvert.DeserializeObject <List <AvailableMiner> >(response);

            return(availableMiners);
        }
示例#10
0
        private static string GetPathToBFGMiner(string minerName)
        {
            string executablePath;

            switch (OSVersionPlatform.GetConcretePlatform())
            {
            case PlatformID.MacOSX:
                executablePath = GetPathToMinerOnMacOSX(minerName);
                break;

            //support Unix - there is no bin folder for the executables like on Mac OS X
            case PlatformID.Unix:
                executablePath = GetPathToMinerOnLinux(minerName);
                break;

            default:
                executablePath = GetPathToMinerOnWindows(minerName, minerName);
                break;
            }
            return(executablePath);
        }
示例#11
0
        public void Startup()
        {
            //use Dns.GetHostName() instead of localhost for compatibility with Mono+Linux
            //https://github.com/nwoolls/MultiMiner/issues/62
            string hostname = Dns.GetHostName();

            if (OSVersionPlatform.GetConcretePlatform() == PlatformID.MacOSX)
            {
                //otherwise Windows -> OS X gets connection refused (though Linux -> OS X works)
                hostname = "localhost";
            }

            Uri baseAddress = new Uri(String.Format("net.tcp://{0}:{1}/RemotingService", hostname, Config.RemotingPort));

            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

            myServiceHost = new ServiceHost(typeof(RemotingService), baseAddress);
            myServiceHost.AddServiceEndpoint(typeof(IRemotingService), binding, baseAddress);

            myServiceHost.Open();

            serviceStarted = true;
        }
示例#12
0
        public static string GetPathToInstalledMiner(MinerDescriptor miner)
        {
            string executablePath;

            switch (OSVersionPlatform.GetConcretePlatform())
            {
            case PlatformID.MacOSX:
                executablePath = GetPathToMinerOnMacOSX(miner.Name, miner.FileName);
                break;

            //support Unix - there is no bin folder for the executables like on Mac OS X
            case PlatformID.Unix:
                //file launching is case-sensitive, lower-case the filename
                executablePath = GetPathToMinerOnLinux(miner.FileName, miner.FileName.ToLower());
                break;

            default:
                executablePath = GetPathToMinerOnWindows(miner.Name, miner.FileName);
                break;
            }

            return(executablePath);
        }