Esempio n. 1
0
 public static void HandlePacket(StarNetNode node, StarboundClient client, IStarboundPacket packet)
 {
     if (PacketHandlers.ContainsKey(packet.PacketId))
     {
         PacketHandlers[packet.PacketId](node, client, packet);
     }
 }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            if (!File.Exists("node.key") || !File.Exists("node.key.pub"))
            {
                Console.WriteLine("Error: Please generate an RSA keypair with an empty password and save it to node.key and node.key.pub\n" +
                                  "$ openssl genrsa -out node.key && openssl rsa -pubout -in node.key -out node.key.pub\n" +
                                  "Distribute node.key.pub to a network authority node and add it to the trusted nodes with:\n" +
                                  "$ mono StarNet.exe add-node <ip address> <port> <path/to/key.pub>");
                return;
            }
            LoadKeys();
            LocalSettings settings = new LocalSettings();

            if (File.Exists("node.config"))
            {
                JsonConvert.PopulateObject(File.ReadAllText("node.config"), settings);
                File.WriteAllText("node.config", JsonConvert.SerializeObject(settings, Formatting.Indented));
            }
            else
            {
                settings = FirstRun(settings);
            }
            var sharedDatabase = new SharedDatabase(settings.ConnectionString);

            if (args.Length != 0)
            {
                HandleArguments(args, settings);
            }
            else
            {
                var localNode = new StarNetNode(sharedDatabase, settings,
                                                new CryptoProvider(ServerKey), new IPEndPoint(IPAddress.Any, settings.StarboundPort));
                Console.WriteLine("Starting node {0}", localNode.Settings.UUID);
                localNode.Start();
                while (true)
                {
                    Thread.Sleep(10000);
                }
            }
        }
Esempio n. 3
0
 public InterNodeNetwork(StarNetNode node, CryptoProvider crypto) : this(node.Settings.NetworkPort, crypto)
 {
     LocalNode = node;
 }