Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DeveLanCacheUI_Backend/DeveLanCacheConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class DeveLanCacheConfiguration
public required string LanCacheLogsDirectory { get; set; }
public required bool Feature_DirectSteamIntegration { get; set; }
public required bool Feature_SkipLinesBasedOnBytesRead { get; set; }
public bool Feature_UseForwardedForAsClientIp { get; set; }
// List of client IPs to exclude from statistics
public string ExcludedClientIps { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ await retryPolicy.ExecuteAsync(async () =>
_steamManifestService.TryToDownloadManifest(ttt);
}

var cacheKey = $"{lanCacheLogLine.CacheIdentifier}_||_{lanCacheLogLine.DownloadIdentifier}_||_{lanCacheLogLine.RemoteAddress}";
var clientIp = _deveLanCacheConfiguration.Feature_UseForwardedForAsClientIp
&& !string.IsNullOrEmpty(lanCacheLogLine.ForwardedFor)
&& lanCacheLogLine.ForwardedFor != "-"
? lanCacheLogLine.ForwardedFor.Split(',')[0].Trim()
: lanCacheLogLine.RemoteAddress;

var cacheKey = $"{lanCacheLogLine.CacheIdentifier}_||_{lanCacheLogLine.DownloadIdentifier}_||_{clientIp}";
steamAppDownloadEventsCache.TryGetValue(cacheKey, out var cachedEvent);

if (cachedEvent == null)
Expand All @@ -141,7 +147,7 @@ await retryPolicy.ExecuteAsync(async () =>
.FirstOrDefaultAsync(t =>
t.CacheIdentifier == lanCacheLogLine.CacheIdentifier &&
t.DownloadIdentifierString == lanCacheLogLine.DownloadIdentifier &&
t.ClientIp == lanCacheLogLine.RemoteAddress &&
t.ClientIp == clientIp &&
t.LastUpdatedAt > lanCacheLogLine.DateTime.AddMinutes(-5)
);
if (cachedEvent != null)
Expand All @@ -162,7 +168,7 @@ await retryPolicy.ExecuteAsync(async () =>
DownloadIdentifier = downloadIdentifierInt,
CreatedAt = lanCacheLogLine.DateTime,
LastUpdatedAt = lanCacheLogLine.DateTime,
ClientIp = lanCacheLogLine.RemoteAddress
ClientIp = clientIp
};
steamAppDownloadEventsCache[cacheKey] = cachedEvent;
await dbContext.DownloadEvents.AddAsync(cachedEvent);
Expand Down
1 change: 1 addition & 0 deletions DeveLanCacheUI_Backend/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"LanCacheLogsDirectory": "\\\\10.88.20.1\\DockerComposers\\lancache\\logs",
"Feature_DirectSteamIntegration": true,
"Feature_SkipLinesBasedOnBytesRead": true,
"Feature_UseForwardedForAsClientIp": false,
"ExcludedClientIps": ""
}
1 change: 1 addition & 0 deletions DeveLanCacheUI_Backend/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"LanCacheLogsDirectory": "/var/develancacheui/lancachelogs",
"Feature_DirectSteamIntegration": false,
"Feature_SkipLinesBasedOnBytesRead": false,
"Feature_UseForwardedForAsClientIp": false,
"ExcludedClientIps": ""
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ This should now all works quite neatly, if it doesn't, let me know in a github i
| LANG | Set this to your language | ?? |
| Feature_DirectSteamIntegration | When false, the backend will download a .CSV file with all depot => steam game mappings (from: https://github.com/devedse/DeveLanCacheUI_SteamDepotFinder_Runner/releases). When true, the tool wil generate this itself / keep it up to date. I would suggest turning this on. | false (for now) |
| Feature_SkipLinesBasedOnBytesRead | When false, it will re-read through the whole file on startup. When true, it tries to be smart and start reading from where it last left off. I would suggest turning this on. | false (for now) |
| Feature_UseForwardedForAsClientIp | When true, the X-Forwarded-For header is used as the client IP instead of the direct remote address. Useful when LanCache sits behind a reverse proxy. The first IP in the header is used. Falls back to RemoteAddress if the header is absent or `-`. | false |
| ExcludedClientIps | A comma separated list of IP addresses to exclude in the downloads pages | |

**Volume Mounts Backend**
Expand Down