Exemplo n.º 1
0
        /// <summary>
        /// Get radius server for test
        /// </summary>
        /// <param name="Port">Server port</param>
        /// <param name="Secret">Packet secret</param>
        /// <param name="UserName">User name</param>
        /// <param name="UserPassword">User password</param>
        /// <param name="ServerType">Server type</param>
        /// <returns></returns>
        public static RadiusServer CreateTestServer(int Port, string Secret, string UserName, string UserPassword, RadiusServerType ServerType)
        {
            var path = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "/Content/radius.dictionary";
            var radiusPacketParser = new RadiusPacketParser(new RadiusDictionary(path));
            var packetHandler      = new TestPacketHandler(UserName, UserPassword);
            var repository         = new RadiusPacketHandlerRepository();

            repository.AddPacketHandler(IPAddress.Any, packetHandler, Secret);
            return(new RadiusServer(new IPEndPoint(IPAddress.Any, Port), radiusPacketParser, ServerType, repository));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var path               = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "/Content/radius.dictionary";
            var dictionary         = new RadiusDictionary(path, NullLogger <RadiusDictionary> .Instance);
            var radiusPacketParser = new RadiusPacketParser(NullLogger <RadiusPacketParser> .Instance, dictionary);

            var packetHandler = new TestPacketHandler();
            var repository    = new PacketHandlerRepository();

            repository.AddPacketHandler(IPAddress.Any, packetHandler, "secret");

            var authenticationServer = new RadiusServer(
                new UdpClientFactory(),
                new IPEndPoint(IPAddress.Any, 1812),
                radiusPacketParser,
                RadiusServerType.Authentication, repository, NullLogger <RadiusServer> .Instance);

            authenticationServer.Start();

            Console.WriteLine("Hello World!");
            Console.ReadLine();
        }