From 70564674275f63f0f1e48bc579aafaeb204308b4 Mon Sep 17 00:00:00 2001 From: Vasilis Date: Mon, 17 Jun 2024 17:09:06 +0300 Subject: [PATCH] Add a bit of troubleshooting steps for a failed advert attempt. (#23) * Add a bit of troubleshooting steps for a failed advert attempt. Changes the invalid ss14 uri error to tell the user where to look to resolve it. The current error for being unable to contact status address looks like its coming from robust itself and not the hub. And gets many people to come to #hosting for something they can fix themselves. This will at least ensure they double-check their config and firewall before asking. Also now the info log will display the attempted advert uri. Removed a null suppression as it was unnecessary (at least rider said so) * Please? --- SS14.ServerHub/Controllers/ServerListController.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SS14.ServerHub/Controllers/ServerListController.cs b/SS14.ServerHub/Controllers/ServerListController.cs index cb8eb67..a2cf1c4 100644 --- a/SS14.ServerHub/Controllers/ServerListController.cs +++ b/SS14.ServerHub/Controllers/ServerListController.cs @@ -94,7 +94,7 @@ public async Task Advertise([FromBody] ServerAdvertise advertise) if (!Uri.TryCreate(advertise.Address, UriKind.Absolute, out var parsedAddress) || string.IsNullOrWhiteSpace(parsedAddress.Host) || parsedAddress.Scheme is not (Ss14UriHelper.SchemeSs14 or Ss14UriHelper.SchemeSs14s)) - return BadRequest("Invalid SS14 URI"); + return BadRequest("Invalid SS14 URI. Ensure your hub.server_url starts with ss14:// or ss14s:// and that the address is valid."); // Ban check. switch (await CheckAddressBannedAsync(parsedAddress)) @@ -112,7 +112,7 @@ parsedAddress.Scheme is not (Ss14UriHelper.SchemeSs14 or Ss14UriHelper.SchemeSs1 Debug.Assert(statusJson != null); Debug.Assert(infoJson != null); - switch (await CheckInfoBannedAsync(parsedAddress, statusJson, infoJson!)) + switch (await CheckInfoBannedAsync(parsedAddress, statusJson, infoJson)) { case BanCheckResult.Banned: return Unauthorized("Your server has been blocked from advertising on the hub. If you believe this to be in error, please contact us."); @@ -214,8 +214,8 @@ parsedAddress.Scheme is not (Ss14UriHelper.SchemeSs14 or Ss14UriHelper.SchemeSs1 } catch (Exception e) { - _logger.LogInformation(e, "Failed to connect to advertising server"); - return (UnprocessableEntity("Unable to contact status address"), null, null); + _logger.LogInformation(e, $"Failed to connect to advertising server: {uri}"); + return (UnprocessableEntity("Unable to contact status address, ensure your firewall/port forwarding configuration allows traffic from the internet and double check your config."), null, null); } } @@ -314,4 +314,4 @@ public override void Write(Utf8JsonWriter writer, RawJson value, JsonSerializerO writer.WriteRawValue(value.Json, skipInputValidation: true); } } -} \ No newline at end of file +}