Skip to content

Commit

Permalink
Update to 0.4.4 (Issues #11)
Browse files Browse the repository at this point in the history
- Fix a big response bug in NGINX server (#11)
- Optimize code structure
- Update Arcaea Client version to 3.12.10
  • Loading branch information
Misaka12456 committed Jun 5, 2022
1 parent f549746 commit 045c2fa
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 32 deletions.
20 changes: 9 additions & 11 deletions Team123it.Arcaea.MarveCube.LinkPlay/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Diagnostics.CodeAnalysis;
using System.Enhance;
using System.Net;
using System.Net.Sockets;
Expand All @@ -10,8 +9,7 @@

namespace Team123it.Arcaea.MarveCube.LinkPlay
{
[SuppressMessage("ReSharper", "FunctionNeverReturns")]
public class Program
public class Program
{
static Socket? _server;
private static ConsoleWriter? _logWriter;
Expand All @@ -37,7 +35,7 @@ private static void Initialization(string[] args)
for (;;)
{
Console.WriteLine("请输入LinkPlay服务器的监听端口(需与主服务器保持同步), 并回车:");
if (ushort.TryParse(Console.ReadLine(), out var i))
if (ushort.TryParse(Console.ReadLine(), out ushort i))
{
port = i;
break;
Expand Down Expand Up @@ -72,7 +70,7 @@ private static void Initialization(string[] args)
for (;;)
{
Console.WriteLine("请输入Redis服务器的监听端口(需与主服务器保持同步), 并回车:");
if (ushort.TryParse(Console.ReadLine(), out var i))
if (ushort.TryParse(Console.ReadLine(), out ushort i))
{
redisPort = i;
break;
Expand All @@ -84,7 +82,7 @@ private static void Initialization(string[] args)
{
Console.WriteLine("请输入Redis服务器的密码(需与主服务器保持同步), 并回车:");
var i = Console.ReadLine();
if (i is not null)
if (!string.IsNullOrWhiteSpace(i))
{
redisPassword = i;
break;
Expand All @@ -93,16 +91,16 @@ private static void Initialization(string[] args)
}

Console.WriteLine("正在保存设置, 请稍后");
var config = new JObject
{
var config = new JObject()
{
{
"settings", new JObject
{
"settings", new JObject()
{
{"isMaintaining", false}
}
},
{
"config", new JObject
"config", new JObject()
{
{"multiplayerServerUrl", multiplayerServerUrl},
{"multiplayerServerPort", port},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Version>0.4.3</Version>
<Company>123 Open-Source Organization</Company>
<Product>Arcaea Server 2 Standalone Link Play Server Part</Product>
<AssemblyVersion>0.4.3</AssemblyVersion>
<AssemblyVersion>0.4.4</AssemblyVersion>
<FileVersion>0.4.3</FileVersion>
<Copyright>(C)Copyright 2015-2022 123 Open-Source Organization. All rights reserved.</Copyright>
<AssemblyTitle>Arcaea Server 2 - High-Speed Protable Arcaea API Server</AssemblyTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Version>0.4.3</Version>
<Company>123 Open-Source Organization</Company>
<Product>Arcaea Server 2 Standalone Download Server Part</Product>
<AssemblyVersion>0.4.3</AssemblyVersion>
<AssemblyVersion>0.4.4</AssemblyVersion>
<FileVersion>0.4.3</FileVersion>
<Copyright>(C)Copyright 2015-2022 123 Open-Source Organization. All rights reserved.</Copyright>
<AssemblyTitle>123 Marvelous Cube Standalone Version</AssemblyTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"isWorldEventMapTesting": false, // 是否正在测试世界模式限时地图(true时设置的测试员(见下)将可以进入不在活动时间范围内的限时地图)
"eventMapTestPlayers": [], // 世界模式限时地图测试玩家的用户id列表
"minSupportVer": "3.10.6", // 最低支持的Arcaea客户端版本
"latestVersion": "3.12.8", // Arcaea客户端的最新版本
"latestVersion": "3.12.10", // Arcaea客户端的最新版本
"aprilFoolsStartTime": -1, // 愚人节开放的UNIX时间戳(单位为秒)(优先级高于上文的"服务器时间",低于"isOverrideAprilFools"的设置)
"topRankLimit": 200 //Top玩家(#框)的最大排名限制(最高可填写为200)
},
Expand Down
20 changes: 5 additions & 15 deletions Team123it.Arcaea.MarveCube/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Enhance.AspNetCore;
using System.IO;
using System.IO.Compression;
using Microsoft.AspNetCore.Builder;
Expand Down Expand Up @@ -27,13 +28,6 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.Configure<FormOptions>(options => options.BufferBody = true);
services.AddResponseCompression();
services.Configure<GzipCompressionProviderOptions>(options =>
{
options.Level = CompressionLevel.Optimal;
});
// services.AddTransient<LargeDataProcessMiddleware>();
// services.AddTransient<RealIpFetcherMiddleware>();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -44,23 +38,17 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseDeveloperExceptionPage();
}

// app.UseHttpsRedirection();
app.UseMiddleware<DeChunkerMiddleware>(); // Forcibly disable buffering(chunked) response

app.UseRouting();

// app.UseAuthorization();

app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto });

//app.UseMiddleware<RealIpFetcherMiddleware>(null);

app.UseEndpoints(endpoints =>
app.UseEndpoints((endpoints) =>
{
endpoints.MapControllers();
});

// app.UseMiddleware<LargeDataProcessMiddleware>(null);

app.Run(async context =>
{
Console.ForegroundColor = ConsoleColor.Yellow;
Expand All @@ -73,5 +61,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
await context.Response.WriteAsync($"Current Path: {context.Request.Path}\n");
});
}

// by Misaka12456 2022.4
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.AspNetCore.Http;
using System.IO;
using System.Threading.Tasks;
using System;
using System.IO.Compression;
using Microsoft.AspNetCore.Http.Features;

namespace System.Enhance.AspNetCore
{
public class DeChunkerMiddleware : IMiddleware
{
public DeChunkerMiddleware()
{

}

public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
// Disable Transfer-Encoding:chunked, use automatically Content-Length instead
var feature = context.Features.Get<IHttpResponseBodyFeature>();
feature?.DisableBuffering();
context.Response.Headers["Content-Encoding"] = "identity";
// For NGINX Server, we set this to forcibly disable buffering response
// (lowiro curl client doesn't support buffering/chunked response)
// (https://github.com/Misaka12456/ArcaeaServer2/issues/11)
context.Response.Headers["X-Accel-Buffering"] = "no";
var originalBodyStream = context.Response.Body;
using (var responseBody = new MemoryStream())
{
context.Response.Body = responseBody;
long length = 0;
await next(context);
// If you want to read the body, uncomment these lines.
context.Response.Body.Seek(0, SeekOrigin.Begin);
var body = await new StreamReader(context.Response.Body).ReadToEndAsync();
length = context.Response.Body.Length;
context.Response.Body.Seek(0, SeekOrigin.Begin);
context.Response.Headers.ContentLength = length;
await responseBody.CopyToAsync(originalBodyStream);
}
}
}
}
6 changes: 3 additions & 3 deletions Team123it.Arcaea.MarveCube/Team123it.Arcaea.MarveCube.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>MarveCube</AssemblyName>
<Version>0.4.3</Version>
<Version>0.4.4</Version>
<Company>123 Open-Source Organization</Company>
<Product>Arcaea Server 2(123 Marvelous Cube Open-Source Version)</Product>
<AssemblyVersion>0.4.3</AssemblyVersion>
<FileVersion>0.4.3</FileVersion>
<AssemblyVersion>0.4.4</AssemblyVersion>
<FileVersion>0.4.4</FileVersion>
<Copyright>(C)Copyright 2015-2022 123 Open-Source Organization. All rights reserved.</Copyright>
<AssemblyTitle>Arcaea Server 2 - High-Speed Protable Arcaea API Server</AssemblyTitle>
<Platforms>x64;ARM64</Platforms>
Expand Down

0 comments on commit 045c2fa

Please sign in to comment.