forked from loic-sharma/BaGet
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase max package size to ~8GB (#100)
* Increase max package size to ~8GB * Add comment for max package size * Make max package size configurable * Add docker hub link to docs * Also use configurable max package size for IIS delpoyments.
- Loading branch information
1 parent
d554b46
commit 68ae87a
Showing
7 changed files
with
83 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using BaGetter.Core; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Cors.Infrastructure; | ||
using Microsoft.AspNetCore.Http.Features; | ||
using Microsoft.AspNetCore.HttpOverrides; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace BaGetter; | ||
|
||
public class ConfigureBaGetterServer | ||
: IConfigureOptions<CorsOptions> | ||
, IConfigureOptions<FormOptions> | ||
, IConfigureOptions<ForwardedHeadersOptions> | ||
, IConfigureOptions<IISServerOptions> | ||
{ | ||
public const string CorsPolicy = "AllowAll"; | ||
private readonly BaGetterOptions _baGetterOptions; | ||
|
||
public ConfigureBaGetterServer(IOptions<BaGetterOptions> baGetterOptions) | ||
{ | ||
_baGetterOptions = baGetterOptions.Value; | ||
} | ||
|
||
|
||
public void Configure(CorsOptions options) | ||
{ | ||
// TODO: Consider disabling this on production builds. | ||
options.AddPolicy( | ||
CorsPolicy, | ||
builder => builder.AllowAnyOrigin() | ||
.AllowAnyMethod() | ||
.AllowAnyHeader()); | ||
} | ||
|
||
public void Configure(FormOptions options) | ||
{ | ||
// Allow packages up to ~8GiB in size | ||
options.MultipartBodyLengthLimit = (long) _baGetterOptions.MaxPackageSizeGiB * int.MaxValue / 2; | ||
} | ||
|
||
public void Configure(ForwardedHeadersOptions options) | ||
{ | ||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; | ||
|
||
// Do not restrict to local network/proxy | ||
options.KnownNetworks.Clear(); | ||
options.KnownProxies.Clear(); | ||
} | ||
|
||
public void Configure(IISServerOptions options) | ||
{ | ||
options.MaxRequestBodySize = (long)_baGetterOptions.MaxPackageSizeGiB * int.MaxValue / 2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters