예제 #1
0
        public async Task Begin()
        {
            EntryPoint[] points = await NRL.FindEntryPoints();

            if (points.Length == 0)
            {
                Log.Error("Unable to locate an available entry point");
                return;
            }

            EntryP = points[0];
            Log.Information("Connecting to entry point {Id}", EntryP.Certificate.Subject);
            Packet.StorePacketRoutine(PackType.TCP_S_HELLO, OnConnect);
            Packet.StorePacketRoutine(PackType.TCP_CS_SOCKET_DATA, EntryPoint.StandardDataHandler);
            Packet.StorePacketRoutine(PackType.TCP_CS_SOCKET_CONTROL, EntryPoint.StandardSocketControlHandler);
            await EntryP.Connect(null);

            await Task.Delay(-1);
        }
예제 #2
0
파일: NREP.cs 프로젝트: IDevJoe/NRCOMM
        static void Main()
        {
            Task.Run(async() =>
            {
                if (!File.Exists("config.json"))
                {
                    File.Copy("config.default.json", "config.json");
                }
                Console.WriteLine("Loading Configuration");
                await ReloadConfiguration();
                Console.WriteLine("Starting Logger.");
                using var log = new LoggerConfiguration().WriteTo.Console().MinimumLevel.Is((LogEventLevel)Enum.Parse(typeof(LogEventLevel), Config.MinLogLevel, true)).CreateLogger();
                Log.Logger    = log;
                Log.Debug("Minimum log level is DEBUG. This may get spammy");
                Log.Information("Node Router Entry Point v{Version:0.00}", Version);
                Log.Information("---------------------------");
                if (Config.IsDefault)
                {
                    LoudMessage("The configuration has default values. Unset 'default' in config.json to remove this message");
                }

                if (Config.X509 == null)
                {
                    LoudMessage("No X509 Certificate is loaded. This entry point will transmit information insecurely. DO NOT USE IN PRODUCTION.");
                }
                else if (Config.CA == null)
                {
                    LoudMessage("No CA is defined. Identities of clients will not be verified. DO NOT USE IN PRODUCTION.");
                }
                await SslManager.Initialize();
                Log.Information("Registering handlers");
                NRL.Initialize();
                Routines.RegisterRoutines();
                Log.Information("Starting TCP server");
                _ = TcpManager.StartTCP();
                Log.Information("Starting UDP Listen on 2888");
                _ = UdpManager.StartUDP();
                await Task.Delay(-1);
            }).GetAwaiter().GetResult();
        }
예제 #3
0
        static void Main(string[] args)
        {
            var  verbosity = LogEventLevel.Information;
            bool showHelp  = false;

            Host = "127.0.0.1";
            var options = new OptionSet()
            {
                { "publish", "publishes the app to the entry point", p => Publish = p != null },
                { "a|app=", "the app name [required]", n => AppName = n },
                { "p|port=", "the service port number [required]", (int r) => Port = r },
                { "ip=", "the ip address to connect to, defaults to 127.0.0.1", (string r) => Host = r },
                { "d", "show debug messages", v => { if (v != null)
                                                     {
                                                         verbosity = LogEventLevel.Debug;
                                                     }
                  } },
                { "h|help", "show this message and exit", h => showHelp = h != null },
            };

            options.Parse(args);
            if (AppName == null || Port == default || showHelp)
            {
                Console.WriteLine("Usage: PortConnector [--publish] [-a|-p|-d|-h]");
                using (var wr = new StringWriter())
                {
                    options.WriteOptionDescriptions(wr);
                    Console.WriteLine(wr.ToString());
                }

                return;
            }
            Log.Logger = new LoggerConfiguration().WriteTo.Console().MinimumLevel.Is(verbosity).CreateLogger();
            NRL.Initialize();
            new Program().Begin().GetAwaiter().GetResult();
        }