public async Task UpdateServers(IReadOnlyList <VpnHost> servers, VpnConfig config) { Ensure.NotNull(servers, nameof(servers)); Ensure.NotNull(config, nameof(config)); VpnHostContract[] endpointIpsContract = Map(servers); VpnConfigContract configContract = Map(config); await _vpnService.UpdateServers(endpointIpsContract, configContract); }
public Task UpdateServers(VpnHostContract[] servers, VpnConfigContract config) { Ensure.NotNull(servers, nameof(servers)); Ensure.NotNull(config, nameof(config)); _logger.Info("Update Servers requested"); _vpnConnection.UpdateServers( Map(servers), Map(config)); return(Task.CompletedTask); }
private VpnConnectionRequestContract GetConnectionRequestContract() { return(new() { Credentials = new VpnCredentialsContract { ClientCertPem = "cert", ClientKeyPair = new AsymmetricKeyPairContract { PublicKey = new PublicKeyContract { Algorithm = KeyAlgorithmContract.Ed25519, Base64 = PublicKey, Bytes = new byte[0], Pem = string.Empty }, SecretKey = new SecretKeyContract { Algorithm = KeyAlgorithmContract.Ed25519, Base64 = PrivateKey, Bytes = new byte[0], Pem = string.Empty } } }, Servers = new VpnHostContract[] { new() { Ip = "127.0.0.999", Label = string.Empty, X25519PublicKey = new ServerPublicKeyContract { Algorithm = KeyAlgorithmContract.X25519, Base64 = ServerPublicKey, Bytes = new byte[0], Pem = string.Empty } }, }, VpnConfig = new VpnConfigContract { CustomDns = new List <string>() } });
private static VpnConfig Map(VpnConfigContract config) { var portConfig = config.Ports.ToDictionary(p => Map(p.Key), p => (IReadOnlyCollection <int>)p.Value.ToList()); return(new VpnConfig(portConfig, config.CustomDns)); }