Exemple #1
0
 private void FireServerLoginResultArrived(IClientConnection con, PacketLoginResult result)
 {
     if (ServerLoginResultArrivedInvoker != null)
     {
         ServerLoginResultArrivedInvoker(con, result);
     }
 }
Exemple #2
0
        /// <summary>
        /// Sends the target connection a listing and status of all game server clusters that this login server knows about.
        /// This is the listing that the client should allow the player too choose from in the UI.
        /// Returns false if currently no servers are available for service.
        /// </summary>
        /// <param name="con"></param>
        protected virtual PacketLoginResult CreateLoginResultPacket()
        {
            // send login result
            PacketLoginResult lr = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);

            lr.ReplyCode = ReplyType.OK;

            bool haveAnyOnline = false;

            foreach (GameServerInfoGroup g in MyServer.OutboundServerGroups.Groups.Values)
            {
                if (!haveAnyOnline)
                {
                    haveAnyOnline = g.HasLiveOutboundServerConnections;
                }
                string serverInfo = g.ID + "," + g.HasLiveOutboundServerConnections;
                lr.ReplyMessage += "|" + serverInfo;
            }

            lr.ReplyMessage = lr.ReplyMessage.Trim('|');

            if (!haveAnyOnline)
            {
                lr.ReplyMessage = "No Wisp servers are currently online on this machine.";
            }

            Log1.Logger("Zeus.Inbound.Client.Login").Debug("Sending client " + ServerUser.AccountName + " Wisp server info: " + lr.ReplyMessage);
            return(lr);
        }
Exemple #3
0
        /// <summary>
        /// The target child server requires that we log in with our shared secret (App.Config) before it will
        /// entertain any other requests from us.  This method fires when the target server
        /// resolves the login request.
        /// </summary>
        protected override void OnServerLoginResponse(PacketLoginResult result)
        {
            base.OnServerLoginResponse(result);
            if (result.ReplyCode != ReplyType.OK)
            {
                Log1.Logger("Server").Error("Unable to login to target server [" + Name + "]. [" + result.ReplyMessage + "].");
                return;
            }

            string ip = "";

            ip = ((IPEndPoint)MyTCPSocket.RemoteEndPoint).Address.ToString();
            int port = -1;

            port = ((IPEndPoint)MyTCPSocket.RemoteEndPoint).Port;
            string serverName = result.Parms.GetStringProperty("ServerName");

            if (result.ReplyCode == ReplyType.OK)
            {
                ServerUserID = result.Parms.GetStringProperty((int)PropertyID.Name);
            }
            Server.UpdateGSIIP(ReportedIP, port, ip, serverName);

            PacketNull ping = CreatePacket((int)PacketType.Null, 0, false, false) as PacketNull;

            ping.NeedsReply = true;
            Send(ping);
        }
        protected override PacketLoginResult CreateLoginResultPacket()
        {
            PacketLoginResult lr = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);

            lr.ReplyCode = ReplyType.OK;

            GameServerInfo <OutboundServerConnection> cons = GetTargetServerForClusterHandoff("");
            bool haveAnyOnline = cons != null;

            if (cons != null)
            {
                lr.ReplyMessage = cons.Name + "," + "TRUE|";
            }

            if (!haveAnyOnline)
            {
                lr.ReplyMessage = "No servers available for service. Try again later.";
                lr.IsCritical   = true;
                lr.ReplyCode    = ReplyType.Failure;
            }

            Log1.Logger("LoginServer.Inbound.Login").Debug("Sending client " + ServerUser.AccountName + " game server info: " + lr.ReplyMessage);

            if (m_IsNewAcct)
            {
                ServerUser.Profile.Save(MyServer.RequireAuthentication);

                if (lr.ReplyCode != ReplyType.OK)
                {
                    lr.ReplyMessage += "\r\n(Account was created, however)";
                }
            }

            return(lr);
        }
