diff --git a/ProjectLighthouse/Controllers/LoginController.cs b/ProjectLighthouse/Controllers/LoginController.cs index 88368a2c..a2c381af 100644 --- a/ProjectLighthouse/Controllers/LoginController.cs +++ b/ProjectLighthouse/Controllers/LoginController.cs @@ -41,10 +41,19 @@ namespace LBPUnion.ProjectLighthouse.Controllers { loginData = null; } - if (loginData == null) return this.BadRequest(); + + if (loginData == null) + { + Logger.Log("loginData was null, rejecting login", LoggerLevelLogin.Instance); + return this.BadRequest(); + } IPAddress? remoteIpAddress = this.HttpContext.Connection.RemoteIpAddress; - if (remoteIpAddress == null) return this.StatusCode(403, ""); // 403 probably isnt the best status code for this, but whatever + if (remoteIpAddress == null) + { + Logger.Log("unable to determine ip, rejecting login", LoggerLevelLogin.Instance); + return this.StatusCode(403, ""); // 403 probably isnt the best status code for this, but whatever + } string ipAddress = remoteIpAddress.ToString(); @@ -56,11 +65,20 @@ namespace LBPUnion.ProjectLighthouse.Controllers if (token == null) // If we cant find an existing token, try to generate a new one { token = await this.database.AuthenticateUser(loginData, ipAddress, titleId); - if (token == null) return this.StatusCode(403, ""); // If not, then 403. + if (token == null) + { + Logger.Log("unable to find/generate a token, rejecting login", LoggerLevelLogin.Instance); + return this.StatusCode(403, ""); // If not, then 403. + } } User? user = await this.database.UserFromGameToken(token, true); - if (user == null || user.Banned) return this.StatusCode(403, ""); + + if (user == null || user.Banned) + { + Logger.Log("unable to find a user from a token, rejecting login", LoggerLevelLogin.Instance); + return this.StatusCode(403, ""); + } if (ServerSettings.Instance.UseExternalAuth) { @@ -75,6 +93,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers DeniedAuthenticationHelper.AddAttempt(ipAddressAndName); await this.database.SaveChangesAsync(); + Logger.Log("too many denied logins, rejecting login", LoggerLevelLogin.Instance); return this.StatusCode(403, ""); } } @@ -104,7 +123,11 @@ namespace LBPUnion.ProjectLighthouse.Controllers await this.database.SaveChangesAsync(); - if (!token.Approved) return this.StatusCode(403, ""); + if (!token.Approved) + { + Logger.Log("token unapproved, rejecting login", LoggerLevelLogin.Instance); + return this.StatusCode(403, ""); + } Logger.Log($"Successfully logged in user {user.Username} as {token.GameVersion} client ({titleId})", LoggerLevelLogin.Instance); // After this point we are now considering this session as logged in. diff --git a/ProjectLighthouse/Helpers/Extensions/RequestExtensions.cs b/ProjectLighthouse/Helpers/Extensions/RequestExtensions.cs new file mode 100644 index 00000000..a31b359a --- /dev/null +++ b/ProjectLighthouse/Helpers/Extensions/RequestExtensions.cs @@ -0,0 +1,15 @@ +using System.Text.RegularExpressions; +using Microsoft.AspNetCore.Http; +using Microsoft.Net.Http.Headers; + +namespace LBPUnion.ProjectLighthouse.Helpers.Extensions +{ + // yoinked and adapted from https://stackoverflow.com/a/68641796 + public static class RequestExtensions + { + private static readonly Regex mobileCheck = new + ("Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled); + + public static bool IsMobile(this HttpRequest request) => mobileCheck.IsMatch(request.Headers[HeaderNames.UserAgent].ToString()); + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Helpers/TimestampHelper.cs b/ProjectLighthouse/Helpers/TimestampHelper.cs index 3a3e9d48..456f33ab 100644 --- a/ProjectLighthouse/Helpers/TimestampHelper.cs +++ b/ProjectLighthouse/Helpers/TimestampHelper.cs @@ -5,5 +5,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers public static class TimestampHelper { public static long Timestamp => (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; + + public static long TimestampMillis => (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds; } } \ No newline at end of file diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml index d4e14ade..ee35c549 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml @@ -1,4 +1,5 @@ @using LBPUnion.ProjectLighthouse.Helpers +@using LBPUnion.ProjectLighthouse.Helpers.Extensions @using LBPUnion.ProjectLighthouse.Types @using LBPUnion.ProjectLighthouse.Types.Settings @model LBPUnion.ProjectLighthouse.Pages.Layouts.BaseLayout @@ -26,6 +27,9 @@ } Model.NavigationItemsRight.Add(new PageNavigationItem("Log out", "/logout", "user alternate slash")); // should always be last } + + Model.IsMobile = Model.Request.IsMobile(); + long timeStarted = TimestampHelper.TimestampMillis; } @@ -48,10 +52,20 @@ - - - + + + @* Embed Stuff *@ + + + @if (!string.IsNullOrEmpty(Model.Description)) + { + + } + + + + @* Google Analytics *@ @if (ServerSettings.Instance.GoogleAnalyticsEnabled) { @@ -81,14 +95,21 @@
+ @if (ServerStatics.IsDebug) + { +
+
+ + + +
+
+ + + } diff --git a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs index f7f14670..f71c2bb3 100644 --- a/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs +++ b/ProjectLighthouse/Pages/Layouts/BaseLayout.cshtml.cs @@ -7,6 +7,13 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts { public class BaseLayout : PageModel { + public BaseLayout(Database database) + { + this.Database = database; + } + + public bool IsMobile; + public readonly Database Database; public readonly List NavigationItems = new() @@ -21,14 +28,10 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts public bool ShowTitleInPage = true; public string Title = string.Empty; + public string Description = string.Empty; private User? user; - public BaseLayout(Database database) - { - this.Database = database; - } - public new User? User { get { if (this.user != null) return this.user; diff --git a/ProjectLighthouse/Pages/SlotPage.cshtml b/ProjectLighthouse/Pages/SlotPage.cshtml index 221d99f2..f9de969d 100644 --- a/ProjectLighthouse/Pages/SlotPage.cshtml +++ b/ProjectLighthouse/Pages/SlotPage.cshtml @@ -3,8 +3,10 @@ @{ Layout = "Layouts/BaseLayout"; - Model.Title = Model.Slot.Name; Model.ShowTitleInPage = false; + + Model.Title = Model.Slot.Name; + Model.Description = Model.Slot.Description; } @await Html.PartialAsync("Partials/SlotCardPartial", Model.Slot, new ViewDataDictionary(ViewData) diff --git a/ProjectLighthouse/Pages/UserPage.cshtml b/ProjectLighthouse/Pages/UserPage.cshtml index 382f2f40..1437fa80 100644 --- a/ProjectLighthouse/Pages/UserPage.cshtml +++ b/ProjectLighthouse/Pages/UserPage.cshtml @@ -8,8 +8,10 @@ @{ Layout = "Layouts/BaseLayout"; - Model.Title = Model.ProfileUser!.Username + "'s user page"; Model.ShowTitleInPage = false; + + Model.Title = Model.ProfileUser!.Username + "'s user page"; + Model.Description = Model.ProfileUser!.Biography; } @if (Model.ProfileUser.Banned) diff --git a/ProjectLighthouse/StaticFiles/android-chrome-192x192.png b/ProjectLighthouse/StaticFiles/android-chrome-192x192.png index 9b3eab52..f7ce477c 100644 Binary files a/ProjectLighthouse/StaticFiles/android-chrome-192x192.png and b/ProjectLighthouse/StaticFiles/android-chrome-192x192.png differ diff --git a/ProjectLighthouse/StaticFiles/android-chrome-512x512.png b/ProjectLighthouse/StaticFiles/android-chrome-512x512.png index 09f9e579..ba90a187 100644 Binary files a/ProjectLighthouse/StaticFiles/android-chrome-512x512.png and b/ProjectLighthouse/StaticFiles/android-chrome-512x512.png differ diff --git a/ProjectLighthouse/StaticFiles/apple-touch-icon.png b/ProjectLighthouse/StaticFiles/apple-touch-icon.png index e87773fa..3c56ec58 100644 Binary files a/ProjectLighthouse/StaticFiles/apple-touch-icon.png and b/ProjectLighthouse/StaticFiles/apple-touch-icon.png differ diff --git a/ProjectLighthouse/StaticFiles/browserconfig.xml b/ProjectLighthouse/StaticFiles/browserconfig.xml index b3930d0f..212c880d 100644 --- a/ProjectLighthouse/StaticFiles/browserconfig.xml +++ b/ProjectLighthouse/StaticFiles/browserconfig.xml @@ -3,7 +3,7 @@ - #da532c + #008cff diff --git a/ProjectLighthouse/StaticFiles/css/styles.css b/ProjectLighthouse/StaticFiles/css/styles.css index 53cbfaa5..18d37154 100644 --- a/ProjectLighthouse/StaticFiles/css/styles.css +++ b/ProjectLighthouse/StaticFiles/css/styles.css @@ -16,3 +16,6 @@ div.statsUnderTitle > span { margin-right: 5px; } +#lighthouse-debug-info > p { + margin-bottom: 1px; +} \ No newline at end of file diff --git a/ProjectLighthouse/StaticFiles/favicon-16x16.png b/ProjectLighthouse/StaticFiles/favicon-16x16.png index e3ef0781..dfd981f8 100644 Binary files a/ProjectLighthouse/StaticFiles/favicon-16x16.png and b/ProjectLighthouse/StaticFiles/favicon-16x16.png differ diff --git a/ProjectLighthouse/StaticFiles/favicon-32x32.png b/ProjectLighthouse/StaticFiles/favicon-32x32.png index bc34a6c1..db29acfa 100644 Binary files a/ProjectLighthouse/StaticFiles/favicon-32x32.png and b/ProjectLighthouse/StaticFiles/favicon-32x32.png differ diff --git a/ProjectLighthouse/StaticFiles/favicon.ico b/ProjectLighthouse/StaticFiles/favicon.ico index af563a7c..0343de4c 100644 Binary files a/ProjectLighthouse/StaticFiles/favicon.ico and b/ProjectLighthouse/StaticFiles/favicon.ico differ diff --git a/ProjectLighthouse/StaticFiles/mstile-150x150.png b/ProjectLighthouse/StaticFiles/mstile-150x150.png index 1825f73d..b0bbb2fc 100644 Binary files a/ProjectLighthouse/StaticFiles/mstile-150x150.png and b/ProjectLighthouse/StaticFiles/mstile-150x150.png differ diff --git a/ProjectLighthouse/StaticFiles/safari-pinned-tab.svg b/ProjectLighthouse/StaticFiles/safari-pinned-tab.svg index 51454694..7d1fcf3c 100644 --- a/ProjectLighthouse/StaticFiles/safari-pinned-tab.svg +++ b/ProjectLighthouse/StaticFiles/safari-pinned-tab.svg @@ -2,222 +2,350 @@ Created by potrace 1.14, written by Peter Selinger 2001-2017 - - - - - - - - - + + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProjectLighthouse/StaticFiles/site.webmanifest b/ProjectLighthouse/StaticFiles/site.webmanifest index b20abb7c..9f2f6643 100644 --- a/ProjectLighthouse/StaticFiles/site.webmanifest +++ b/ProjectLighthouse/StaticFiles/site.webmanifest @@ -1,6 +1,6 @@ { - "name": "", - "short_name": "", + "name": "Project Lighthouse", + "short_name": "Lighthouse", "icons": [ { "src": "/android-chrome-192x192.png", @@ -13,7 +13,7 @@ "type": "image/png" } ], - "theme_color": "#ffffff", - "background_color": "#ffffff", + "theme_color": "#008cff", + "background_color": "#008cff", "display": "standalone" } diff --git a/ProjectLighthouse/Types/Settings/ServerStatics.cs b/ProjectLighthouse/Types/Settings/ServerStatics.cs index cea385e4..12af421e 100644 --- a/ProjectLighthouse/Types/Settings/ServerStatics.cs +++ b/ProjectLighthouse/Types/Settings/ServerStatics.cs @@ -27,5 +27,11 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings } public static bool IsUnitTesting => AppDomain.CurrentDomain.GetAssemblies().Any(assembly => assembly.FullName.StartsWith("xunit")); + + #if DEBUG + public static readonly bool IsDebug = true; + #else + public static readonly bool IsDebug = false; + #endif } } \ No newline at end of file diff --git a/README.md b/README.md index 9ece56f8..d87d9bf7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Project Lighthouse -Project Lighthouse is an umbrella project for all work to investigate and develop private servers for LittleBigPlanet. -This project is the main server component that LittleBigPlanet games connect to. +Project Lighthouse is a clean-room, open-source custom server for LittleBigPlanet. This is a project conducted by the [LBP Union Ministry of Technology Research and Development team.](https://www.lbpunion.com/technology) For concerns and inquiries about the project, please [contact us here.](https://www.lbpunion.com/contact) For general questions and discussion about Project Lighthouse, please see the [megathread](https://www.lbpunion.com/forum/union-hall/project-lighthouse-littlebigplanet-private-servers-megathread) on our forum. ## WARNING!