diff --git a/src/DMAPI/tgs/v4/api.dm b/src/DMAPI/tgs/v4/api.dm index b5991119d4..8b65335eb8 100644 --- a/src/DMAPI/tgs/v4/api.dm +++ b/src/DMAPI/tgs/v4/api.dm @@ -121,7 +121,25 @@ sleep(10) /datum/tgs_api/v4/proc/Export(command) - return file2text(world.Export("[host_path]/Interop/[instance_id]?command=[url_encode(command)]&access_token=[access_token]")["CONTENT"]) + var/list/res = world.Export("[host_path]/Interop?access=[url_encode(access_identifier)]&command=[url_encode(command)]") + if(!istype(res)) + TGS_ERROR_LOG("Error contacting TGS webapi at [host_path]! Export returned something not a list (probably null): [res]") + return + var/byond_status = res["STATUS"] + var/byond_content = res["CONTENT"] + if(byond_status != "200 OK") + TGS_ERROR_LOG("Error contacting TGS webapi at [host_path]! Top level HTTP [byond_status]: [byond_content]") + return + var/json = json_decode(byond_content) //always expecting json + if(!json) + TGS_ERROR_LOG("Error contacting TGS webapi at [host_path]! Byond content not json: [byond_content]") + return + var/status = json["STATUS"] + var/content = json["CONTENT"] + if(status != 200) //HTTP OK + TGS_ERROR_LOG("Error contacting TGS webapi at [host_path]! HTTP [status]: [json_encode(content)]") + return + return content /datum/tgs_api/v4/OnReboot() var/json = Export(TGS4_COMM_SERVER_REBOOT) diff --git a/src/Tgstation.Server.Host/Components/DreamMaker.cs b/src/Tgstation.Server.Host/Components/DreamMaker.cs index 4bf02b7873..d4747d8834 100644 --- a/src/Tgstation.Server.Host/Components/DreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/DreamMaker.cs @@ -97,6 +97,13 @@ namespace Tgstation.Server.Host.Components SecurityLevel = DreamDaemonSecurity.Safe //all it needs to read the file and exit }; + var dirA = ioManager.ConcatPath(job.DirectoryName.ToString(), ADirectoryName); + var provider = new TemporaryDmbProvider(ioManager.ResolvePath(ioManager.GetDirectoryName(dirA)), ioManager.ResolvePath(ioManager.ConcatPath(dirA, String.Concat(job.DmeName, DmbExtension)))); + using (var controller = await sessionControllerFactory.LaunchNew(launchParameters, provider, true, true, true, cancellationToken).ConfigureAwait(false)) + { + + } + using (var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken)) using (var control = interop.CreateRun(launchParameters.PrimaryPort.Value, null, null)) { @@ -112,7 +119,6 @@ namespace Tgstation.Server.Host.Components if (e.EventType == ServerControlEventType.ServerUnresponsive) ddTcs.SetResult(null); }; - var dirA = ioManager.ConcatPath(job.DirectoryName.ToString(), ADirectoryName); var ddTestTask = dreamDaemonExecutor.RunDreamDaemon(launchParameters, null, dreamDaemonPath, new TemporaryDmbProvider(ioManager.ResolvePath(ioManager.GetDirectoryName(dirA)), ioManager.ResolvePath(ioManager.ConcatPath(dirA, String.Concat(job.DmeName, DmbExtension)))), interopInfo, true, false, cts.Token); await Task.WhenAny(ddTcs.Task, ddTestTask).ConfigureAwait(false); diff --git a/src/Tgstation.Server.Host/Components/Watchdog/LaunchResult.cs b/src/Tgstation.Server.Host/Components/Watchdog/LaunchResult.cs index 8f8ae755ab..12704584fb 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/LaunchResult.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/LaunchResult.cs @@ -7,6 +7,11 @@ namespace Tgstation.Server.Host.Components.Watchdog /// sealed class LaunchResult { + /// + /// If the DMAPI was validated + /// + public bool? ApiValidated { get; set; } + /// /// The time it took for to return /// diff --git a/src/Tgstation.Server.Host/Controllers/InteropController.cs b/src/Tgstation.Server.Host/Controllers/InteropController.cs index 937889b482..2f1690884d 100644 --- a/src/Tgstation.Server.Host/Controllers/InteropController.cs +++ b/src/Tgstation.Server.Host/Controllers/InteropController.cs @@ -39,9 +39,12 @@ namespace Tgstation.Server.Host.Controllers { var result = await instanceManager.HandleWorldExport(Request.Query, cancellationToken).ConfigureAwait(false); //explain things in very simple terms dream daemon can understand - if (result != null) - return Json(result); - return NotFound(); + //EXCEPT DREAMDAENEN BUGS + //THAT"S RIGHT !BUGS! + //ON ANYTHING THAT ISNT A 200 RESPOSNCE REEEE + if (result == null) + result = new { STATUS = 404 }; + return Json(result); } } }