Exemple #5
0
        /// <summary>
        /// Sends the target connection a listing and status of all game server clusters that this login server knows about.
        /// This is the listing that the client should allow the player too choose from in the UI.
        /// Returns false if currently no servers are available for service.
        /// </summary>
        /// <param name="con"></param>
        protected virtual PacketLoginResult CreateLoginResultPacket()
        {
            // send login result
            PacketLoginResult lr = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);

            lr.ReplyCode = ReplyType.OK;

            bool haveAnyOnline = false;

            foreach (GameServerInfoGroup g in MyServer.OutboundServerGroups.Groups.Values)
            {
                if (!haveAnyOnline)
                {
                    haveAnyOnline = g.HasLiveOutboundServerConnections;
                }

                GameServerInfo <OutboundServerConnection> svr = g.NextConnection();

                string serverName = g.ID;

                string serverInfo = serverName + "," + g.HasLiveOutboundServerConnections;
                lr.ReplyMessage += "|" + serverInfo;
            }

            if (!haveAnyOnline)
            {
                lr.ReplyMessage = "No servers available for service.";
                lr.IsCritical   = true;
                lr.ReplyCode    = ReplyType.Failure;
            }

            Log1.Logger("LoginServer.Inbound.Login").Debug("Sending client " + ServerUser.AccountName + " game server info: " + lr.ReplyMessage);
            return(lr);
        }
Exemple #6
0
        /// <summary>
        /// Gets called when a player sends a login request ticket.
        /// </summary>
        private void OnPlayerLoginRequest(INetworkConnection con, Packet msg)
        {
            try
            {
                string             loginMsg           = "";
                PacketLoginRequest packetLoginRequest = msg as PacketLoginRequest;
                msg.NeedsReply = false; // handle sending ourselves because we dont want OnConnectionReady to fire before the player gets the login result.

                ServerUser su = null;
                su = ConnectionManager.GetAuthorizedUser(packetLoginRequest.AccountName, MyServer, packetLoginRequest.LoginConnectionType);;

                PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                if (su == null || su.AuthTicket.ToString() != packetLoginRequest.Password)
                {
                    OnPlayerLoginResolved(packetLoginRequest, false, ref loginMsg);
                    lrf.IsCritical   = true;
                    lrf.ReplyCode    = ReplyType.Failure;
                    lrf.ReplyMessage = "Account credentials refused by server! " + loginMsg;
                    msg.ReplyPacket  = lrf;
                    return;
                }

                lrf.ReplyCode    = ReplyType.OK;
                lrf.ReplyMessage = su.AccountName + ", ready to play!";
                lrf.Parms.SetProperty("ServerName", 1, MyServer.ServerName);
                msg.ReplyPacket = lrf;

                ServerUser.CurrentCharacter = su.CurrentCharacter;
                su.MyConnection             = this;
                ServerUser.MyConnection     = null;
                this.ServerUser             = su;

                if (!OnPlayerLoginResolved(packetLoginRequest, true, ref loginMsg))
                {
                    lrf.ReplyCode    = ReplyType.Failure;
                    lrf.IsCritical   = true;
                    lrf.ReplyMessage = "Login Failed! " + loginMsg;
                    return;
                }

                Log1.Logger("Server.Inbound.Login").Info(packetLoginRequest.AccountName + ": " + lrf.ReplyMessage);

                lrf.Parms.SetProperty(-1, ServerUser.Profile.UserRoles);
                lrf.Parms.SetProperty(-2, ServerUser.Profile.MaxCharacters);
                msg.NeedsReply = false; // don't want to fire OnConnectionReady before the client gets the login reply
                Send(lrf);              // " "

                OnConnectionReady();
            }
            catch (Exception e)
            {
                Log1.Logger("Server.Inbound.Login").Error("InboundPlayerConnection::OnPlayerLoginRequest failed. ", e);
                PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                lrf.ReplyCode    = ReplyType.Failure;
                lrf.IsCritical   = true;
                lrf.ReplyMessage = "Login Failed! " + e.Message;
                msg.ReplyPacket  = lrf;
            }
        }
 protected override void OnServerLoginResponse(PacketLoginResult result)
 {
     base.OnServerLoginResponse(result);
     if (result.ReplyCode == ReplyType.OK && ConnectionReady != null)
     {
         ConnectionReady(this, EventArgs.Empty);
     }
 }
