コード例 #1
0
        public override void FlushDNS()
        {
            base.FlushDNS();

            // 10.5 - 10.6
            string dscacheutilPath = LocateExecutable("dscacheutil");

            if (dscacheutilPath != "")
            {
                SystemShell.Shell1(dscacheutilPath, "-flushcache");
            }

            // 10.7 - 10.8 - 10.9 - 10.10.4 - 10.11 - Sierra 10.12.0
            string killallPath = LocateExecutable("killall");

            if (killallPath != "")
            {
                SystemShell.Shell2(killallPath, "-HUP", "mDNSResponder");
            }

            // 10.10.0 - 10.10.3
            string discoveryutilPath = LocateExecutable("discoveryutil");

            if (discoveryutilPath != "")
            {
                SystemShell.Shell1(discoveryutilPath, "udnsflushcaches");
                SystemShell.Shell1(discoveryutilPath, "mdnsflushcache");
            }
        }
コード例 #2
0
        public override void OnReport(Report report)
        {
            base.OnReport(report);

            report.Add("ip addr show", (LocateExecutable("ip") != "") ? SystemShell.Shell2(LocateExecutable("ip"), "addr", "show") : "'ip' " + LanguageManager.GetText("NotFound"));
            report.Add("ip link show", (LocateExecutable("ip") != "") ? SystemShell.Shell2(LocateExecutable("ip"), "link", "show") : "'ip' " + LanguageManager.GetText("NotFound"));
            report.Add("ip -4 route show", (LocateExecutable("ip") != "") ? SystemShell.Shell3(LocateExecutable("ip"), "-4", "route", "show") : "'ip' " + LanguageManager.GetText("NotFound"));
            report.Add("ip -6 route show", (LocateExecutable("ip") != "") ? SystemShell.Shell3(LocateExecutable("ip"), "-6", "route", "show") : "'ip' " + LanguageManager.GetText("NotFound"));
        }
コード例 #3
0
ファイル: Platform.cs プロジェクト: siemantic/Eddie
        public override void OnReport(Report report)
        {
            base.OnReport(report);

            report.Add("UID", Conversions.ToString(m_uid));
            report.Add("LogName", m_logname);
            report.Add("ip addr show", (LocateExecutable("ip") != "") ? SystemShell.Shell2(LocateExecutable("ip"), "addr", "show") : "'ip' " + Messages.NotFound);
            report.Add("ip link show", (LocateExecutable("ip") != "") ? SystemShell.Shell2(LocateExecutable("ip"), "link", "show") : "'ip' " + Messages.NotFound);
            report.Add("ip route show", (LocateExecutable("ip") != "") ? SystemShell.Shell2(LocateExecutable("ip"), "route", "show") : "'ip' " + Messages.NotFound);
        }
コード例 #4
0
ファイル: Platform.cs プロジェクト: siemantic/Eddie
        public override List <RouteEntry> RouteList()
        {
            List <RouteEntry> entryList = new List <RouteEntry>();

            // TOFIX: "route" not available on recent Linux systems.
            // Need to be adapted to "ip". But it's used only for "Remove default gateway" feature, useless for a lots of reason, deprecated soon.
            string routePath = LocateExecutable("route");

            if (routePath == "")
            {
                Engine.Instance.Logs.Log(LogType.Error, "'route' " + Messages.NotFound);
            }
            else
            {
                string result = SystemShell.Shell2(routePath, "-n", "-ee");

                string[] lines = result.Split('\n');
                foreach (string line in lines)
                {
                    string[] fields = Utils.StringCleanSpace(line).Split(' ');

                    if (fields.Length == 11)
                    {
                        RouteEntry e = new RouteEntry();
                        e.Address = fields[0];
                        e.Gateway = fields[1];
                        e.Mask    = fields[2];
                        e.Flags   = fields[3].ToUpperInvariant();
                        e.Metrics = fields[4];
                        // Ref, Use ignored
                        e.Interface = fields[7];
                        e.Mss       = fields[8];
                        e.Window    = fields[9];
                        e.Irtt      = fields[10];

                        if (e.Address.Valid == false)
                        {
                            continue;
                        }
                        if (e.Gateway.Valid == false)
                        {
                            continue;
                        }
                        if (e.Mask.Valid == false)
                        {
                            continue;
                        }

                        entryList.Add(e);
                    }
                }
            }

            return(entryList);
        }
