Skip to content

Commit

Permalink
Add a bit of troubleshooting steps for a failed advert attempt. (#23)
Browse files Browse the repository at this point in the history
* 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?
  • Loading branch information
VasilisThePikachu committed Jun 17, 2024
1 parent afd062a commit 7056467
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions SS14.ServerHub/Controllers/ServerListController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task<IActionResult> 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))
Expand All @@ -112,7 +112,7 @@ public async Task<IActionResult> Advertise([FromBody] ServerAdvertise advertise)
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.");
Expand Down Expand Up @@ -214,8 +214,8 @@ private async Task<(IActionResult? result, byte[]? statusJson, byte[]? infoJson)
}
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);
}
}

Expand Down Expand Up @@ -314,4 +314,4 @@ public override void Write(Utf8JsonWriter writer, RawJson value, JsonSerializerO
writer.WriteRawValue(value.Json, skipInputValidation: true);
}
}
}
}

0 comments on commit 7056467

Please sign in to comment.