Exemple #8
0
        private void DoLocalLogin(INetworkConnection con, Packet pMsg)
        {
            bool authd = IsLocalConnection();

            try
            {
                PacketLoginRequest p = pMsg as PacketLoginRequest;
                ServerUser.AccountName = p.AccountName;
                Log1.Logger("Zeus").Info("Local user " + Environment.UserName + " is attempting login...");

                bool hasAccountAccess = authd;

                if (!hasAccountAccess)
                {
                    PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                    lrf.IsCritical   = true; // this along with reply code failure forces D/C
                    lrf.ReplyCode    = ReplyType.Failure;
                    lrf.ReplyMessage = string.Format(p.AccountName + " failed to authenticate local IP address.");
                    pMsg.ReplyPacket = lrf;

                    Log1.Logger("Zeus").Info(lrf.ReplyMessage);
                    return;
                }

                PacketLoginResult result = CreateLoginResultPacket();
                if (result.ReplyCode == ReplyType.OK)
                {
                    ServerUser.AuthTicket      = Guid.NewGuid();
                    ServerUser.IsAuthenticated = true;
                    MembershipUser mu = Membership.GetUser(p.AccountName, true);
                    if (mu != null)
                    {
                        ServerUser.ID = (Guid)mu.ProviderUserKey;
                    }
                    else if (authd)
                    {
                        ServerUser.ID = Guid.NewGuid();
                    }

                    ConnectionManager.AuthorizeUser(ServerUser, false);
                    ServerUser.Profile.UserRoles = new string[] { "Administrator" };
                    result.Parms.SetProperty(-1, ServerUser.Profile.UserRoles);
                    result.Parms.SetProperty(-2, ServerUser.Profile.MaxCharacters);
                    LoggedInAndReady();
                }

                pMsg.ReplyPacket = result;
                Log1.Logger("Zeus").Info("Zeus client *" + Environment.UserName + "* authentication: " + result.ReplyCode.ToString() + ". " + result.ReplyMessage);
            }
            catch (Exception e)
            {
                Log1.Logger("Zeus").Error("Exception thrown whilst player attempted login. " + e.Message, e);
                KillConnection("Error logging in.");
            }
        }
Exemple #9
0
        /// <summary>
        /// The server we are connecting to has resolved our login request
        /// </summary>
        /// <param name="packetLoginResult"></param>
        private void OnLoginResult(INetworkConnection con, Packet packetLoginResult)
        {
            PacketLoginResult msg = packetLoginResult as PacketLoginResult;

            LoggedIn = msg.ReplyCode == ReplyType.OK;
            OnServerLoginResponse(msg);

            if (LoggedIn)
            {
                Clock.SyncEnabled = false;// ConfigHelper.GetStringConfig("SynchronizeClockWithServer", "TRUE").ToUpper() == "TRUE";
            }
        }
Exemple #10
0
 protected override void OnServerLoginResponse(PacketLoginResult result)
 {
     base.OnServerLoginResponse(result);
     if (result.ReplyCode == ReplyType.OK)
     {
         Log1.Logger("LoginServer.Outbound.Login").Info("Logged in successfully to " + Name);
     }
     else
     {
         Log1.Logger("LoginServer.Outbound.Login").Error("Failed to log in to " + Name + ". " + result.ReplyMessage);
     }
 }
Exemple #11
0
 protected override void OnServerLoginResponse(PacketLoginResult result)
 {
     base.OnServerLoginResponse(result);
     if (result.ReplyCode == ReplyType.OK)
     {
         Log1.Logger(Server.ServerUserID).Info("Logged in successfully to " + Name);
     }
     else
     {
         Log1.Logger(Server.ServerUserID).Info("Failed to log in to " + Name + ". " + result.ReplyMessage);
     }
 }
Exemple #12
0
 protected override void OnServerLoginResponse(PacketLoginResult packetLoginResult)
 {
     if (packetLoginResult.ReplyCode == ReplyType.OK)
     {
         Game g = packetLoginResult.Parms.GetWispProperty("TargetGame") as Game;
         if (g != null)
         {
             CurrentGame = FireGameActivating(this, g);
         }
     }
     base.OnServerLoginResponse(packetLoginResult);
 }