コード例 #5
0
        public override string GetExecutableReport(string path)
        {
            string otoolPath = LocateExecutable("otool");

            if (otoolPath != "")
            {
                return(SystemShell.Shell2(otoolPath, "-L", SystemShell.EscapePath(path)));
            }
            else
            {
                return("'otool' " + Messages.NotFound);
            }
        }
コード例 #6
0
ファイル: Platform.cs プロジェクト: DreamAuth/Eddie
        public override string GetExecutableReport(string path)
        {
            string otoolPath = LocateExecutable("otool");

            if (otoolPath != "")
            {
                return(SystemShell.Shell2(otoolPath, "-L", SystemShell.EscapePath(path)));
            }
            else
            {
                return("'otool' " + LanguageManager.GetText("NotFound"));
            }
        }
コード例 #7
0
ファイル: Platform.cs プロジェクト: siemantic/Eddie
        public override Dictionary <int, string> GetProcessesList()
        {
            Dictionary <int, string> result = new Dictionary <int, string>();
            string psPath = LocateExecutable("ps");

            if (psPath != "")
            {
                string   resultS = SystemShell.Shell2(psPath, "-eo", "pid,command");
                string[] resultA = resultS.Split('\n');
                foreach (string pS in resultA)
                {
                    int posS = pS.IndexOf(' ');
                    if (posS != -1)
                    {
                        int    pid  = Conversions.ToInt32(pS.Substring(0, posS).Trim());
                        string name = pS.Substring(posS).Trim();
                        result[pid] = name;
                    }
                }
            }

            return(result);
        }
コード例 #8
0
ファイル: Platform.cs プロジェクト: DreamAuth/Eddie
        public override Dictionary <string, string> GetProcessesList()
        {
            // We experience some crash under OSX with the base method.
            Dictionary <string, string> result = new Dictionary <string, string>();
            string psPath = LocateExecutable("ps");

            if (psPath != "")
            {
                string   resultS = SystemShell.Shell2(psPath, "-eo", "pid,command");
                string[] resultA = resultS.Split('\n');
                foreach (string pS in resultA)
                {
                    int posS = pS.IndexOf(' ');
                    if (posS != -1)
                    {
                        string pid  = pS.Substring(0, posS).Trim();
                        string name = pS.Substring(posS).Trim();
                        result[pid] = name;
                    }
                }
            }

            return(result);
        }
コード例 #9
0
ファイル: Platform.cs プロジェクト: siemantic/Eddie
        public override void FlushDNS()
        {
            base.FlushDNS();

            string servicePath = LocateExecutable("service");

            if (servicePath != "")
            {
                Dictionary <string, string> services = new Dictionary <string, string>();
                string list = SystemShell.Shell1(servicePath, "--status-all");
                list = Utils.StringCleanSpace(list);
                foreach (string line in list.Split('\n'))
                {
                    if (line.Contains(" running "))
                    {
                        int pos = line.IndexOf(".service");
                        if (pos != -1)
                        {
                            string name = line.Substring(0, pos).Trim();
                            services[name] = name;
                        }
                    }
                }

                if (services.ContainsKey("nscd"))
                {
                    SystemShell.Shell2(servicePath, "nscd", "restart");
                }
                if (services.ContainsKey("dnsmasq"))
                {
                    SystemShell.Shell2(servicePath, "dnsmasq", "restart");
                }
                if (services.ContainsKey("named"))
                {
                    SystemShell.Shell2(servicePath, "named", "restart");
                }
                if (services.ContainsKey("bind9"))
                {
                    SystemShell.Shell2(servicePath, "bind9", "restart");
                }
            }
            else
            {
                if (FileExists("/etc/init.d/nscd"))
                {
                    SystemShell.Shell1("/etc/init.d/nscd", "restart");
                }
                if (FileExists("/etc/init.d/dnsmasq"))
                {
                    SystemShell.Shell1("/etc/init.d/dnsmasq", "restart");
                }
                if (FileExists("/etc/init.d/named"))
                {
                    SystemShell.Shell1("/etc/init.d/named", "restart");
                }
                if (FileExists("/etc/init.d/bind9"))
                {
                    SystemShell.Shell1("/etc/init.d/bind9", "restart");
                }
            }

            // On some system, for example Fedora, nscd caches are saved to disk,
            // located in /var/db/nscd, and not flushed with a simple restart.
            string nscdPath = LocateExecutable("nscd");

            if (nscdPath != "")
            {
                SystemShell.Shell1(nscdPath, "--invalidate=hosts");
            }
        }