コード例 #1
0
ファイル: Users.cs プロジェクト: Symple85/StarryboundServer
        public static void GenerateSAKey()
        {
            if (!File.Exists(Path.Combine(StarryboundServer.SavePath, "authcode.txt")))
            {
                var r = new Random((int)DateTime.Now.ToBinary());
                StarryboundServer.authCode = r.Next(100000, 10000000).ToString();

                using (var tw = new StreamWriter(Path.Combine(StarryboundServer.SavePath, "authcode.txt")))
                {
                    tw.WriteLine(StarryboundServer.authCode);
                }
            }
            else
            {
                using (var tr = new StreamReader(Path.Combine(StarryboundServer.SavePath, "authcode.txt")))
                {
                    StarryboundServer.authCode = tr.ReadLine();
                }
            }

            StarryboundServer.logWarn("************************************************************************");
            StarryboundServer.logWarn("Important notice: To become SuperAdmin, you need to join the game and type /auth " + StarryboundServer.authCode);
            StarryboundServer.logWarn("This token will display until disabled by verification and is usable by any player.");
            StarryboundServer.logWarn("************************************************************************");
        }
コード例 #2
0
        public override bool doProcess(string[] args)
        {
            if (args.Length < 1)
            {
                this.client.sendCommandMessage("Incorrect auth code. This incident has been logged.");
                StarryboundServer.logWarn(this.client.playerData.name + " (IP: " + this.client.playerData.ip + ") attempted to use /auth even though it was disabled.");
                return(false);
            }

            string code = args[0];

            if (code != StarryboundServer.authCode)
            {
                this.client.sendCommandMessage("Incorrect auth code. This incident has been logged.");
                StarryboundServer.logWarn(this.client.playerData.name + " (IP: " + this.client.playerData.ip + ") attempted to use /auth even though it was disabled.");
                return(false);
            }

            this.client.playerData.group = StarryboundServer.groups["superadmin"];
            Users.SaveUser(this.client.playerData);
            StarryboundServer.authCode = null;

            if (File.Exists(Path.Combine(StarryboundServer.SavePath, "authcode.txt")))
            {
                File.Delete(Path.Combine(StarryboundServer.SavePath, "authcode.txt"));
            }

            this.client.sendCommandMessage("Thank you for installing Starrybound v" + StarryboundServer.VersionNum + "!");
            this.client.sendCommandMessage("You are now superadmin, your setup is now complete.");
            this.client.sendCommandMessage("You can use /group adduser <username> <group> to provide access to other users.");

            return(true);
        }
コード例 #3
0
ファイル: Shutdown.cs プロジェクト: deranon/StarryboundServer
        public override bool doProcess(string[] args)
        {
            if (!hasPermission())
            {
                permissionError(); return(false);
            }

            if (StarryboundServer.restartTime != 0)
            {
                StarryboundServer.sendGlobalMessage("^#f75d5d;The server restart has been aborted by " + this.player.name);
                StarryboundServer.logWarn("The server restart has been aborted.");
                StarryboundServer.changeState(ServerState.Running, "Command::Restart");
                StarryboundServer.restartTime = 0;
            }
            else
            {
                StarryboundServer.sendGlobalMessage("^#f75d5d;The server will restart in 30 seconds. We will be back shortly.");
                StarryboundServer.logWarn("The server will restart in 30 seconds.");
                StarryboundServer.restartTime = Utils.getTimestamp() + 30;
            }

            return(true);
        }