Exemple #13
0
 protected override void OnServerLoginResponse(PacketLoginResult result)
 {
     base.OnServerLoginResponse(result);
     if (result.ReplyCode == ReplyType.OK)
     {
         Log1.Logger("Zeus.Outbound.Server.Login").Info("Logged in successfully to " + Name);
     }
     else
     {
         Log1.Logger("Zeus.Outbound.Server.Login").Info("Failed to log in to " + Name);
     }
 }
        /// <summary>
        /// Gets called when a parent server is requesting to be connected with this server.
        /// There is no account in the accounts DB for the parent servers... there is only a shared secret which is shared among all servers in the clusters.
        /// The shared secret is defined in the App.Config.
        /// </summary>
        private void OnClusterServerLoginRequest(INetworkConnection con, Packet msg)
        {
            PacketLoginRequest p = msg as PacketLoginRequest;

            m_ServerUser.AccountName = p.AccountName;

            // send login result
            PacketLoginResult lr = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);

            //lr.ReplyMessage = ServerBase.ServerName;
            lr.Parms.SetProperty(1, MyServer.ServerName);
            lr.ReplyCode = (p.Password.ToUpper() == SharedSecretWithClusterServers.ToString().ToUpper()) ? ReplyType.OK : ReplyType.Failure;
            if (lr.ReplyCode == ReplyType.Failure)
            {
                lr.ReplyMessage = "Bad credentials.";
            }

            if (!OnClusterServerLoginResolved(p, lr.ReplyCode == ReplyType.OK))
            {
                lr.ReplyCode = ReplyType.Failure;
            }

            if (lr.ReplyCode == ReplyType.OK)
            {
                lr.Parms.SetProperty((int)PropertyID.Name, MyServer.ServerUserID);
                m_ServerUser.AccountName = p.AccountName;
                m_ServerUser.IsAuthorizedClusterServer = true;
                m_ServerUser.RenewAuthorizationTicket(); // make sure we dont time out
            }

            msg.ReplyPacket = lr;

            if (lr.ReplyCode != ReplyType.OK)
            {
                lr.IsCritical = true;
                Log1.Logger("Server.Inbound.Login").Info("Failed authentication for " + p.AccountName + ", using password *" + p.Password + "* . Killing connection.");
                return;
            }

            RegisterPacketHandler((int)PacketType.Null, OnPing);

            ConnectionManager.AddParentConnection(this, m_ServerUser);
            OnParentConnectionSet();
            OnConnectionReady();
        }
Exemple #15
0
        private void DoNoAuthLogin(INetworkConnection con, Packet pMsg)
        {
            try
            {
                PacketLoginRequest p = pMsg as PacketLoginRequest;
                ServerUser.AccountName  = Guid.NewGuid().ToString(); // assign random session name
                ServerUser.OwningServer = MyServer.ServerUserID;
                Log1.Logger("LoginServer.Inbound.Login").Info("No-auth assigned user name " + ServerUser.AccountName + " from " + RemoteIP + " is attempting login...");
                Log1.Logger("LoginServer.UserIPMap").Info("User [" + p.AccountName + "] from [" + RemoteIP + "] is attempting login.");
                string msg = "";

                if (!HaveServersForService())
                {
                    PacketLoginResult ns = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                    ns.ReplyMessage  = "No servers available for service.\r\n\r\nTry again later.";
                    ns.IsCritical    = true;
                    ns.ReplyCode     = ReplyType.Failure;
                    pMsg.ReplyPacket = ns;
                    return;
                }

                PacketLoginResult result = CreateLoginResultPacket();
                if (result.ReplyCode == ReplyType.OK)
                {
                    ServerUser.AuthTicket      = Guid.NewGuid();
                    ServerUser.IsAuthenticated = true;
                    ServerUser.ID = Guid.NewGuid(); // generate random ID for this session

                    RegisterPacketHandler((int)PacketType.RequestHandoffToServer, OnClusterHandoffRequest);
                    ServerUser.Profile.UserRoles = new string[0];
                    result.Parms.SetProperty("AccountName", ServerUser.AccountName);
                    result.Parms.SetProperty(-1, ServerUser.Profile.UserRoles);
                    result.Parms.SetProperty(-2, ServerUser.Profile.MaxCharacters);
                    ConnectionManager.AuthorizeUser(ServerUser);
                }
                pMsg.ReplyPacket = result;
                Log1.Logger("LoginServer.Inbound.Login").Info("Game client *" + ServerUser.AccountName + "* authentication: " + result.ReplyCode.ToString() + ". " + result.ReplyMessage);
            }
            catch (Exception e)
            {
                Log1.Logger("LoginServer.Inbound.Login").Error("Exception thrown whilst player attempted login. " + e.Message, e);
                KillConnection("Error logging in.");
            }
        }
