예제 #1
0
        public PacketIn ProcessPacket(TCPConnection con, byte[] buf, int start, int size)
        {
            PacketIn packet = new PacketIn(buf, start, size);

            switch (packet.ID)
            {
            case 72:     // TS_AC_AES_KEY_IV
                var pAES = new AUTH_PACKETS.AES_KEY_IV(packet);
                m_pAES_KEY = m_cRSA.PrivateDecrypt(pAES.nKey, OpenSSL.Crypto.RSA.Padding.PKCS1);
                GenerateLoginPacket(m_pAES_KEY, con);
                break;

            case 10000:     // TS_AC_RESULT
                var pResult = new AUTH_PACKETS.RESULT(packet.ReadUInt16(), packet.ReadUInt16(), packet.ReadInt32());
                if (pResult.nLoginFlag == 1)
                {
                    PacketOut o = new PacketOut(10021);
                    con.SendTCP(o);
                }
                else
                {
                    m_cAuthConnection.Disconnect();
                    XLog.Log("Login failed. Result: {0} - Disconnecting...", pResult.nResult);
                }
                m_szPassword = string.Empty;
                break;

            case 10022:     // TS_AC_SERVER_LIST
                m_iAuthServerList = new AUTH_PACKETS.SERVER_LIST(packet);
                XLog.Log("Server selection. Please use /select ID to connect to one of the listed servers below.");
                for (int i = 0; i < m_iAuthServerList.count; i++)
                {
                    XLog.Log(string.Format("-> Server {0}: {1}", i + 1, m_iAuthServerList.list[i].server_name));
                }
                break;

            case 10024:     // TS_AC_SELECT_SERVER
                con.Disconnect();

                var pSelectServer = new AUTH_PACKETS.SELECT_SERVER(packet, ref m_pAES_KEY);

                Config.ConfigNet conf = new Config.ConfigNet();
                conf.Port     = m_iAuthServerList.list[m_nSelectedServerIdx].server_port;
                conf.ListenIp = System.Net.IPAddress.Parse(m_iAuthServerList.list[m_nSelectedServerIdx].server_ip);

                PacketOut oEncrypt = new PacketOut(2005);
                oEncrypt.FillString(m_szName, 61);
                oEncrypt.Write(pSelectServer.encrypted_data, 0, pSelectServer.encrypted_data.Length);
                oEncrypt.FinalizeLengthAndChecksum();
                con.Close();
                m_cClientBase.CreateGameServerSession(oEncrypt, conf, m_szName);
                break;

            default:
                break;
            }
            return(packet);
        }
예제 #2
0
        public PacketIn ProcessPacket(TCPConnection con, byte[] buf, int start, int size)
        {
            PacketIn packet = new PacketIn( buf, start, size );
            switch ( packet.ID ) {

                case 72: // TS_AC_AES_KEY_IV
                    var pAES = new AUTH_PACKETS.AES_KEY_IV( packet );
                    m_pAES_KEY = m_cRSA.PrivateDecrypt( pAES.nKey, OpenSSL.Crypto.RSA.Padding.PKCS1 );
                    GenerateLoginPacket( m_pAES_KEY, con );
                    break;
                case 10000: // TS_AC_RESULT
                    var pResult = new AUTH_PACKETS.RESULT( packet.ReadUInt16(), packet.ReadUInt16(), packet.ReadInt32() );
                    if ( pResult.nLoginFlag == 1 ) {
                        PacketOut o = new PacketOut( 10021 );
                        con.SendTCP( o );
                    }
                    else {
                        m_cAuthConnection.Disconnect();
                        XLog.Log( "Login failed. Result: {0} - Disconnecting...", pResult.nResult );
                    }
                    m_szPassword = string.Empty;
                    break;
                case 10022: // TS_AC_SERVER_LIST
                    m_iAuthServerList = new AUTH_PACKETS.SERVER_LIST( packet );
                    XLog.Log( "Server selection. Please use /select ID to connect to one of the listed servers below." );
                    for ( int i = 0; i < m_iAuthServerList.count; i++ ) {
                        XLog.Log( string.Format( "-> Server {0}: {1}", i + 1, m_iAuthServerList.list[i].server_name ) );
                    }
                    break;
                case 10024: // TS_AC_SELECT_SERVER
                    con.Disconnect();

                    var pSelectServer = new AUTH_PACKETS.SELECT_SERVER( packet, ref m_pAES_KEY );

                    Config.ConfigNet conf = new Config.ConfigNet();
                    conf.Port = m_iAuthServerList.list[m_nSelectedServerIdx].server_port;
                    conf.ListenIp = System.Net.IPAddress.Parse( m_iAuthServerList.list[m_nSelectedServerIdx].server_ip );

                    PacketOut oEncrypt = new PacketOut( 2005 );
                    oEncrypt.FillString( m_szName, 61 );
                    oEncrypt.Write( pSelectServer.encrypted_data, 0, pSelectServer.encrypted_data.Length );
                    oEncrypt.FinalizeLengthAndChecksum();
                    con.Close();
                    m_cClientBase.CreateGameServerSession( oEncrypt, conf, m_szName );
                    break;
                default:
                    break;
            }
            return packet;
        }