- 404 favicon

- Try to fix chrome redirect bug
This commit is contained in:
Infi
2024-08-28 19:57:50 +02:00
parent bf446c5511
commit 6fe560d111
4 changed files with 50 additions and 14 deletions
+27 -9
View File
@@ -22,14 +22,32 @@ tags:
- Chat - Chat
- Replacement - Replacement
changelog: |- changelog: |-
**Added** **Welcome to future~**
- Implement 24-hour clock timestamp option [default false] - Webinterface added
- *Does not work if your game client is offline or you are logged out*
**Fixes** **Features**
- Bozja/Eureka tells should work again - Browse chat on any device
- Invites in Bozja/Eureka should work again - Write chat messages
- Added a notification that warns about fails duo missing player id - Easily copy & paste messages
- Hide activity channels are now saved across sessions - Automatically start with plugin load
**Security**
- This feature is not intended to be used outside of your local network
- Do not forward this port
- Never share your authcode
- Multibox support is not given, first client only
**To be added very soon**
- Display errors as small notifications
**Planned**
- Tab support
- Browser specific settings
- Styling support
**Welcomed**
- User that want to expand this to apps or other platforms
*Note: A FAQ will be provided in the chat2 thread on dalamud's discord, linked in About*
**Misc**
- Loc updates
+2 -3
View File
@@ -79,7 +79,6 @@ public class HostContext
{ {
IsActive = false; IsActive = false;
IsStopping = true; IsStopping = true;
await Task.Delay(10000);
Host.Stop(); Host.Stop();
// Save our session tokens // Save our session tokens
@@ -114,9 +113,9 @@ public class HostContext
Plugin.Log.Error(args.Exception, "Webserver threw an exception."); Plugin.Log.Error(args.Exception, "Webserver threw an exception.");
} }
private async Task DefaultRoute(HttpContextBase ctx) private async Task<bool> DefaultRoute(HttpContextBase ctx)
{ {
await ctx.Response.Send("Nothing to see here."); return await ctx.Response.Send("Nothing to see here.");
} }
private async Task CheckAuthenticationCookie(HttpContextBase ctx) private async Task CheckAuthenticationCookie(HttpContextBase ctx)
+20 -1
View File
@@ -36,10 +36,12 @@ public class RouteController
// Pre Auth // Pre Auth
Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/", AuthRoute, ExceptionRoute); Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/", AuthRoute, ExceptionRoute);
Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/auth", GetAuthenticateClient, ExceptionRoute);
Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.POST, "/auth", AuthenticateClient, ExceptionRoute); Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.POST, "/auth", AuthenticateClient, ExceptionRoute);
Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/files/gfdata.gfd", GetGfdData, ExceptionRoute); Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/files/gfdata.gfd", GetGfdData, ExceptionRoute);
Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/files/fonticon_ps5.tex", GetTexData, ExceptionRoute); Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/files/fonticon_ps5.tex", GetTexData, ExceptionRoute);
Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/files/FFXIV_Lodestone_SSF.ttf", GetLodestoneFont, ExceptionRoute); Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/files/FFXIV_Lodestone_SSF.ttf", GetLodestoneFont, ExceptionRoute);
Core.Host.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/favicon.ico", GetFavicon, ExceptionRoute);
Core.Host.Routes.PreAuthentication.Parameter.Add(HttpMethod.GET, "/emote/{name}", GetEmote, ExceptionRoute); Core.Host.Routes.PreAuthentication.Parameter.Add(HttpMethod.GET, "/emote/{name}", GetEmote, ExceptionRoute);
Core.Host.Routes.PreAuthentication.Content.Add("/static", true, ExceptionRoute); Core.Host.Routes.PreAuthentication.Content.Add("/static", true, ExceptionRoute);
@@ -87,6 +89,12 @@ public class RouteController
await ctx.Response.Send(data); await ctx.Response.Send(data);
} }
private async Task GetFavicon(HttpContextBase ctx)
{
ctx.Response.StatusCode = 404;
await ctx.Response.Send();
}
private async Task GetEmote(HttpContextBase ctx) private async Task GetEmote(HttpContextBase ctx)
{ {
var name = ctx.Request.Url.Parameters["name"] ?? ""; var name = ctx.Request.Url.Parameters["name"] ?? "";
@@ -122,9 +130,11 @@ public class RouteController
#region PreAuthRoutes #region PreAuthRoutes
private async Task<bool> AuthenticateClient(HttpContextBase ctx) private async Task<bool> AuthenticateClient(HttpContextBase ctx)
{ {
Plugin.Log.Information($"Auth requested");
var currentTick = Environment.TickCount64; var currentTick = Environment.TickCount64;
if (RateLimit.TryGetValue(ctx.Request.Source.IpAddress, out var timestamp) && timestamp > currentTick) if (RateLimit.TryGetValue(ctx.Request.Source.IpAddress, out var timestamp) && timestamp > currentTick)
return await Redirect(ctx, "/", ("message", "Rate limit active."), ("retry", "12345")); return await Redirect(ctx, "/", ("message", "Rate limit active."));
// The next request will be rate limited for 10s // The next request will be rate limited for 10s
RateLimit[ctx.Request.Source.IpAddress] = currentTick + 10_000; RateLimit[ctx.Request.Source.IpAddress] = currentTick + 10_000;
@@ -139,6 +149,15 @@ public class RouteController
ctx.Response.Headers.Add("Set-Cookie", $"ChatTwo-token={token}"); ctx.Response.Headers.Add("Set-Cookie", $"ChatTwo-token={token}");
return await Redirect(ctx, "/chat"); return await Redirect(ctx, "/chat");
} }
private async Task<bool> GetAuthenticateClient(HttpContextBase ctx)
{
Plugin.Log.Information($"Get was used for auth requested");
Plugin.Log.Information($"{ctx.Request.Url.Full}");
Plugin.Log.Information($"{ctx.RouteType}");
return await Redirect(ctx, "/", ("message", "Rate limit active."));
}
#endregion #endregion
#region PostAuthRoutes #region PostAuthRoutes
+1 -1
View File
@@ -13,7 +13,7 @@
<main class="auth"> <main class="auth">
<h1>Authcode</h1> <h1>Authcode</h1>
<form action="/auth" method="POST"> <form action="/auth" method="POST">
<input type="password" name="authcode"> <label><input type="password" name="authcode"></label>
<button type="submit">Submit</button> <button type="submit">Submit</button>
</form> </form>
<img src="/emote/Sure"> <img src="/emote/Sure">