Exemple #16
0
        /// <summary>
        /// Gets called when the server we are connecting to has resolved our login request
        /// </summary>
        protected virtual void OnServerLoginResponse(PacketLoginResult result)
        {
            try
            {
                if (result.ReplyCode == ReplyType.OK)
                {
                    Roles = result.Parms.GetStringArrayProperty(-1);

                    int numSamplesForClockSync = ConfigHelper.GetIntConfig("NumSamplesForClockSync", 10);  // 10 samples
                    int syncTimeAllowed        = ConfigHelper.GetIntConfig("ClockSyncTimeAllowed", 15000); // across 15 seconds
                    int timeBetweenSyncs       = ConfigHelper.GetIntConfig("TimeBetweenClockSync", 0);     // only sync once per session
                    Clock = new NetworkClock(this, numSamplesForClockSync, syncTimeAllowed, timeBetweenSyncs);
                }

                FireServerLoginResultArrived(this, result);
            }
            catch (Exception e)
            {
                Log.LogMsg("Login failure. " + e.Message);
            }
        }
 protected override void OnServerLoginResponse(PacketLoginResult packetLoginResult)
 {
     if (packetLoginResult.ReplyCode == ReplyType.OK)
     {
         Game g = packetLoginResult.Parms.GetWispProperty("TargetGame") as Game;
         if (g != null)
         {
             CurrentGame = FireGameActivating(this, g);
         }
     }
     base.OnServerLoginResponse(packetLoginResult);
 }
Exemple #18
0
 protected override void OnServerLoginResponse(PacketLoginResult result)
 {
     base.OnServerLoginResponse(result);
 }
        /// <summary>
        /// The target child server requires that we log in with our shared secret (App.Config) before it will
        /// entertain any other requests from us.  This method fires when the target server
        /// resolves the login request.
        /// </summary>
        protected override void OnServerLoginResponse(PacketLoginResult result)
        {
            base.OnServerLoginResponse(result);
            if (result.ReplyCode != ReplyType.OK)
            {
                Log1.Logger("Server").Error("Unable to login to target server [" + Name + "]. [" + result.ReplyMessage + "].");
                return;
            }

            string ip = "";
            ip = ((IPEndPoint)MyTCPSocket.RemoteEndPoint).Address.ToString();
            int port = -1;
            port = ((IPEndPoint)MyTCPSocket.RemoteEndPoint).Port;
            string serverName = result.Parms.GetStringProperty("ServerName");
            if (result.ReplyCode == ReplyType.OK)
            {
                ServerUserID = result.Parms.GetStringProperty((int)PropertyID.Name);
            }
            Server.UpdateGSIIP(ReportedIP, port, ip, serverName);

            PacketNull ping = CreatePacket((int)PacketType.Null, 0, false, false) as PacketNull;
            ping.NeedsReply = true;
            Send(ping);
        }
