示例#1
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            PopulatePriorities(); //populate before loading settings
            LoadSettings();
            autoLaunchCheckBox.Enabled = OSVersionPlatform.GetGenericPlatform() != PlatformID.Unix;
            sysTrayCheckBox.Enabled    = OSVersionPlatform.GetGenericPlatform() != PlatformID.Unix;

            coinApiCombo.SelectedIndex = applicationConfiguration.UseCoinWarzApi ? CoinWarzIndex :
                                         (applicationConfiguration.UseWhatMineApi ? WhatMineIndex :
                                          (applicationConfiguration.UseWhatToMineApi ? WhatToMineIndex :
                                           CoinChooseIndex));
            PopulateApiKey();
        }
示例#2
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            // adjust height for hidden MobileMiner settings
            Height = Height - 65;

            PopulatePriorities(); //populate before loading settings
            LoadSettings();
            autoLaunchCheckBox.Enabled = OSVersionPlatform.GetGenericPlatform() != PlatformID.Unix;
            sysTrayCheckBox.Enabled    = OSVersionPlatform.GetGenericPlatform() != PlatformID.Unix;

            coinApiCombo.SelectedIndex = applicationConfiguration.UseCoinWarzApi ? CoinWarzIndex : WhatToMineIndex;
            PopulateApiKey();
        }
示例#3
0
        public static void UnzipFileToFolder(string zipFilePath, string destionationFolder)
        {
            Directory.CreateDirectory(destionationFolder);

            if (OSVersionPlatform.GetGenericPlatform() == PlatformID.Unix)
            {
                UnzipFileToFolderUnix(zipFilePath, destionationFolder);
            }
#if !__MonoCS__
            else
            {
                UnzipFileToFolderWindows(zipFilePath, destionationFolder);
            }
#endif
        }
示例#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);
                result = parser["Workgroup"].ToString();
            }
            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
        private void coinListBox_MouseMove(object sender, MouseEventArgs e)
        {
            //not supported on mono
            if (OSVersionPlatform.GetGenericPlatform() == PlatformID.Unix)
            {
                return;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (coinListBox.SelectedItem == null)
                {
                    return;
                }
                coinListBox.DoDragDrop(coinListBox.SelectedItem, DragDropEffects.Move);
            }
        }
示例#6
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);
        }
示例#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
        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();
                }
            }
        }
示例#9
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);
        }
示例#10
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);
        }
示例#11
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);
        }
示例#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);
        }
示例#13
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;
        }
示例#14
0
        private static void RunApplication()
        {
            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());
        }
 private void UpdateAutoCheckBox()
 {
     autoDesktopCheckBox.Enabled = !disableGpuCheckbox.Checked && (OSVersionPlatform.GetGenericPlatform() != PlatformID.Unix);
 }
