namespace VPNAuth.Server; public static class HttpContextUtils { public static string GetRemoteIpAddress(this HttpContext context) => context.Request.Headers["X-Forwarded-For"].DefaultIfEmpty(context.Connection.RemoteIpAddress!.ToString()) .First()!; public static ConfigUser? GetUser(this HttpContext context) { var config = Config.Read(); if (config.Users == null || config.Users.Count == 0) return null; return config.Users!.Find(user => user.Ips!.Contains(context.GetRemoteIpAddress())); } }