Exemple #20
0
        /// <summary>
        /// User requests login to the system.  This method attempts to authenticate the player (or create a new account, depending on method parms)
        /// </summary>
        public void DoDatabaseLogin(INetworkConnection con, Packet pMsg)
        {
            PacketLoginRequest p = pMsg as PacketLoginRequest;

            ServerUser.AccountName = p.AccountName;
            Log1.Logger("Zeus").Info("User " + p.AccountName + " from " + RemoteIP + " is attempting login...");

            string msg = "";

#if DEBUG
            DateTime start = DateTime.Now;
#endif
            bool isLocal          = IsLocalConnection();
            bool hasAccountAccess = isLocal || Membership.ValidateUser(p.AccountName, p.Password);


#if DEBUG
            DateTime end = DateTime.Now;
            TimeSpan len = end - start;
            Log1.Logger("Zeus").Debug("DB call to validate user took " + len.TotalSeconds.ToString() + " seconds.");
#endif

            if (!hasAccountAccess)
            {
                PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                lrf.IsCritical   = true; // this along with reply code failure forces D/C
                lrf.ReplyCode    = ReplyType.Failure;
                lrf.ReplyMessage = string.Format("Authentication Failed. No account matching these credentials was found. Goodbye.");
                pMsg.ReplyPacket = lrf;

                Log1.Logger("Zeus").Info(p.AccountName + ": " + lrf.ReplyMessage);
                return;
            }

            MembershipUser usr = Membership.GetUser(p.AccountName, true);
            if (usr == null && isLocal)
            {
                usr = new MembershipUser("CustomizedMembershipProvider", Environment.MachineName + "\\" + Environment.UserName, Guid.NewGuid(), "", "", "", true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.MinValue);
            }

            ServerUser.ID = (Guid)usr.ProviderUserKey;
            // Cache this user's profile data
            ServerUser.Profile.Load(MyServer.RequireAuthentication);

            if (isLocal)
            {
                ServerUser.Profile.UserRoles = new string[] { "Administrator" };
            }

            // check if suspension needs to be lifted
            DateTime suspensionRelease = ServerUser.Profile.AddedProperties.GetDateTimeProperty("SuspensionRelease").GetValueOrDefault(DateTime.MinValue);
            bool     isSuspended       = false;
            if (suspensionRelease != DateTime.MinValue)
            {
                isSuspended = true;
                // currently suspended.  need to lift suspension?
                if (suspensionRelease < DateTime.UtcNow)
                {
                    DB.Instance.User_Unsuspend(ServerUser.ID, "System", suspensionRelease, "Suspension expired.  Time served.", -1);
                    isSuspended = false;
                }
            }

            if (isSuspended && !ServerUser.Profile.IsUserInRole("Administrator"))
            {
                PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                lrf.IsCritical   = true; // this along with reply code failure forces D/C
                lrf.ReplyCode    = ReplyType.Failure;
                lrf.ReplyMessage = "[" + p.AccountName + "] is currently suspended until " + suspensionRelease.ToString("g") + " UTC. Access to Zeus is denied.";
                pMsg.ReplyPacket = lrf;

                Log1.Logger("LoginServer.Inbound.Login").Info(lrf.ReplyMessage);
                return;
            }

            bool accountIsActive = isLocal || ServerUser.Profile.IsUserInRole("ActiveCustomerService");
            if (!accountIsActive)
            {
                PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                lrf.IsCritical   = true; // this along with reply code failure forces D/C
                lrf.ReplyCode    = ReplyType.Failure;
                lrf.ReplyMessage = "Authentication Failed. This account does not have the proper credential to connect. Goodbye.";
                pMsg.ReplyPacket = lrf;

                Log1.Logger("Zeus.Inbound.Client.Login").Info(p.AccountName + ": " + lrf.ReplyMessage);
                return;
            }

            PacketLoginResult result = CreateLoginResultPacket();
            if (result.ReplyCode == ReplyType.OK)
            {
                ServerUser.AuthTicket      = Guid.NewGuid();
                ServerUser.IsAuthenticated = true;
                ServerUser.ID = (Guid)usr.ProviderUserKey;

                ConnectionManager.AuthorizeUser(ServerUser, false);
                result.Parms.SetProperty(-1, ServerUser.Profile.UserRoles);
                result.Parms.SetProperty(-2, ServerUser.Profile.MaxCharacters);
                result.Parms.SetProperty((int)PropertyID.Name, MyServer.ServerUserID);
                LoggedInAndReady();
            }
            pMsg.ReplyPacket = result;

            Log1.Logger("Zeus").Info("Zeus client *" + ServerUser.AccountName + "* authentication: " + result.ReplyCode.ToString() + ". " + result.ReplyMessage);
        }
Exemple #21
0
 protected virtual void ReadProfileFromLoginPacket(PacketLoginResult lr)
 {
     User.Roles = lr.Parms.GetStringArrayProperty(-1);
     User.MaxCharacters = lr.Parms.GetIntProperty(-2).GetValueOrDefault(1);
 }
Exemple #22
0
 private void FireServerLoginResultArrived(IClientConnection con, PacketLoginResult result)
 {
     if (ServerLoginResultArrivedInvoker != null)
     {
         ServerLoginResultArrivedInvoker(con, result);
     }
 }
Exemple #23
0
        /// <summary>
        /// Gets called when the server we are connecting to has resolved our login request
        /// </summary>
        protected virtual void OnServerLoginResponse(PacketLoginResult result)
        {
            try
            {
                if (result.ReplyCode == ReplyType.OK)
                {
                    Roles = result.Parms.GetStringArrayProperty(-1);

                    int numSamplesForClockSync = ConfigHelper.GetIntConfig("NumSamplesForClockSync", 10); // 10 samples
                    int syncTimeAllowed = ConfigHelper.GetIntConfig("ClockSyncTimeAllowed", 15000); // across 15 seconds
                    int timeBetweenSyncs = ConfigHelper.GetIntConfig("TimeBetweenClockSync", 0); // only sync once per session
                    Clock = new NetworkClock(this, numSamplesForClockSync, syncTimeAllowed, timeBetweenSyncs);
                }

                FireServerLoginResultArrived(this, result);
            }
            catch (Exception e)
            {
                Log.LogMsg("Login failure. " + e.Message);
            }
        }
Exemple #24
0
        private void DoDatabaseLogin(INetworkConnection con, Packet pMsg)
        {
            try
            {
                PacketLoginRequest p = pMsg as PacketLoginRequest;
                ServerUser.AccountName  = p.AccountName;
                ServerUser.OwningServer = MyServer.ServerUserID;
                Log1.Logger("LoginServer.Inbound.Login").Info("User " + p.AccountName + " from " + RemoteIP + " is attempting login...");
                Log1.Logger("LoginServer.UserIPMap").Info("User [" + p.AccountName + "] from [" + RemoteIP + "] is attempting login.");

                if (!HaveServersForService())
                {
                    PacketLoginResult ns = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                    ns.ReplyMessage  = "No servers available for service.\r\n\r\nTry again later.";
                    ns.IsCritical    = true;
                    ns.ReplyCode     = ReplyType.Failure;
                    pMsg.ReplyPacket = ns;
                    return;
                }

                string msg = "";
                if (p.IsNewAccount && (!LoginServer.AllowNewAccountsOnTheFly || !CanCreateNewAccount(pMsg, ref msg) || !CreateNewAccount(p.AccountName, p.Password, p.AccountName, ref msg)))
                {
                    if (!LoginServer.AllowNewAccountsOnTheFly)
                    {
                        Log1.Logger("LoginServer.Inboud.Login").Warn("Login packet specified new account request flag but server config disallows this. Check 'AllowNewAccountsOnTheFly' in the config file. Default setting is FALSE.");
                    }
                    PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                    lrf.IsCritical   = true; // this along with reply code failure forces D/C
                    lrf.ReplyCode    = ReplyType.Failure;
                    lrf.ReplyMessage = msg;
                    pMsg.ReplyPacket = lrf;

                    Log1.Logger("LoginServer.Inbound.Login").Info(p.AccountName + " failed to create new account. " + lrf.ReplyMessage);
                    return;
                }

                bool hasAccountAccess = Membership.ValidateUser(p.AccountName, p.Password);

                if (!hasAccountAccess)
                {
                    PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                    lrf.IsCritical   = true; // this along with reply code failure forces D/C
                    lrf.ReplyCode    = ReplyType.Failure;
                    lrf.ReplyMessage = string.Format(p.AccountName + " authentication Failed. No account matching these credentials was found. Goodbye.");
                    pMsg.ReplyPacket = lrf;

                    Log1.Logger("LoginServer.Inbound.Login").Info(lrf.ReplyMessage);
                    return;
                }

                ServerUser.Profile.Load(MyServer.RequireAuthentication);

                foreach (AccountProfile.Session s in ServerUser.Profile.AllSessions)
                {
                    System.Diagnostics.Debug.WriteLine(ServerUser.AccountName + ": " + s.LoginUTC.ToLongTimeString() + " to " + s.LogoutUTC.ToLongTimeString() + " (duration " + s.Duration.TotalMinutes + " mins). From " + s.IP);
                }

                ServerUser.Profile.Save(MyServer.RequireAuthentication);

                // check if suspension needs to be lifted
                DateTime suspensionRelease = ServerUser.Profile.AddedProperties.GetDateTimeProperty("SuspensionRelease").GetValueOrDefault(DateTime.MinValue);
                bool     isSuspended       = false;
                if (suspensionRelease != DateTime.MinValue)
                {
                    isSuspended = true;
                    // currently suspended.  need to lift suspension?
                    if (suspensionRelease >= DateTime.UtcNow)
                    {
                        DB.Instance.User_Unsuspend(ServerUser.ID, "System", suspensionRelease, "Suspension expired.  Time served.", -1);
                        isSuspended = false;
                    }
                }

                if (isSuspended)
                {
                    PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                    lrf.IsCritical   = true; // this along with reply code failure forces D/C
                    lrf.ReplyCode    = ReplyType.Failure;
                    lrf.ReplyMessage = "[" + p.AccountName + "] is currently suspended until " + suspensionRelease.ToString("g") + " UTC. Please log in to this account through our website for details. Goodbye.";
                    pMsg.ReplyPacket = lrf;

                    Log1.Logger("LoginServer.Inbound.Login").Info(lrf.ReplyMessage);
                    return;
                }

                bool accountIsActive = ServerUser.Profile.IsUserInRole("ActiveUser");
                if (!accountIsActive)
                {
                    PacketLoginResult lrf = (PacketLoginResult)CreatePacket((int)PacketType.LoginResult, 0, true, true);
                    lrf.IsCritical   = true; // this along with reply code failure forces D/C
                    lrf.ReplyCode    = ReplyType.Failure;
                    lrf.ReplyMessage = p.AccountName + " this account is currently not active.  Please log in to this account through our website for details. Goodbye.";
                    pMsg.ReplyPacket = lrf;

                    Log1.Logger("LoginServer.Inbound.Login").Info(lrf.ReplyMessage);
                    return;
                }

                PacketLoginResult result = CreateLoginResultPacket();
                if (result.ReplyCode == ReplyType.OK)
                {
                    ServerUser.AuthTicket      = Guid.NewGuid();
                    ServerUser.IsAuthenticated = true;
                    ServerUser.ID = (Guid)Membership.GetUser(p.AccountName).ProviderUserKey;

                    RegisterPacketHandler((int)PacketType.RequestHandoffToServer, OnClusterHandoffRequest);

                    // load the user profile and add it to the packet.
                    result.Parms.SetProperty(-1, ServerUser.Profile.UserRoles);
                    result.Parms.SetProperty(-2, ServerUser.Profile.MaxCharacters);
                    ConnectionManager.AuthorizeUser(ServerUser);
                }

                pMsg.ReplyPacket = result;



                Log1.Logger("LoginServer.Inbound.Login").Info("Game client *" + ServerUser.AccountName + "* authentication: " + result.ReplyCode.ToString() + ". " + result.ReplyMessage);
            }
            catch (Exception e)
            {
                Log1.Logger("LoginServer.Inbound.Login").Error("Exception thrown whilst player attempted login. " + e.Message, e);
                KillConnection("Error logging in.");
            }
        }
Exemple #25
0
    /// <summary>
    /// Called by the login server when the results to our login attempt are available
    /// </summary>
    protected virtual void OnLoginServer_AuthenticationResolved(LoginServerOutboundConnection loginConnection, PacketLoginResult lr)
    {
        //System.Diagnostics.Debug.WriteLine("Game Servers Available: " + m_LoginCon.GameServers.Count);
        Log.LogMsg("Game Servers Available: " + m_LoginCon.GameServers.Count);
        SystemMessages.AddMessage(string.Format("Login server authenticated: {0}.  {1}", lr.ReplyCode == ReplyType.OK, lr.ReplyMessage), SystemMessageType.Networking);

        if (lr.ReplyCode == ReplyType.OK)
        {
            ReadProfileFromLoginPacket(lr);
        }

        FireLoginServerResult(loginConnection, lr);
    }
 protected override void OnServerLoginResponse(PacketLoginResult result)
 {
     base.OnServerLoginResponse(result);
 }
Exemple #27
0
 private void FireLoginServerResult(LoginServerOutboundConnection con, PacketLoginResult result)
 {
     if (LoginServerResultInvoker != null)
     {
         LoginServerResultInvoker(con, result);
     }
 }
 protected override void OnServerLoginResponse(PacketLoginResult result)
 {
     base.OnServerLoginResponse(result);
     if (result.ReplyCode == ReplyType.OK && ConnectionReady != null)
     {
         ConnectionReady(this, EventArgs.Empty);
     }
 }