예제 #1
0
파일: Platform.cs 프로젝트: siemantic/Eddie
        public virtual List <string> GetEnvironmentPaths()
        {
            string        envPath = Environment.GetEnvironmentVariable("PATH");
            List <string> paths   = Utils.StringToList(envPath, EnvPathSep, true, true, true, true);

            return(paths);
        }
예제 #2
0
        public void NormalizeRelativePathDirective(string name, string basePath)
        {
            List <Directive> list = GetDirectiveList(name);

            if (list != null)
            {
                foreach (Directive d in list)
                {
                    string        body   = d.Text;
                    List <string> fields = Utils.StringToList(body, " ");
                    if (fields.Count < 1)
                    {
                        return;
                    }
                    string path = fields[0];
                    fields.RemoveAt(0);
                    if ((path.StartsWith("\"")) && (path.EndsWith("\"")))
                    {
                        path = path.Substring(1, path.Length - 2);
                    }
                    path   = Platform.Instance.FileGetAbsolutePath(path, basePath);
                    d.Text = "\"" + path.Replace("\\", "\\\\") + "\" " + String.Join(" ", fields.ToArray());
                    d.Text = d.Text.Trim();
                }
            }
        }
예제 #3
0
        public IpAddresses GetAllIps(bool includeIpUsedByClient)
        {
            IpAddresses result = new IpAddresses();

            // Custom
            {
                string list = Engine.Instance.Storage.Get("netlock.allowed_ips");
                list = list.Replace("\u2028", ",");                 // OS X Hack  // TOCLEAN
                List <string> hosts = Utils.StringToList(list);
                foreach (string host in hosts)
                {
                    string host2      = host;
                    int    posComment = host2.IndexOf("#");
                    if (posComment != -1)
                    {
                        host2 = host2.Substring(0, posComment).Trim();
                    }

                    result.Add(host2);
                }
            }

            // Routes Out
            {
                string   routes  = Engine.Instance.Storage.Get("routes.custom");
                string[] routes2 = routes.Split(';');
                foreach (string route in routes2)
                {
                    string[] routeEntries = route.Split(',');
                    if (routeEntries.Length < 2)
                    {
                        continue;
                    }

                    string host   = routeEntries[0];
                    string action = routeEntries[1];

                    if (action == "out")
                    {
                        result.Add(host);
                    }
                }
            }

            // DNS
            if (Engine.Instance.Storage.GetBool("netlock.allow_dns"))
            {
                result.Add(Platform.Instance.DetectDNS());
            }

            if (includeIpUsedByClient)
            {
                // Providers
                foreach (Provider provider in Engine.Instance.ProvidersManager.Providers)
                {
                    result.Add(provider.GetNetworkLockAllowedIps());
                }

                // Servers
                lock (Engine.Instance.Connections)
                {
                    Dictionary <string, ConnectionInfo> servers = new Dictionary <string, ConnectionInfo>(Engine.Instance.Connections);

                    foreach (ConnectionInfo infoServer in servers.Values)
                    {
                        result.Add(infoServer.IpsEntry);
                    }
                }
            }

            return(result);
        }
예제 #4
0
        // Called for user events
        public static void ShellUserEvent(string path, string arguments, bool waitEnd)
        {
            List <string> args = Utils.StringToList(arguments, " ", true, true, false, false);

            Shell(path, args.ToArray(), waitEnd);
        }