using System;
using System.Collections.Generic;

namespace NetworkResurrector.Api.Application.Helpers
{
    internal static class DataFaker
    {
        private static readonly Random Random = new Random();
        private static readonly string[] Names = { "Apollo", "Athena", "Cronus", "Diana", "Hermes", "Jupiter", "Mars", "Mercury", "Neptune", "Saturn", "Uranus", "Venus" };
        private static readonly string[] Codes = { "Node", "Hypervisor", "Srv", "WebSrv", "SqlSrv", "Host", "Agent" };

        public static string GenerateName()
        {
            var codeIndex = Random.Next(Codes.Length);
            var nameIndex = Random.Next(Names.Length);
            return $"{Names[nameIndex]}{Codes[codeIndex]}";
        }

        public static IEnumerable<string> GenerateIPv4AddressesInSubnet(int count)
        {
            Random random = new Random();
            byte[] subnet = new byte[4];
            random.NextBytes(subnet);
            subnet[0] = (byte)((subnet[0] & 0xF0) | 0x0A); // set first octet to 10.x.x.x (private IP range)

            var addresses = new List<string>();
            for (int i = 0; i < count; i++)
            {
                byte[] ip = new byte[4];
                random.NextBytes(ip);
                ip[0] = subnet[0];
                ip[1] = subnet[1];
                addresses.Add(string.Join(".", ip));
            }
            return addresses;
        }
    }
}
