Ejemplo n.º 1
0
 public UserConnection(Socket s, ServerBase server, bool isBlocking)
     : base(s, server, isBlocking)
 {
     RegisterPacketHandler((int)PacketType.LoginRequest, OnPlayerLoginRequest);
     RegisterPacketHandler((int)PacketType.PacketGenericMessage, (int)GenericMessageType.GetLatestVersion, OnGetLatestVersion);
     RegisterStandardPacketReplyHandler((int)PacketType.PacketGenericMessage, 878787, OnClientMachineInfo);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Override from ServerBase, to make sure we create the proper connection object for inbound connections.
        /// If we don't override this method, a generic InboundConnection class will be instantiated.
        /// </summary>
        protected override InboundConnection CreateInboundConnection(Socket s, ServerBase server, int serviceID, bool isBlocking)
        {
            InboundConnection con = null;
            // ServiceIDs represents the type connection that is being requested.
            // these IDs are set in the App.Config of the initiating server and are any arbitrarily agreed upon integers
            switch (serviceID)
            {
                case 7:
                    con = new ZeusInboundConnection(s, server, isBlocking);
                    con.ServiceID = serviceID;
                    break;
                case 1: // central server
                    con = new GSTurnedLobbyInboundCentralConnection(s, server, isBlocking);
                    con.ServiceID = serviceID;
                    GameManager.Instance.CentralServer = con as GSInboundServerConnection;
                    break;
                default: // assume player client
                    con = new GSTurnedLobbyInboundPlayerConnection(s, server, isBlocking);
                    con.ServiceID = serviceID;
                    break;
            }

            #if DEBUG
            if (con == null)
            {
                throw new ArgumentOutOfRangeException("ServiceID " + serviceID.ToString() + " is unknown to CreateInboundConnection.  Cannot process connection.");
            }
            #endif
            return con;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Override this method to create the correct connection object for connecting to another server in the Hive
 /// given the service request ID listed in the App.Config.
 /// Once the appropriate connection is created, it takes over the handshaking and communication.
 /// </summary>
 public override OutboundServerConnection CreateOutboundServerConnection(string name, ServerBase server, string reportedIP, int serviceID, bool isBlocking)
 {
     switch (serviceID)
     {
         default:
             return new BeholderOutboundServerConnection(name, server, reportedIP, isBlocking);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Override from ServerBase, to make sure we create the proper connection object for inbound connections.
 /// If we don't override this method, a generic CSInboundServerConnection class will be instantiated.
 /// </summary>
 protected override InboundConnection CreateInboundConnection(Socket s, ServerBase server, int serviceId, bool isBlocking)
 {
     if (serviceId == 7)
     {
         return new ZeusInboundConnection(s, server, isBlocking);
     }
     return new CSInboundServerConnection(s, server, isBlocking);
 }
Ejemplo n.º 5
0
        public OutboundServerConnection(string name, ServerBase server, string reportedIP, bool isBlocking)
            : base(isBlocking)
        {
            Name = name;
            LoggedIn = false;
            Disonnected = false;
            Server = server;
            ReportedIP = reportedIP;

            RegisterPacketHandler((int)ServerPacketType.ServerStatusUpdate, OnServerPong);
        }
Ejemplo n.º 6
0
        protected override InboundConnection CreateInboundConnection(System.Net.Sockets.Socket s, ServerBase server, int serviceID, bool isBlocking)
        {
            if (serviceID == 7)
            {
                return new ZeusInboundConnection(s, server, isBlocking);
            }

            if (serviceID == 99)
            {
                return new InboundChatLoginConnection(s, server, isBlocking);
            }

            return new InboundWorldLoginConnection(s, server, isBlocking);
        }
Ejemplo n.º 7
0
        public InboundConnection(Socket s, ServerBase server, bool isBlocking)
            : base(isBlocking)
        {
            MyServer = server;
            NUM_CONNECTIONS_IN_MEMORY++;
            try
            {
                MyTCPSocket = s;
                MyTCPSocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, DisableTCPDelay);

                m_TimeoutTimer = new Timer();

                int timeout = ConfigHelper.GetIntConfig("PlayerConnectionTimeout");
                if (timeout < 1)
                {
                    timeout = 10;
                }

                m_TimeoutTimer.Interval = timeout * 1000;
                m_TimeoutTimer.Elapsed += new ElapsedEventHandler(TimeoutTimer_Elapsed);
                m_TimeoutTimer.Start();

                ServerUser = new Shared.ServerUser();
                ServerUser.MyConnection = this;

                // Track the network socket associated with this connection object.
                string msg = "";
                if (!ConnectionManager.TrackUserSocket(this, ref msg))
                {
                    KillConnection(msg);
                    return;
                }

                if (!Transit.ListenForDataOnSocket())
                {
                    KillConnection("Remote end closed socket.");
                    return;
                }

                Log1.Logger("Server").Info("Now have [" + ConnectionManager.ConnectionCount.ToString() + " connections] attached.");
            }
            catch (Exception e)
            {
                KillConnection("Error instantiating Inbound connection object " + GetType().ToString() + " : " + e.Message);
                Log1.Logger("Server.Network").Error("Error instantiating Inbound connection object " + GetType().ToString() + " : " + e.Message, e);
                return;
            }
            SendRijndaelExchangeRequest();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Returns the authorized user object, or null if the user isn't currently authorized
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public static ServerUser GetAuthorizedUser(string account, ServerBase server, PacketLoginRequest.ConnectionType conType)
        {
            ServerUser u = null;

            if (conType == PacketLoginRequest.ConnectionType.AssistedTransfer)
            {
                lock (m_AuthorizedAccountsSyncRoot)
                {
                    AuthorizedAccounts.TryGetValue(account.ToLower(), out u);
                }
            }

            else if (conType == PacketLoginRequest.ConnectionType.UnassistedTransfer)
            {
                Guid ticket = Guid.Empty;
                string authServer = "";
                DateTime whenAuthd = DateTime.MinValue;
                int character = -1;
                string targetServerID = "";
                Guid accountID = Guid.Empty;
                if (!DB.Instance.User_GetAuthorizationTicket(account, out authServer, out ticket, out whenAuthd, out character, out targetServerID, out accountID) || ticket == Guid.Empty)
                {
                    return null;
                }

                if (targetServerID != server.ServerUserID)
                {
                    // we weren't authorized to be on this server.
                    Log1.Logger(server.ServerUserID).Error("[" + account + "] attempted unassisted transfer to [" + server.ServerUserID + "], but that user was only authorized to transfer to target server ID [" + targetServerID+ "]. Connection denied.");
                    return null;
                }

                if (whenAuthd + AuthTicketLifetime < DateTime.UtcNow)
                {
                    // ticket expired.
                    Log1.Logger(server.ServerUserID).Error("[" + account + "] attempted unassisted transfer to [" + server.ServerUserID + "], but that user's auth ticket is expired. Connection denied.");
                    return null;
                }

                // Got a ticket.  Load up the user from the DB.
                u = new ServerUser();

                u.OwningServer = server.ServerUserID;
                u.AuthTicket = ticket;
                u.ID = accountID;
                u.AccountName = account;

                // load the profile
                AccountProfile ap = new AccountProfile(account);
                u.Profile = ap;
                ap.Load(server.RequireAuthentication);

                // load the character
                if (character > -1)
                {
                    string msg = "";
                    u.CurrentCharacter = CharacterUtil.Instance.LoadCharacter(u, character, ref msg);
                    if (u.CurrentCharacter == null)
                    {
                        // Couldn't load character.
                        Log1.Logger(server.ServerUserID).Error("[" + account + "] attempted unassisted transfer with characer [" + character + "], but that character could not be loaded from the DB: [" + msg + "]. Connection denied.");
                        return null;
                    }
                    u.CurrentCharacter.OwningAccount = u;
                    CharacterCache.CacheCharacter(u.CurrentCharacter, server.ServerUserID);
                }
            }

            AuthorizeUser(u); // gotta call this to activate/renew the auth ticket on this server.
            return u;
        }
 public CentralLobbyInboundBeholderConnection(Socket s, ServerBase server, bool isBlocking)
     : base(s, server, isBlocking)
 {
 }
Ejemplo n.º 10
0
 public CSInboundPlayerConnection(Socket s, ServerBase server, bool isBlocking)
     : base(s, server, isBlocking)
 {
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Override from ServerBase, to make sure we create the proper connection object for inbound connections.
 /// If we don't override this method, a generic CSOutboundConnection class will be instantiated.
 /// </summary>
 public override OutboundServerConnection CreateOutboundServerConnection(string name, ServerBase server, string reportedIP, int serviceId, bool isBlocking)
 {
     return new CSOutboundConnection(name, server, reportedIP, isBlocking);
 }
 public LobbyBeholderOutboundServerConnection(string name, ServerBase server, string reportedIP, bool isBlocking)
     : base(name, server, reportedIP, isBlocking)
 {
 }
Ejemplo n.º 13
0
 public LSInboundConnection(Socket s, ServerBase server, bool isBlocking)
     : base(s, server, isBlocking)
 {
     RegisterPacketHandler((int)PacketType.LoginRequest, OnPlayerLoginRequest);
 }
 public CentralLobbyOutboundContentConnection(string name, ServerBase server, string reportedIP, bool isBlocking)
     : base(name, server, reportedIP, isBlocking)
 {
 }
Ejemplo n.º 15
0
 public InboundLobbyLoginConnection(Socket s, ServerBase server, bool isBlocking)
     : base(s, server, isBlocking)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Override from ServerBase, to make sure we create the proper connection object for outbound connections.
 /// If we don't override this method, a generic OutboundServerConnection class will be instantiated.
 /// </summary>
 public override OutboundServerConnection CreateOutboundServerConnection(string name, ServerBase server, string reportedIP, int serviceID, bool isBlocking)
 {
     // we need to define a new class and instantiate it here for any outbound connections.  currently, the game lobby server
     // should have no outbound connections.  If it tries to create some (i.e. this exception has been thrown), there is likely
     // an outbound connection defined in your App.Config file that probably shouldn't be there.
     throw new NotImplementedException("No outbound connections object have been defined for GameServer_Lobby");
 }
Ejemplo n.º 17
0
        protected override InboundConnection CreateInboundConnection(Socket s, ServerBase server, int serviceID, bool isBlocking)
        {
            if (serviceID == 7) // 7eus
            {
                ZeusPatchInboundZeusConnection zcon = new ZeusPatchInboundZeusConnection(s, server, isBlocking);
                return zcon;
            }

            UserConnection con = new UserConnection(s, server, isBlocking);
            return con;
        }
Ejemplo n.º 18
0
 public LSOutboundConnection(string name, ServerBase server, string reportedIP, bool isBlocking)
     : base(name, server, reportedIP, isBlocking)
 {
 }
 public GSTurnedLobbyInboundPlayerConnection(Socket s, ServerBase server, bool isBlocking)
     : base(s, server, isBlocking)
 {
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Override from ServerBase, to make sure we create the proper connection object for inbound connections.
 /// If we don't override this method, a generic InboundConnection class will be instantiated.
 /// </summary>
 protected override InboundConnection CreateInboundConnection(Socket s, ServerBase server, int serviceID, bool isBlocking)
 {
     return new AcctServiceInboundZeusConnection(s, server, isBlocking);
 }
 public GSLobbyInboundCentralConnection(Socket s, ServerBase server, bool isBlocking)
     : base(s, server, isBlocking)
 {
 }