示例#1
0
        private void StartServer()
        {
            var port = 1645;
            Int32.TryParse(textBox_Port.Text, out port);

            //var clients = JsonConvert.DeserializeObject<RadiusServersModel>(File.ReadAllText(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\clients.json"));

            _log.Info("Reading configuration");
            _contextFactory = new FlexinetsEntitiesFactory(CloudConfigurationManager.GetSetting("SQLConnectionString"));
            var path = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\dictionary";
            var dictionary = new RadiusDictionary(path);
            var ipassSecret = CloudConfigurationManager.GetSetting("ipasssecret");
            var mbbSecret = CloudConfigurationManager.GetSetting("mbbsecret");
            var disconnectSecret = CloudConfigurationManager.GetSetting("disconnectSecret");
            var apiUrl = CloudConfigurationManager.GetSetting("ApiUrl");
            _log.Info("Configuration read");

            _rsIpass = new RadiusServer(new IPEndPoint(IPAddress.Any, port), dictionary);
            _rsIpass.AddPacketHandler(IPAddress.Parse("127.0.0.1"), ipassSecret, new iPassPacketHandler(_contextFactory));
            _rsIpass.Start();


            var networkIdProvider = new NetworkIdProvider(_contextFactory, apiUrl);
            var smsgateway = new SMSGatewayTwilio(
                   CloudConfigurationManager.GetSetting("twilio.deliveryreporturl"),
                   CloudConfigurationManager.GetSetting("twilio.accountsid"),
                   CloudConfigurationManager.GetSetting("twilio.authtoken"));

            var welcomeSender = new WelcomeSender(_contextFactory, smsgateway);
            var disconnector = new RadiusDisconnector(_contextFactory, disconnectSecret);
            var mdPacketHandler = new MobileDataPacketHandler(_contextFactory, networkIdProvider, welcomeSender, disconnector);

            _rsMbb = new RadiusServer(new IPEndPoint(IPAddress.Any, port + 1), dictionary);   // daah...
            _rsMbb.AddPacketHandler(IPAddress.Parse("127.0.0.1"), mbbSecret, mdPacketHandler);
            _rsMbb.Start();

            button1.Content = "Stop";
        }
示例#2
0
        protected override void OnStart(string[] args)
        {
            try
            {
                _log.Info($"Starting RadiusServerService build version {FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion}");
                _log.Info("Reading configuration");

                var loggerFactory = new LoggerFactory();
                loggerFactory.AddNLog();
                var dictionary = new RadiusDictionary(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\content\\radius.dictionary", loggerFactory.CreateLogger <RadiusDictionary>());


                var radiusPacketParser = new RadiusPacketParser(loggerFactory.CreateLogger <RadiusPacketParser>(), dictionary);
                var packetHandler      = new TestPacketHandler();
                var repository         = new PacketHandlerRepository();

                repository.AddPacketHandler(IPAddress.Parse("127.0.0.1"), packetHandler, "secret");

                _authenticationServer = new RadiusServer(
                    new Net.UdpClientFactory(),
                    new IPEndPoint(IPAddress.Any, 1812),
                    radiusPacketParser,
                    RadiusServerType.Authentication,
                    repository,
                    loggerFactory.CreateLogger <RadiusServer>());


                _log.Info("Configuration read");

                _authenticationServer.Start();
            }
            catch (Exception ex)
            {
                _log.Fatal(ex, "Failed to start service");
                throw;
            }
        }
        protected override void OnStart(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();
            try
            {
                _log.Info($"Starting RadiusServerService build version {FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion}");
                _log.Info("Reading configuration");

                _contextFactory = new FlexinetsEntitiesFactory(CloudConfigurationManager.GetSetting("SQLConnectionString"));

                var dictionary = new RadiusDictionary(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\content\\radius.dictionary");
                var port       = Convert.ToInt32(CloudConfigurationManager.GetSetting("Port"));
                _authenticationServer = new RadiusServer(new IPEndPoint(IPAddress.Any, port), dictionary, RadiusServerType.Authentication);
                _accountingServer     = new RadiusServer(new IPEndPoint(IPAddress.Any, port + 1), dictionary, RadiusServerType.Accounting); // todo, good grief...

                var authProxy = new iPassAuthenticationProxy(
                    _contextFactory,
                    CloudConfigurationManager.GetSetting("ipass.checkpathold"),
                    CloudConfigurationManager.GetSetting("ipass.checkpathnew"));

                var ipassPacketHandler = new iPassPacketHandler(_contextFactory, authProxy, new UserAuthenticationProvider(null, _contextFactory, null));
                var ipassSecret        = CloudConfigurationManager.GetSetting("ipasssecret");
                _authenticationServer.AddPacketHandler(IPAddress.Parse("127.0.0.1"), ipassSecret, ipassPacketHandler);
                _accountingServer.AddPacketHandler(IPAddress.Parse("127.0.0.1"), ipassSecret, ipassPacketHandler);

                var smsgateway = new SMSGatewayTwilio(
                    CloudConfigurationManager.GetSetting("twilio.deliveryreporturl"),
                    CloudConfigurationManager.GetSetting("twilio.accountsid"),
                    CloudConfigurationManager.GetSetting("twilio.authtoken"));

                var welcomeSender  = new WelcomeSender(_contextFactory, smsgateway);
                var disconnectorV2 = new RadiusDisconnectorV2(
                    CloudConfigurationManager.GetSetting("disconnector.username"),
                    CloudConfigurationManager.GetSetting("disconnector.password"),
                    CloudConfigurationManager.GetSetting("disconnector.apiurl"));
                var mbbPacketHandlerV2 = new MobileDataPacketHandlerV2(_contextFactory, welcomeSender, disconnectorV2);

                // todo refactor this
                var remoteAddresses = new List <IPAddress> {
                    IPAddress.Parse("10.239.24.6"),
                    IPAddress.Parse("10.239.24.7"),
                    IPAddress.Parse("10.239.24.8"),
                    IPAddress.Parse("10.239.24.15"),
                    IPAddress.Parse("10.239.24.16"),
                    IPAddress.Parse("10.239.24.17")
                };


                var mbbNewSecret = CloudConfigurationManager.GetSetting("mbbnewsecret");
                _authenticationServer.AddPacketHandler(remoteAddresses, mbbNewSecret, mbbPacketHandlerV2);
                _accountingServer.AddPacketHandler(remoteAddresses, mbbNewSecret, mbbPacketHandlerV2);

                _log.Info("Configuration read");

                _authenticationServer.Start();
                _accountingServer.Start();
            }
            catch (Exception ex)
            {
                _log.Fatal("Failed to start service", ex);
                throw;
            }
        }