Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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>()
         }
     });
Ejemplo n.º 4
0
        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));
        }