mirror of
https://github.com/techgarage-ir/MTWireGuard.git
synced 2025-08-30 22:59:35 +02:00
Add project files.
This commit is contained in:
commit
b2325a46ef
1351 changed files with 48136 additions and 0 deletions
42
Pages/Index.cshtml.cs
Normal file
42
Pages/Index.cshtml.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using MTWireGuard.Repositories;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace MTWireGuard.Pages
|
||||
{
|
||||
[Authorize]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
private readonly IMikrotikRepository API;
|
||||
|
||||
public IndexModel(ILogger<IndexModel> logger, IMikrotikRepository mikrotik)
|
||||
{
|
||||
_logger = logger;
|
||||
API = mikrotik;
|
||||
}
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
var users = await API.GetUsersAsync();
|
||||
var servers = await API.GetServersAsync();
|
||||
var traffics = await API.GetServersTraffic();
|
||||
var wgTraffics = traffics.Where(s => s.Type == "wg");
|
||||
long up = 0;
|
||||
long down = 0;
|
||||
foreach (var item in wgTraffics)
|
||||
{
|
||||
up += item.UploadBytes;
|
||||
down += item.DownloadBytes;
|
||||
}
|
||||
ViewData["users"] = users;
|
||||
ViewData["servers"] = servers;
|
||||
ViewData["uptr"] = Helper.ConvertByteSize(up, 2);
|
||||
ViewData["downtr"] = Helper.ConvertByteSize(down, 2);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue