DnsBlacklist.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Text.RegularExpressions;
  2. namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
  3. {
  4. static partial class DnsBlacklist
  5. {
  6. const RegexOptions RegexOpts = RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture;
  7. [GeneratedRegex(@"^(.*)\-lp1\.(n|s)\.n\.srv\.nintendo\.net$", RegexOpts)]
  8. private static partial Regex BlockedHost1();
  9. [GeneratedRegex(@"^(.*)\-lp1\.lp1\.t\.npln\.srv\.nintendo\.net$", RegexOpts)]
  10. private static partial Regex BlockedHost2();
  11. [GeneratedRegex(@"^(.*)\-lp1\.(znc|p)\.srv\.nintendo\.net$", RegexOpts)]
  12. private static partial Regex BlockedHost3();
  13. [GeneratedRegex(@"^(.*)\-sb\-api\.accounts\.nintendo\.com$", RegexOpts)]
  14. private static partial Regex BlockedHost4();
  15. [GeneratedRegex(@"^(.*)\-sb\.accounts\.nintendo\.com$", RegexOpts)]
  16. private static partial Regex BlockedHost5();
  17. [GeneratedRegex(@"^accounts\.nintendo\.com$", RegexOpts)]
  18. private static partial Regex BlockedHost6();
  19. private static readonly Regex[] BlockedHosts = {
  20. BlockedHost1(),
  21. BlockedHost2(),
  22. BlockedHost3(),
  23. BlockedHost4(),
  24. BlockedHost5(),
  25. BlockedHost6()
  26. };
  27. public static bool IsHostBlocked(string host)
  28. {
  29. foreach (Regex regex in BlockedHosts)
  30. {
  31. if (regex.IsMatch(host))
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. }
  39. }