mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-07 16:03:07 +00:00
trying to get back tracker stats
This commit is contained in:
parent
d03dd9f954
commit
0bed02ed73
@ -6,7 +6,7 @@ namespace BittorrentPlugin
|
||||
public class BittorrentContainerRecipe : ContainerRecipeFactory
|
||||
{
|
||||
public override string AppName => "bittorrent";
|
||||
public override string Image => "thatbenbierens/bittorrentdriver:init11";
|
||||
public override string Image => "thatbenbierens/bittorrentdriver:init12";
|
||||
|
||||
public static string ApiPortTag = "API_PORT";
|
||||
public static string TrackerPortTag = "TRACKER_PORT";
|
||||
|
||||
@ -96,10 +96,8 @@ namespace BittorrentPlugin
|
||||
|
||||
public string GetTrackerStats()
|
||||
{
|
||||
//var http = tools.CreateHttp(TrackerAddress.ToString(), c => { });
|
||||
//var endpoint = http.CreateEndpoint(TrackerAddress, "/", container.Name);
|
||||
//return endpoint.HttpGetString("stats");
|
||||
return "no";
|
||||
var endpoint = GetEndpoint();
|
||||
return endpoint.HttpGetString("stats");
|
||||
}
|
||||
|
||||
//public Address TrackerAddress { get; private set; } = new Address("", 0);
|
||||
|
||||
@ -37,6 +37,15 @@ namespace BittorrentDriver.Controllers
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("stats")]
|
||||
public string GetTrackerStats()
|
||||
{
|
||||
return Try(() =>
|
||||
{
|
||||
return tracker.GetStats();
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost("postfile")]
|
||||
public string PostFile([FromBody] PostFileInput input)
|
||||
{
|
||||
|
||||
@ -5,10 +5,13 @@ namespace BittorrentDriver
|
||||
public class TorrentTracker
|
||||
{
|
||||
private Process? process;
|
||||
private int? trackerPort;
|
||||
|
||||
public string Start(int port)
|
||||
{
|
||||
if (process != null) throw new Exception("Already started");
|
||||
trackerPort = port;
|
||||
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
FileName = "bittorrent-tracker",
|
||||
@ -48,5 +51,17 @@ namespace BittorrentDriver
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
public string GetStats()
|
||||
{
|
||||
if (!trackerPort.HasValue) throw new Exception("Port value not set");
|
||||
|
||||
using var client = new HttpClient();
|
||||
var task = client.GetAsync($"http://localhost:{trackerPort.Value}/stats");
|
||||
task.Wait();
|
||||
var strTask = task.Result.Content.ReadAsStringAsync();
|
||||
strTask.Wait();
|
||||
return strTask.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user