mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-29 16:11:05 +01:00
Merge pull request #660 from Cyberboss/ThisIsBeyondSanity
Adds some additional validation to port changes
This commit is contained in:
@@ -149,6 +149,12 @@ namespace Tgstation.Server.Host.Controllers
|
||||
if (model == null)
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
|
||||
if (model.PrimaryPort == 0)
|
||||
return BadRequest(new ErrorMessage { Message = "Primary port cannot be 0!" });
|
||||
|
||||
if (model.SecurityLevel == DreamDaemonSecurity.Ultrasafe)
|
||||
return BadRequest(new ErrorMessage { Message = "This version of TGS does not support the ultrasafe DreamDaemon configuration!" });
|
||||
|
||||
//alias for changing DD settings
|
||||
var current = await DatabaseContext.Instances.Where(x => x.Id == Instance.Id).Select(x => x.DreamDaemonSettings).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@@ -185,8 +191,8 @@ namespace Tgstation.Server.Host.Controllers
|
||||
|| CheckModified(x => x.StartupTimeout, DreamDaemonRights.SetStartupTimeout))
|
||||
return Forbid();
|
||||
|
||||
if (current.SecurityLevel == DreamDaemonSecurity.Ultrasafe)
|
||||
return BadRequest(new ErrorMessage { Message = "This version of TGS does not support the ultrasafe DreamDaemon configuration!" });
|
||||
if (current.PrimaryPort == current.SecondaryPort)
|
||||
return BadRequest(new ErrorMessage { Message = "Primary port and secondary port cannot be the same!" });
|
||||
|
||||
var wd = instanceManager.GetInstance(Instance).Watchdog;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
using Tgstation.Server.Host.Components;
|
||||
using Tgstation.Server.Host.Core;
|
||||
@@ -85,9 +86,9 @@ namespace Tgstation.Server.Host.Controllers
|
||||
|
||||
/// <inheritdoc />
|
||||
[TgsAuthorize(DreamMakerRights.Compile)]
|
||||
public override async Task<IActionResult> Create([FromBody] Api.Models.DreamMaker model, CancellationToken cancellationToken)
|
||||
public override async Task<IActionResult> Create([FromBody] DreamMaker model, CancellationToken cancellationToken)
|
||||
{
|
||||
var job = new Job
|
||||
var job = new Models.Job
|
||||
{
|
||||
Description = "Compile active repository code",
|
||||
StartedBy = AuthenticationContext.User,
|
||||
@@ -101,8 +102,11 @@ namespace Tgstation.Server.Host.Controllers
|
||||
|
||||
/// <inheritdoc />
|
||||
[TgsAuthorize(DreamMakerRights.SetDme | DreamMakerRights.SetApiValidationPort)]
|
||||
public override async Task<IActionResult> Update([FromBody] Api.Models.DreamMaker model, CancellationToken cancellationToken)
|
||||
public override async Task<IActionResult> Update([FromBody] DreamMaker model, CancellationToken cancellationToken)
|
||||
{
|
||||
if (model.ApiValidationPort == 0)
|
||||
return BadRequest(new ErrorMessage { Message = "API Validation port cannot be 0!" });
|
||||
|
||||
var hostModel = await DatabaseContext.DreamMakerSettings.Where(x => x.InstanceId == Instance.Id).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (hostModel == null)
|
||||
return StatusCode((int)HttpStatusCode.Gone);
|
||||
|
||||
Reference in New Issue
Block a user