Example #1
0
 public void AddUser(HueUser user)
 {
     if (!WhiteList.ContainsKey(user.Id))
     {
         WhiteList.Add(user.Id, user);
     }
 }
Example #2
0
 public static bool WhiteListContains(string type, string value)
 {
     if (!WhiteList.ContainsKey(type))
     {
         return(false);
     }
     else
     {
         return(WhiteList[type] == value);
     }
 }
Example #3
0
        private static void CheckFiles()
        {
            var gameFilePaths = Directory.GetFiles(CommonUtil.CombinePaths(Client.KspPath, "GameData"), "*",
                                                   SearchOption.AllDirectories);
            var gameFileRelativePaths =
                gameFilePaths.Select(
                    filePath =>
                    filePath.Substring(filePath.ToLowerInvariant().IndexOf("gamedata", StringComparison.Ordinal) + 9)
                    .Replace('\\', '/')).ToList();

            //Check Required
            foreach (var requiredEntry in ParseRequired)
            {
                if (!requiredEntry.Key.EndsWith("dll"))
                {
                    CheckNonDllFile(gameFileRelativePaths, requiredEntry, true);
                }
                else
                {
                    CheckDllFile(requiredEntry, true);
                }
            }

            //Check Optional
            foreach (var optionalEntry in ParseOptional)
            {
                if (!optionalEntry.Key.EndsWith("dll"))
                {
                    CheckNonDllFile(gameFileRelativePaths, optionalEntry, false);
                }
                else
                {
                    CheckDllFile(optionalEntry, false);
                }
            }

            if (WhiteList.Any() && !BlackList.Any()) //Check Resource whitelist
            {
                var autoAllowed = new List <string>
                {
                    "lunamultiplayer/plugins/lunaclient.dll",
                    "lunamultiplayer/plugins/lunacommon.dll",
                    "lunamultiplayer/plugins/fastmember.dll",
                    "lunamultiplayer/plugins/lidgren.network.dll",
                    "lunamultiplayer/plugins/mono.data.tds.dll",
                    "lunamultiplayer/plugins/system.data.dll",
                    "lunamultiplayer/plugins/system.threading.dll",
                    "lunamultiplayer/plugins/system.transactions.dll"
                };

                //Allow LMP files, Ignore squad plugins, Check required (Required implies whitelist), Check optional (Optional implies whitelist)
                //Check whitelist

                foreach (var dllResource in
                         SystemsContainer.Get <ModSystem>().DllList.Where(
                             dllResource =>
                             !autoAllowed.Contains(dllResource.Key) && !dllResource.Key.StartsWith("squad/plugins") &&
                             !ParseRequired.ContainsKey(dllResource.Key) && !ParseOptional.ContainsKey(dllResource.Key) &&
                             !WhiteList.ContainsKey(dllResource.Key)))
                {
                    ModCheckOk = false;
                    LunaLog.Log($"[LMP]: Non-whitelisted resource {dllResource.Key} exists on client!");
                    StringBuilder.AppendLine($"Non-whitelisted resource {dllResource.Key} exists on client!");
                }
            }

            if (!WhiteList.Any() && BlackList.Any()) //Check Resource blacklist
            {
                foreach (var blacklistEntry in
                         BlackList.Keys.Where(blacklistEntry => SystemsContainer.Get <ModSystem>().DllList.ContainsKey(blacklistEntry)))
                {
                    ModCheckOk = false;
                    LunaLog.Log($"[LMP]: Banned resource {blacklistEntry} exists on client!");
                    StringBuilder.AppendLine($"Banned resource {blacklistEntry} exists on client!");
                }
            }
        }