-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#115 feat: new dashboard and started import functionality
+ removed overwrite flag for logging and improved logging system using Microsoft.Extensions.ILogging
- Loading branch information
1 parent
2c57052
commit 54fcabb
Showing
82 changed files
with
1,512 additions
and
649 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.IO; | ||
using Moq; | ||
|
||
namespace Core.Test.Mocks; | ||
|
||
public class FileInfoMock : Mock<FileSystemInfo> { | ||
public FileInfoMock(string name) { | ||
SetupGet(o => o.FullName).Returns(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Bogus; | ||
using ByteSizeLib; | ||
using Linguard.Core.Managers; | ||
using Linguard.Core.Models; | ||
using Linguard.Core.Models.Wireguard; | ||
using Linguard.Core.OS; | ||
using Linguard.Core.Services; | ||
using Moq; | ||
|
||
namespace Core.Test.Mocks; | ||
|
||
public class WireguardServiceMock : Mock<IWireguardService> { | ||
public WireguardServiceMock(IConfigurationManager manager, ISystemWrapper systemWrapper, Faker faker) { | ||
Setup(o => o.StartInterface(It.IsAny<Interface>())) | ||
.Callback<Interface>(systemWrapper.AddNetworkInterface); | ||
Setup(o => o.StopInterface(It.IsAny<Interface>())) | ||
.Callback<Interface>(systemWrapper.RemoveNetworkInterface); | ||
Setup(o => o.GeneratePrivateKey()) | ||
.Returns(faker.Lorem.Sentence()); | ||
Setup(o => o.GeneratePublicKey(It.IsAny<string>())) | ||
.Returns(faker.Lorem.Sentence()); | ||
Setup(o => o.GetTrafficData(It.IsAny<Client>())) | ||
.Returns<Client>(client => new TrafficData { | ||
Peer = client, | ||
ReceivedData = ByteSize.FromBytes(faker.Random.Number((int) ByteSize.BytesInMegaByte)), | ||
SentData = ByteSize.FromBytes(faker.Random.Number((int) ByteSize.BytesInMegaByte)), | ||
}); | ||
Setup(o => o.GetTrafficData(It.IsAny<Interface>())) | ||
.Returns<Interface>(iface => { | ||
if (systemWrapper.IsInterfaceDown(iface)) { | ||
return Enumerable.Empty<TrafficData>(); | ||
} | ||
var data = iface.Clients.Select(client => Object.GetTrafficData(client)).ToList(); | ||
data.Add(new TrafficData { | ||
Peer = iface, | ||
ReceivedData = ByteSize.FromBytes(data.Sum(e => e.ReceivedData.Bytes)), | ||
SentData = ByteSize.FromBytes(data.Sum(e => e.SentData.Bytes)) | ||
}); | ||
return data; | ||
}); | ||
Setup(o => o.GetTrafficData()) | ||
.Returns(() => { | ||
var data = new List<TrafficData>(); | ||
foreach (var iface in manager.Configuration.Wireguard.Interfaces) { | ||
data.AddRange(Object.GetTrafficData(iface)); | ||
} | ||
return data; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.