Skip to content

Commit

Permalink
Merge pull request #300 from bdach/domain-to-envvar
Browse files Browse the repository at this point in the history
Split domain to which LIO requests are directed to envvar
peppy authored Nov 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 0a02c0b + aa1395f commit 2481e03
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -103,10 +103,20 @@ Defaults to `localhost`.

Enables DataDog origin detection when running in a container. See [DataDog documentation](https://docs.datadoghq.com/developers/dogstatsd/?tab=kubernetes&code-lang=dotnet#origin-detection-over-udp).

### LEGACY_IO_DOMAIN

Root domain to which LegacyIO requests should be directed.

- In Debug configuration, this parameter is not required; when missing, all LIO requests are no-ops.
- In Release configuration, this parameter is required; all LIO requests will hard-fail with an exception if missing.

### SHARED_INTEROP_SECRET

Secret key used to sign LegacyIO requests to osu-web. Required to award medals.

- In Debug configuration, this parameter is not required; when missing, all LIO requests are no-ops.
- In Release configuration, this parameter is required; all LIO requests will hard-fail with an exception if missing.

### PROCESS_USER_MEDALS

Whether to process user medals. Set to `0` to disable processing.
Original file line number Diff line number Diff line change
@@ -74,12 +74,21 @@ public RulesetDatabaseInfo(int rulesetId, string rulesetIdentifier, bool legacyS
}
}

private static readonly string shared_interop_secret = Environment.GetEnvironmentVariable("SHARED_INTEROP_SECRET") ?? string.Empty;
private static readonly string? legacy_io_domain = Environment.GetEnvironmentVariable("LEGACY_IO_DOMAIN");
private static readonly string? shared_interop_secret = Environment.GetEnvironmentVariable("SHARED_INTEROP_SECRET");

private static readonly HttpClient http = new HttpClient();

public static HttpResponseMessage RunLegacyIO(string command, string method = "GET", dynamic? postObject = null)
{
if (string.IsNullOrEmpty(legacy_io_domain))
{
#if !DEBUG
throw new InvalidOperationException($"Attempted legacy IO call without target domain specified ({command})");
#endif
return null!;
}

if (string.IsNullOrEmpty(shared_interop_secret))
{
#if !DEBUG
@@ -96,7 +105,7 @@ public static HttpResponseMessage RunLegacyIO(string command, string method = "G
{
long time = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

string url = $"https://osu.ppy.sh/_lio/{command}{(command.Contains('?') ? "&" : "?")}timestamp={time}";
string url = $"{legacy_io_domain}/_lio/{command}{(command.Contains('?') ? "&" : "?")}timestamp={time}";
string signature = hmacEncode(url, Encoding.UTF8.GetBytes(shared_interop_secret));

#pragma warning disable SYSLIB0014

0 comments on commit 2481e03

Please sign in to comment.