Skip to content

Commit

Permalink
fix: cannot list captured traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Sep 24, 2023
1 parent b27edfb commit 43961e8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/GZCTF/Controllers/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public async Task<IActionResult> GetChallengesWithTrafficCapturing([FromRoute] i
[ProducesResponseType(typeof(RequestResponse), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetChallengeTraffic([FromRoute] int challengeId, CancellationToken token)
{
var filePath = $"{FilePath.Capture}/{challengeId:int}";
var filePath = $"{FilePath.Capture}/{challengeId}";

if (!Path.Exists(filePath))
return NotFound(new RequestResponse("未找到相关捕获信息", StatusCodes.Status404NotFound));
Expand Down Expand Up @@ -412,7 +412,7 @@ public async Task<IActionResult> GetChallengeTraffic([FromRoute] int challengeId
[ProducesResponseType(typeof(RequestResponse), StatusCodes.Status404NotFound)]
public IActionResult GetTeamTraffic([FromRoute] int challengeId, [FromRoute] int partId)
{
var filePath = $"{FilePath.Capture}/{challengeId:int}/{partId:int}";
var filePath = $"{FilePath.Capture}/{challengeId}/{partId}";

if (!Path.Exists(filePath))
return NotFound(new RequestResponse("未找到相关捕获信息", StatusCodes.Status404NotFound));
Expand All @@ -438,12 +438,12 @@ public IActionResult GetTeamTraffic([FromRoute] int challengeId, [FromRoute] int
public async Task<IActionResult> GetTeamTrafficZip([FromRoute] int challengeId, [FromRoute] int partId,
CancellationToken token)
{
var filePath = $"{FilePath.Capture}/{challengeId:int}/{partId:int}";
var filePath = $"{FilePath.Capture}/{challengeId}/{partId}";

if (!Path.Exists(filePath))
return NotFound(new RequestResponse("未找到相关捕获信息", StatusCodes.Status404NotFound));

var filename = $"Capture-{challengeId:int}-{partId:int}-{DateTimeOffset.UtcNow:yyyyMMdd-HH.mm.ssZ}";
var filename = $"Capture-{challengeId}-{partId}-{DateTimeOffset.UtcNow:yyyyMMdd-HH.mm.ssZ}";
Stream stream = await Codec.ZipFilesAsync(filePath, filename, token);
stream.Seek(0, SeekOrigin.Begin);

Expand Down Expand Up @@ -471,7 +471,7 @@ public IActionResult GetTeamTraffic([FromRoute] int challengeId, [FromRoute] int
try
{
var file = Path.GetFileName(filename);
var path = Path.GetFullPath(Path.Combine(FilePath.Capture, $"{challengeId:int}/{partId:int}", file));
var path = Path.GetFullPath(Path.Combine(FilePath.Capture, $"{challengeId}/{partId}", file));

if (Path.GetExtension(file) != ".pcap" || !Path.Exists(path))
return NotFound(new RequestResponse("未找到相关捕获信息"));
Expand Down

0 comments on commit 43961e8

Please sign in to comment.