-
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 ignore files and add clients creation
- Loading branch information
1 parent
dadadf0
commit bdac7a2
Showing
2,400 changed files
with
1,072 additions
and
100,474 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,17 @@ | ||
using Linguard.Core.Models.Wireguard; | ||
|
||
namespace Linguard.Core.Configuration; | ||
|
||
public class WireguardConfiguration : IWireguardConfiguration { | ||
public HashSet<Interface> Interfaces { get; set; } | ||
public string IptablesBin { get; set; } | ||
public string WireguardBin { get; set; } | ||
public string WireguardQuickBin { get; set; } | ||
public Uri? PrimaryDns { get; set; } | ||
public Uri? SecondaryDns { get; set; } | ||
public Uri? Endpoint { get; set; } | ||
|
||
public object Clone() { | ||
return MemberwiseClone(); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,71 @@ | ||
using System.Net; | ||
using Linguard.Core.Configuration; | ||
using Linguard.Core.Configuration.Serialization; | ||
using Linguard.Core.Drivers.TrafficStorage; | ||
using Linguard.Core.Models; | ||
using Linguard.Core.Models.Wireguard; | ||
using Linguard.Core.OS; | ||
using Linguard.Core.Utils; | ||
using Linguard.Log; | ||
|
||
namespace Linguard.Core.Managers; | ||
|
||
public class YamlConfigurationManager : FileConfigurationManager { | ||
private static readonly string[] SupportedExtensions = {"yaml", "yml"}; | ||
|
||
private FileInfo? _configurationFile; | ||
protected sealed override FileInfo ConfigurationFile { | ||
get { | ||
if (_configurationFile != default) return _configurationFile; | ||
var filename = Path.Combine(WorkingDirectory.BaseDirectory.FullName, AssemblyInfo.Product.ToLower()); | ||
var tries = 0; | ||
while (tries < SupportedExtensions.Length && _configurationFile is not { Exists: true }) { | ||
var filepath = Path.ChangeExtension(filename, SupportedExtensions[tries]); | ||
_configurationFile = new FileInfo(filepath); | ||
tries++; | ||
} | ||
return _configurationFile!; | ||
} | ||
} | ||
|
||
public override async void LoadDefaults() { | ||
LoadWebDefaults(); | ||
LoadLoggingDefaults(); | ||
LoadTrafficDefaults(); | ||
await LoadWireguardDefaults(); | ||
} | ||
|
||
private void LoadWebDefaults() { | ||
Configuration.Web.Style = Style.Default; | ||
Configuration.Web.LoginAttempts = 10; | ||
Configuration.Web.SecretKey = ""; | ||
} | ||
private void LoadLoggingDefaults() { | ||
Configuration.Logging.Level = LogLevel.Info; | ||
Configuration.Logging.Overwrite = false; | ||
} | ||
private void LoadTrafficDefaults() { | ||
Configuration.Traffic.Enabled = true; | ||
Configuration.Traffic.StorageDriver = new JsonTrafficStorageDriver(); | ||
} | ||
private async Task LoadWireguardDefaults() { | ||
Configuration.Wireguard.Interfaces = new HashSet<Interface>(); | ||
Configuration.Wireguard.IptablesBin = new CommandRunner() | ||
.Run("whereis iptables | tr ' ' '\n' | grep bin").Stdout; | ||
Configuration.Wireguard.WireguardBin = new CommandRunner() | ||
.Run("whereis wg | tr ' ' '\n' | grep bin").Stdout; | ||
Configuration.Wireguard.WireguardQuickBin = new CommandRunner() | ||
.Run("whereis wg-quick | tr ' ' '\n' | grep bin").Stdout; | ||
Configuration.Wireguard.Interfaces = new(); | ||
Configuration.Wireguard.PrimaryDns = new("8.8.8.8", UriKind.RelativeOrAbsolute); | ||
Configuration.Wireguard.SecondaryDns = new("8.8.4.4", UriKind.RelativeOrAbsolute); | ||
var publicIp = Network.GetPublicIPAddress(); | ||
Configuration.Wireguard.Endpoint = publicIp == default | ||
? default | ||
: new(publicIp.ToString(), UriKind.RelativeOrAbsolute); | ||
} | ||
|
||
public YamlConfigurationManager(IConfiguration configuration, IWorkingDirectory workingDirectory) | ||
: base(configuration, workingDirectory, new YamlConfigurationSerializer()) { | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,14 @@ | ||
using System.Net; | ||
|
||
namespace Linguard.Core.Utils; | ||
|
||
public static class Network { | ||
public static IPAddress? GetPublicIPAddress() { | ||
const string url = "https://api.ipify.org/"; | ||
var response = new HttpClient() | ||
.Send(new HttpRequestMessage(HttpMethod.Get, url)) | ||
.Content | ||
.ReadAsStringAsync().Result; | ||
return IPAddress.TryParse(response, out var ipAddress) ? ipAddress : default; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.