示例#16
0
        internal static string GetIPv4Mask(string networkInterfaceName)
        {
            if (OSVersionPlatform.GetGenericPlatform() != PlatformID.Unix)
            {
                throw new NotImplementedException();
            }

            IntPtr ifap;

            if (getifaddrs(out ifap) != 0)
            {
                throw new SystemException("getifaddrs() failed");
            }

            try
            {
                var next = ifap;
                while (next != IntPtr.Zero)
                {
                    var addr = (ifaddrs)Marshal.PtrToStructure(next, typeof(ifaddrs));
                    var name = addr.ifa_name;

                    if (addr.ifa_addr != IntPtr.Zero)
                    {
                        var sockaddr = (sockaddr_in)Marshal.PtrToStructure(addr.ifa_addr, typeof(sockaddr_in));
                        switch (sockaddr.sin_family)
                        {
                        case AF_INET6:
                            break;

                        case AF_INET:
                            if (name == networkInterfaceName)
                            {
                                var netmask = (sockaddr_in)Marshal.PtrToStructure(addr.ifa_netmask, typeof(sockaddr_in));
                                var ipAddr  = new IPAddress(netmask.sin_addr);     // IPAddress to format into default string notation
                                return(ipAddr.ToString());
                            }
                            break;

                        case AF_PACKET:
                        {
                            var sockaddrll = (sockaddr_ll)Marshal.PtrToStructure(addr.ifa_addr, typeof(sockaddr_ll));
                            if (sockaddrll.sll_halen > sockaddrll.sll_addr.Length)
                            {
                                Console.Error.WriteLine("Got a bad hardware address length for an AF_PACKET {0} {1}",
                                                        sockaddrll.sll_halen, sockaddrll.sll_addr.Length);
                                next = addr.ifa_next;
                                continue;
                            }
                        }
                        break;
                        }
                    }

                    next = addr.ifa_next;
                }
            }
            finally
            {
                freeifaddrs(ifap);
            }

            return(null);
        }
        public static List <NetworkInterfaceInfo> GetLocalNetworkInterfaces(
            SubnetClass subnetClasses = SubnetClass.C,
            bool flushCache           = false)
        {
            if (flushCache)
            {
                localNetworkInterfaces = null;
            }

            if (localNetworkInterfaces != null)
            {
                return(localNetworkInterfaces);
            }

            List <NetworkInterfaceInfo> workingInterfaces = new List <NetworkInterfaceInfo>();

            NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface networkInterface in networkInterfaces)
            {
                if ((networkInterface.NetworkInterfaceType == NetworkInterfaceType.Loopback) ||
                    (networkInterface.NetworkInterfaceType == NetworkInterfaceType.Tunnel) ||
                    (networkInterface.OperationalStatus != OperationalStatus.Up))
                {
                    continue;
                }

                IPInterfaceProperties ipProperties = networkInterface.GetIPProperties();
                foreach (UnicastIPAddressInformation ipInformation in ipProperties.UnicastAddresses)
                {
                    IPAddress ipv4Mask = null;

                    if (OSVersionPlatform.GetGenericPlatform() == PlatformID.Unix)
                    {
                        //Mono does not implement IPv4Mask
                        //see https://bugzilla.xamarin.com/show_bug.cgi?id=2033
                        string mask = IPInfoTools.GetIPv4Mask(networkInterface.Name);
                        if (mask == null || IPAddress.TryParse(mask, out ipv4Mask) == false)
                        {
                            ipv4Mask = IPAddress.Parse("255.255.255.0"); // default to this
                        }
                    }
                    else
                    {
                        ipv4Mask = ipInformation.IPv4Mask;
                    }

                    SubnetClass interfaceClass = ipv4Mask.GetSubnetClass();

                    //optionally scan class A & B subnets
                    if (!((subnetClasses & interfaceClass) == interfaceClass))
                    {
                        continue;
                    }

                    IPAddress ipAddress = ipInformation.Address;

                    if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
                    {
                        NetworkInterfaceInfo interfaceInfo = new NetworkInterfaceInfo();

                        interfaceInfo.Host      = ipAddress;
                        interfaceInfo.Netmask   = ipv4Mask;
                        interfaceInfo.Broadcast = GetBroadcastAddress(interfaceInfo.Host, interfaceInfo.Netmask);

                        //deprecations are known - we only support IPv4 scanning with this code
                        //see above check for AddressFamily.InterNetwork
                        long host       = (long)(uint)IPAddress.NetworkToHostOrder((int)interfaceInfo.Host.Address);
                        long netmask    = (long)(uint)IPAddress.NetworkToHostOrder((int)interfaceInfo.Netmask.Address);
                        long broadcast  = (long)(uint)IPAddress.NetworkToHostOrder((int)interfaceInfo.Broadcast.Address);
                        long network    = host & netmask;
                        long rangeStart = network + 1;
                        long rangeEnd   = broadcast - 1;

                        //e.g. if host == broadcast, netmask == 255.255.255.255
                        if (rangeEnd < rangeStart)
                        {
                            long swap = rangeEnd;
                            rangeEnd   = rangeStart;
                            rangeStart = swap;
                        }

                        interfaceInfo.RangeStart = new IPAddress((long)(uint)IPAddress.HostToNetworkOrder((int)rangeStart));
                        interfaceInfo.RangeEnd   = new IPAddress((long)(uint)IPAddress.HostToNetworkOrder((int)rangeEnd));

                        workingInterfaces.Add(interfaceInfo);
                    }
                }
            }

            //cache the results
            localNetworkInterfaces = workingInterfaces;

            return(localNetworkInterfaces);
        }