Ejemplo n.º 1
0
        public static PacketProcessResult HandleClient(Packet pck, RelaySession session, SilkroadServer server)
        {
            byte locale = pck.ReadUInt8();
            string username = pck.ReadAscii();
            string password = pck.ReadAscii();
            ushort ServerID = pck.ReadUInt16();

            if (Global.EnableServerInspection && !Global.InspectionLoginIgnore.Contains(username))
            {
                Packet login_response = new Packet(0xA102, false);
                login_response.WriteUInt8(0x02);
                login_response.WriteUInt8(0x02);
                login_response.WriteUInt8(0x02);
                session.SendPacketToClient(login_response);

                return PacketProcessResult.Disconnect;
            }

            if (Global.EnableIpAccountLimitation)
            {
                //We use Utility.GetRemoteEpString because username is assigned after AgentServer.UserAuth
                string clientAddr = Utility.GetRemoteEpString(session.Arguments.ClientSocket);
                int connectionCount = Global.srvmgr.GetUserCountByIpForAgent(clientAddr);

                if (connectionCount >= Global.AccountIpLimitCount)
                {
                    Packet login_resp = new Packet(0xA102, false);
                    login_resp.WriteUInt8(0x02);
                    login_resp.WriteUInt8(12);
                    session.SendPacketToClient(login_resp);

                    return PacketProcessResult.Disconnect;
                }
            }

            int serverOnline = 0;
            int.TryParse(session.State["server_" + ServerID] as string, out serverOnline);
            if (Global.ShardMaxOnline > 0 && Global.ShardMaxOnline <= serverOnline)
            {
                Packet login_response = new Packet(0xA102, false);
                login_response.WriteUInt8(0x02);
                login_response.WriteUInt8(5);
                session.SendPacketToClient(login_response);
                return PacketProcessResult.Disconnect;
            }

            if (Global.EnableLoginProcessing)
            {

                Packet login = new Packet(0x6102);
                login.WriteUInt8(Global.OriginalLocale > 0 && locale > 0 ? Global.OriginalLocale : locale);
                login.WriteAscii(username);
                login.WriteAscii(Global.EnableUseSha1Salt ? Utility.HashPassword(username, password) : password);
                login.WriteUInt16(ServerID);
                session.SendPacketToModule(login);
                //return PacketProcessResult.DoNothing;
                return PacketProcessResult.ContinueLoop;
            }
            return PacketProcessResult.DoNothing;
        }
Ejemplo n.º 2
0
        public static PacketProcessResult HandleClient(Packet pck, RelaySession session)
        {
            byte locale = pck.ReadUInt8();
            string username = pck.ReadAscii();
            string password = pck.ReadAscii();
            ushort ServerID = pck.ReadUInt16();
            //проверить
            if (Global.EnableIpAccountLimitation)
            {

                int nResult = Global.dbmgr.GetIpLimitationResult(username, Utility.GetRemoteEpString(session.Arguments.ClientSocket));
                if (nResult == 0)
                {
                    Packet login_response = new Packet(0xA102, false);
                    login_response.WriteUInt8(0x02);
                    login_response.WriteUInt8(12);
                    session.SendPacketToClient(login_response);
                    //drop conn
                    return PacketProcessResult.Disconnect;
                }
            }
            if (Global.EnableLoginProcessing)
            {

                Packet login = new Packet(0x6102);
                login.WriteUInt8(Global.OriginalLocale > 0 && locale > 0 ? Global.OriginalLocale : locale);
                login.WriteAscii(username);
                login.WriteAscii(Global.EnableUseSha1Salt ? Utility.HashPassword(username, password) : password);
                login.WriteUInt16(ServerID);
                session.SendPacketToModule(login);
                //return PacketProcessResult.DoNothing;
                return PacketProcessResult.ContinueLoop;
            }
            return PacketProcessResult.DoNothing;
        }
Ejemplo n.º 3
0
        public static PacketProcessResult HandleClient(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (Global.EnableSilkDisplayFix)
            {
                try
                {
                    string uname = session.State["username"] as string;

                    if (uname.Length == 0)
                    {
                        Global.logmgr.WriteLog(LogLevel.Error, "username len == 0 (request silk info)");
                        return(PacketProcessResult.Disconnect);
                    }

                    List <int> silk_info = Global.dbmgr.GetSilkDataByUsername(uname);
                    Packet     resp      = new Packet(0x3153);

                    resp.WriteUInt32(silk_info[0]);
                    resp.WriteUInt32(silk_info[1]);
                    resp.WriteUInt32(silk_info[2]);
                    //  m_ClientSecurity.Send(resp);
                    session.SendPacketToClient(resp);

                    // Global.g_LogManager.WriteLog(LogLevel.Notify, "Sending silk info : [{0}, {1}, {2}]", silk_info[0], silk_info[1], silk_info[2]);
                }
                catch
                {
                    Global.logmgr.WriteLog(LogLevel.Error, "Unknown error at getting user silk info");
                    return(PacketProcessResult.Disconnect);
                }
            }
            return(PacketProcessResult.DoNothing);
        }
Ejemplo n.º 4
0
        public static PacketProcessResult HandleClient(Packet pck, RelaySession session)
        {
            byte   locale   = pck.ReadUInt8();
            string username = pck.ReadAscii();
            string password = pck.ReadAscii();
            ushort ServerID = pck.ReadUInt16();

            //проверить
            if (Global.EnableIpAccountLimitation)
            {
                int nResult = Global.dbmgr.GetIpLimitationResult(username, Utility.GetRemoteEpString(session.Arguments.ClientSocket));
                if (nResult == 0)
                {
                    Packet login_response = new Packet(0xA102, false);
                    login_response.WriteUInt8(0x02);
                    login_response.WriteUInt8(12);
                    session.SendPacketToClient(login_response);
                    //drop conn
                    return(PacketProcessResult.Disconnect);
                }
            }
            if (Global.EnableLoginProcessing)
            {
                Packet login = new Packet(0x6102);
                login.WriteUInt8(Global.OriginalLocale > 0 && locale > 0 ? Global.OriginalLocale : locale);
                login.WriteAscii(username);
                login.WriteAscii(Global.EnableUseSha1Salt ? Utility.HashPassword(username, password) : password);
                login.WriteUInt16(ServerID);
                session.SendPacketToModule(login);
                //return PacketProcessResult.DoNothing;
                return(PacketProcessResult.ContinueLoop);
            }
            return(PacketProcessResult.DoNothing);
        }
Ejemplo n.º 5
0
        public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (server.HasAgentRedirectRules())
            {
                string src_host;
                int src_port;
                byte flag1 = pck.ReadUInt8();

                if (flag1 == 1)
                {
                    UInt32 uint1 = pck.ReadUInt32();
                    src_host = pck.ReadAscii();
                    src_port = pck.ReadUInt16();

                    bool redirectRuleFound = false;
                    for (int j = 0; j < server.RedirectRules.Count; j++)
                    {

                        if (server.RedirectRules[j].OriginalIp == src_host && server.RedirectRules[j].OriginalPort == src_port)
                        {
                            Packet mypck = new Packet(0xA102, false);
                            mypck.WriteUInt8(flag1);
                            mypck.WriteUInt32(uint1);
                            mypck.WriteAscii(server.RedirectRules[j].NewIp);
                            mypck.WriteUInt16((ushort)server.RedirectRules[j].NewPort);

                            //  m_ClientSecurity.Send(mypck);
                            session.SendPacketToClient(mypck);
                            redirectRuleFound = true;

                            break;

                        }

                    }
                    if (!redirectRuleFound)
                    {
                        Global.logmgr.WriteLog(LogLevel.Warning, "Agent redirect rules given, but [{0}:{1}] is unknown agent server", src_host, src_port);
                    }
                    else
                    {
                        return PacketProcessResult.ContinueLoop;
                    }

                }

            }
            return PacketProcessResult.DoNothing;
        }
Ejemplo n.º 6
0
        public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (server.HasAgentRedirectRules())
            {
                string src_host;
                int    src_port;
                byte   flag1 = pck.ReadUInt8();


                if (flag1 == 1)
                {
                    UInt32 uint1 = pck.ReadUInt32();
                    src_host = pck.ReadAscii();
                    src_port = pck.ReadUInt16();

                    bool redirectRuleFound = false;
                    for (int j = 0; j < server.RedirectRules.Count; j++)
                    {
                        if (server.RedirectRules[j].OriginalIp == src_host && server.RedirectRules[j].OriginalPort == src_port)
                        {
                            Packet mypck = new Packet(0xA102, false);
                            mypck.WriteUInt8(flag1);
                            mypck.WriteUInt32(uint1);
                            mypck.WriteAscii(server.RedirectRules[j].NewIp);
                            mypck.WriteUInt16((ushort)server.RedirectRules[j].NewPort);

                            //  m_ClientSecurity.Send(mypck);
                            session.SendPacketToClient(mypck);
                            redirectRuleFound = true;

                            break;
                        }
                    }
                    if (!redirectRuleFound)
                    {
                        Global.logmgr.WriteLog(LogLevel.Warning, "Agent redirect rules given, but [{0}:{1}] is unknown agent server", src_host, src_port);
                    }
                    else
                    {
                        return(PacketProcessResult.ContinueLoop);
                    }
                }
            }
            return(PacketProcessResult.DoNothing);
        }
        public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
        {
            Packet ServerList = new Packet(0xA101);
            byte GlobalOperationFlag = pck.ReadUInt8();

            ServerList.WriteUInt8(GlobalOperationFlag);

            while (GlobalOperationFlag == 1)
            {
                byte GlobalOperationType = pck.ReadUInt8();
                string GlobalOperationName = pck.ReadAscii();

                GlobalOperationFlag = pck.ReadUInt8();
                ServerList.WriteUInt8(GlobalOperationType);
                ServerList.WriteAscii(GlobalOperationName);
                ServerList.WriteUInt8(GlobalOperationFlag);
            }
            byte ShardFlag = pck.ReadUInt8();

            ServerList.WriteUInt8(ShardFlag);

            while (ShardFlag == 1)
            {
                uint ShardID = pck.ReadUInt16();
                string ShardName = pck.ReadAscii();
                uint ShardCurrent = pck.ReadUInt16();
                uint ShardCapacity = pck.ReadUInt16();
                byte ShardStatus = pck.ReadUInt8();
                byte GlobalOperationID = pck.ReadUInt8();
                ShardFlag = pck.ReadUInt8();
                session.State["server_" + ShardID] = ShardCurrent;

                ServerList.WriteUInt16(ShardID);
                ServerList.WriteAscii("Возрождение", Global.TextEncodeCode);
                ServerList.WriteUInt16(ShardCurrent + Global.ShardFakeOnline);
                ServerList.WriteUInt16(Global.ShardMaxOnline > 0 ? (uint)Global.ShardMaxOnline : ShardCapacity);
                ServerList.WriteUInt8(ShardStatus);
                ServerList.WriteUInt8(GlobalOperationID);
                ServerList.WriteUInt8(ShardFlag);

            }
            session.SendPacketToClient(ServerList);
            return PacketProcessResult.ContinueLoop;
        }
Ejemplo n.º 8
0
        public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
        {
            Packet ServerList          = new Packet(0xA101);
            byte   GlobalOperationFlag = pck.ReadUInt8();

            ServerList.WriteUInt8(GlobalOperationFlag);

            while (GlobalOperationFlag == 1)
            {
                byte   GlobalOperationType = pck.ReadUInt8();
                string GlobalOperationName = pck.ReadAscii();

                GlobalOperationFlag = pck.ReadUInt8();
                ServerList.WriteUInt8(GlobalOperationType);
                ServerList.WriteAscii(GlobalOperationName);
                ServerList.WriteUInt8(GlobalOperationFlag);
            }
            byte ShardFlag = pck.ReadUInt8();

            ServerList.WriteUInt8(ShardFlag);

            while (ShardFlag == 1)
            {
                uint   ShardID           = pck.ReadUInt16();
                string ShardName         = pck.ReadAscii();
                uint   ShardCurrent      = pck.ReadUInt16();
                uint   ShardCapacity     = pck.ReadUInt16();
                byte   ShardStatus       = pck.ReadUInt8();
                byte   GlobalOperationID = pck.ReadUInt8();
                ShardFlag = pck.ReadUInt8();
                session.State["server_" + ShardID] = ShardCurrent;

                ServerList.WriteUInt16(ShardID);
                ServerList.WriteAscii("Возрождение", Global.TextEncodeCode);
                ServerList.WriteUInt16(ShardCurrent + Global.ShardFakeOnline);
                ServerList.WriteUInt16(Global.ShardMaxOnline > 0 ? (uint)Global.ShardMaxOnline : ShardCapacity);
                ServerList.WriteUInt8(ShardStatus);
                ServerList.WriteUInt8(GlobalOperationID);
                ServerList.WriteUInt8(ShardFlag);
            }
            session.SendPacketToClient(ServerList);
            return(PacketProcessResult.ContinueLoop);
        }
Ejemplo n.º 9
0
 public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
 {
     if (Global.EnableLoginNotice)
     {
         bool noticeDone = false;
         bool.TryParse(session.State["noticeDone"] as string, out noticeDone);
         if (!noticeDone)
         {
             foreach (string text in Global.LoginNotice)
             {
                 Packet notice = new Packet(0x3026);
                 notice.WriteUInt8(7);
                 notice.WriteAscii(text, Global.TextEncodeCode);
                 session.SendPacketToClient(notice);
             }
             session.State["noticeDone"] = true;
         }
     }
     return(PacketProcessResult.DoNothing);
 }
Ejemplo n.º 10
0
 public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
 {
     if (Global.EnableStartIntro)
     {
         byte hz1 = pck.ReadUInt8();
         if (hz1 == 1)
         {
             ulong hz2 = pck.ReadUInt64();
             if (hz2 == 1)
             {
                 Packet intro = new Packet(0x3CA2);
                 intro.WriteAscii(Global.StartIntroScriptName);
                 intro.WriteUInt32(12);
                 session.SendPacketToClient(intro);
             }
         }
         return(PacketProcessResult.ContinueLoop);
     }
     return(PacketProcessResult.DoNothing);
 }
Ejemplo n.º 11
0
 public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
 {
     if (Global.EnableLoginNotice)
     {
         bool noticeDone = false;
         bool.TryParse(session.State["noticeDone"] as string, out noticeDone);
         if (!noticeDone)
         {
             foreach (string text in Global.LoginNotice)
             {
                 Packet notice = new Packet(0x3026);
                 notice.WriteUInt8(7);
                 notice.WriteAscii(text, Global.TextEncodeCode);
                 session.SendPacketToClient(notice);
             }
             session.State["noticeDone"] = true;
         }
     }
     return PacketProcessResult.DoNothing;
 }
Ejemplo n.º 12
0
        public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (Global.EnableStartIntro)
            {
                byte hz1 = pck.ReadUInt8();
                if (hz1 == 1)
                {
                    ulong hz2 = pck.ReadUInt64();
                    if (hz2 == 1)
                    {
                        Packet intro = new Packet(0x3CA2);
                        intro.WriteAscii(Global.StartIntroScriptName);
                        intro.WriteUInt32(12);
                        session.SendPacketToClient(intro);
                    }

                }
                return PacketProcessResult.ContinueLoop;
            }
            return PacketProcessResult.DoNothing;
        }
Ejemplo n.º 13
0
        public static PacketProcessResult HandleClient(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (Global.EnableItemMallBuyFix)
            {
                Packet MyResponse = new Packet(0xB566, true);

                string uname = session.State["username"] as string;

                if (uname.Length == 0)
                {
                    Global.logmgr.WriteLog(LogLevel.Warning, "username len == 0 !");
                    return(PacketProcessResult.Disconnect);
                }


                if (uname.Contains("'"))
                {
                    Global.logmgr.WriteLog(LogLevel.Warning, "User trying to exploit shop ! Uname str: {0}", uname);
                    return(PacketProcessResult.Disconnect);
                }

                List <string> query_res = Global.dbmgr.GetJidAndToken(uname);

                UInt32 jid   = uint.Parse(query_res[0]);
                string token = query_res[1];

                MyResponse.WriteUInt8(1);
                MyResponse.WriteUInt32(jid);
                MyResponse.WriteAscii(token);

                session.SendPacketToClient(MyResponse);
                //   Global.g_LogManager.WriteLog(LogLevel.Notify, "Shop packet OK [{0}] JID [{1}] TOKEN [{2}]",uname,jid,token);

                return(PacketProcessResult.ContinueLoop);
            }
            return(PacketProcessResult.DoNothing);
        }
Ejemplo n.º 14
0
        public static PacketProcessResult HandleClient(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (Global.EnableItemMallBuyFix)
            {
                Packet MyResponse = new Packet(0xB566, true);

                string uname = session.State["username"] as string;

                if (uname.Length == 0)
                {
                    Global.logmgr.WriteLog(LogLevel.Warning, "username len == 0 !");
                    return PacketProcessResult.Disconnect;
                }

                if (uname.Contains("'"))
                {
                    Global.logmgr.WriteLog(LogLevel.Warning, "User trying to exploit shop ! Uname str: {0}", uname);
                    return PacketProcessResult.Disconnect;
                }

                List<string> query_res = Global.dbmgr.GetJidAndToken(uname);

                UInt32 jid = uint.Parse(query_res[0]);
                string token = query_res[1];

                MyResponse.WriteUInt8(1);
                MyResponse.WriteUInt32(jid);
                MyResponse.WriteAscii(token);

                session.SendPacketToClient(MyResponse);
                //   Global.g_LogManager.WriteLog(LogLevel.Notify, "Shop packet OK [{0}] JID [{1}] TOKEN [{2}]",uname,jid,token);

                return PacketProcessResult.ContinueLoop;
            }
            return PacketProcessResult.DoNothing;
        }
Ejemplo n.º 15
0
        public static PacketProcessResult HandleClient(Packet pck, RelaySession session, SilkroadServer server)
        {
            byte   locale   = pck.ReadUInt8();
            string username = pck.ReadAscii();
            string password = pck.ReadAscii();
            ushort ServerID = pck.ReadUInt16();

            if (Global.EnableServerInspection && !Global.InspectionLoginIgnore.Contains(username))
            {
                Packet login_response = new Packet(0xA102, false);
                login_response.WriteUInt8(0x02);
                login_response.WriteUInt8(0x02);
                login_response.WriteUInt8(0x02);
                session.SendPacketToClient(login_response);

                return(PacketProcessResult.Disconnect);
            }

            if (Global.EnableIpAccountLimitation)
            {
                //We use Utility.GetRemoteEpString because username is assigned after AgentServer.UserAuth
                string clientAddr      = Utility.GetRemoteEpString(session.Arguments.ClientSocket);
                int    connectionCount = Global.srvmgr.GetUserCountByIpForAgent(clientAddr);

                if (connectionCount >= Global.AccountIpLimitCount)
                {
                    Packet login_resp = new Packet(0xA102, false);
                    login_resp.WriteUInt8(0x02);
                    login_resp.WriteUInt8(12);
                    session.SendPacketToClient(login_resp);

                    return(PacketProcessResult.Disconnect);
                }
            }

            int serverOnline = 0;

            int.TryParse(session.State["server_" + ServerID] as string, out serverOnline);
            if (Global.ShardMaxOnline > 0 && Global.ShardMaxOnline <= serverOnline)
            {
                Packet login_response = new Packet(0xA102, false);
                login_response.WriteUInt8(0x02);
                login_response.WriteUInt8(5);
                session.SendPacketToClient(login_response);
                return(PacketProcessResult.Disconnect);
            }


            if (Global.EnableLoginProcessing)
            {
                Packet login = new Packet(0x6102);
                login.WriteUInt8(Global.OriginalLocale > 0 && locale > 0 ? Global.OriginalLocale : locale);
                login.WriteAscii(username);
                login.WriteAscii(Global.EnableUseSha1Salt ? Utility.HashPassword(username, password) : password);
                login.WriteUInt16(ServerID);
                session.SendPacketToModule(login);
                //return PacketProcessResult.DoNothing;
                return(PacketProcessResult.ContinueLoop);
            }
            return(PacketProcessResult.DoNothing);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// DownloadServer info / patch info request packet (Module -> Client)
        /// </summary>
        /// <param name="pck"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (server.HasDownloadRedirectRules())
            {
                //Read original data
                byte result = pck.ReadUInt8();

                //UpdateInfo
                if (result == 0x02)
                {
                    byte errorCode = pck.ReadUInt8();

                    if (errorCode == 0x02)
                    {
                        Packet myPacket = new Packet(0xA100, false, true);

                        string tmpIp = pck.ReadAscii();
                        ushort tmpPort = pck.ReadUInt16();

                        bool redirectRuleFound = false;
                        for (int i = 0; i < server.RedirectRules.Count; i++)
                        {
                            if (server.RedirectRules[i].OriginalIp == tmpIp && server.RedirectRules[i].OriginalPort == tmpPort)
                            {
                                tmpIp = server.RedirectRules[i].NewIp;
                                tmpPort = (ushort)server.RedirectRules[i].NewPort;
                                redirectRuleFound = true;
                            }
                        }

                        if (!redirectRuleFound)
                        {
                            Global.logmgr.WriteLog(LogLevel.Warning, "Download redirect rules given, but [{0}:{1}] is unknown download server", tmpIp, tmpPort);
                        }

                        uint version = pck.ReadUInt32();
                        byte fileFlag = pck.ReadUInt8();

                        myPacket.WriteUInt8(result);
                        myPacket.WriteUInt8(errorCode);

                        myPacket.WriteAscii(tmpIp);
                        myPacket.WriteUInt16(tmpPort);
                        myPacket.WriteUInt32(version);
                        myPacket.WriteUInt8(fileFlag);

                        while (fileFlag == 0x01)
                        {
                            uint fileId = pck.ReadUInt32();
                            string fileName = pck.ReadAscii();
                            string filePath = pck.ReadAscii();
                            uint fileLength = pck.ReadUInt32();
                            byte doPack = pck.ReadUInt8();

                            fileFlag = pck.ReadUInt8();

                            myPacket.WriteUInt32(fileId);
                            myPacket.WriteAscii(fileName);
                            myPacket.WriteAscii(filePath);
                            myPacket.WriteUInt32(fileLength);
                            myPacket.WriteUInt8(doPack);
                            myPacket.WriteUInt8(fileFlag);
                        }
                        session.SendPacketToClient(myPacket);
                    }
                    //Do not send original packet
                    return PacketProcessResult.ContinueLoop;
                }
            }
            return PacketProcessResult.DoNothing;
        }
Ejemplo n.º 17
0
        public static PacketProcessResult HandleClient(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (Global.EnableItemMallBuyFix)
            {
                string uname = session.State["username"] as string;

                if (uname.Length == 0)
                {
                    Global.logmgr.WriteLog(LogLevel.Error, "username len == 0 (request buy mall item)");
                    return(PacketProcessResult.Disconnect);
                }

                byte ShopType = pck.ReadUInt8();

                if (ShopType == 24)
                {
                    //------------------------------------------
                    UInt16 uint1 = pck.ReadUInt16();
                    byte   b1    = pck.ReadUInt8();
                    byte   b2    = pck.ReadUInt8();
                    byte   b3    = pck.ReadUInt8();
                    string package_item_codename = pck.ReadAscii();
                    ushort nItems = pck.ReadUInt16();
                    pck.ReadUInt64();
                    uint refpackage_id = pck.ReadUInt32();
                    //------------------------------------------

                    string charname = session.State["charname"] as string;

                    if (charname.Length == 0)
                    {
                        Global.logmgr.WriteLog(LogLevel.Error, "charname len == 0 (buy in item mall)");
                        return(PacketProcessResult.Disconnect);
                    }

                    int res = Global.dbmgr.GetBuyMallResult(charname, package_item_codename, nItems);


                    if (res == -1)
                    {
                        //------------------------------------------
                        session.SendClientNotice("UIIT_STT_ANTICHEAT_ITEM_MALL_ERROR");
                        //------------------------------------------
                    }
                    else
                    {
                        //update silk
                        List <int> silk_info = Global.dbmgr.GetSilkDataByUsername(uname);


                        //------------------------------------------
                        Packet resp = new Packet(0x3153);

                        resp.WriteUInt32(silk_info[0]);
                        resp.WriteUInt32(silk_info[1]);
                        resp.WriteUInt32(silk_info[2]);
                        // m_ClientSecurity.Send(resp);
                        session.SendPacketToClient(resp);

                        //------------------------------------------
                        Packet inventory = new Packet(0xB034);
                        inventory.WriteUInt8(1);
                        inventory.WriteUInt8(24);
                        inventory.WriteUInt16(uint1);
                        inventory.WriteUInt8(b1);
                        inventory.WriteUInt8(b2);
                        inventory.WriteUInt8(b3);
                        inventory.WriteUInt8(1);
                        inventory.WriteUInt8(res);
                        inventory.WriteUInt16(nItems);
                        inventory.WriteUInt32(0);
                        //m_ClientSecurity.Send(inventory);
                        session.SendPacketToClient(inventory);
                        //------------------------------------------

                        Packet inventory2 = new Packet(0xB034);
                        inventory2.WriteUInt8(1);
                        inventory2.WriteUInt8(7);
                        inventory2.WriteUInt8((byte)(res));
                        //  m_ClientSecurity.Send(inventory2);
                        session.SendPacketToClient(inventory2);

                        //------------------------------------------

                        //  Global.g_LogManager.WriteLog(LogLevel.Notify, "GetBuyMallResult OK slot {0}", res);
                    }
                    return(PacketProcessResult.ContinueLoop);
                }
            }

            return(PacketProcessResult.DoNothing);
        }
Ejemplo n.º 18
0
        public static PacketProcessResult HandleClient(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (Global.EnableItemMallBuyFix)
            {
                string uname = session.State["username"] as string;

                if (uname.Length == 0)
                {
                    Global.logmgr.WriteLog(LogLevel.Error, "username len == 0 (request buy mall item)");
                    return PacketProcessResult.Disconnect;

                }

                byte ShopType = pck.ReadUInt8();

                if (ShopType == 24)
                {
                    //------------------------------------------
                    UInt16 uint1 = pck.ReadUInt16();
                    byte b1 = pck.ReadUInt8();
                    byte b2 = pck.ReadUInt8();
                    byte b3 = pck.ReadUInt8();
                    string package_item_codename = pck.ReadAscii();
                    ushort nItems = pck.ReadUInt16();
                    pck.ReadUInt64();
                    uint refpackage_id = pck.ReadUInt32();
                    //------------------------------------------

                    string charname = session.State["charname"] as string;

                    if (charname.Length == 0)
                    {
                        Global.logmgr.WriteLog(LogLevel.Error, "charname len == 0 (buy in item mall)");
                        return PacketProcessResult.Disconnect;
                    }

                    int res = Global.dbmgr.GetBuyMallResult(charname, package_item_codename, nItems);

                    if (res == -1)
                    {
                        //------------------------------------------
                        session.SendClientNotice("UIIT_STT_ANTICHEAT_ITEM_MALL_ERROR");
                        //------------------------------------------
                    }
                    else
                    {
                        //update silk
                        List<int> silk_info = Global.dbmgr.GetSilkDataByUsername(uname);

                        //------------------------------------------
                        Packet resp = new Packet(0x3153);

                        resp.WriteUInt32(silk_info[0]);
                        resp.WriteUInt32(silk_info[1]);
                        resp.WriteUInt32(silk_info[2]);
                        // m_ClientSecurity.Send(resp);
                        session.SendPacketToClient(resp);

                        //------------------------------------------
                        Packet inventory = new Packet(0xB034);
                        inventory.WriteUInt8(1);
                        inventory.WriteUInt8(24);
                        inventory.WriteUInt16(uint1);
                        inventory.WriteUInt8(b1);
                        inventory.WriteUInt8(b2);
                        inventory.WriteUInt8(b3);
                        inventory.WriteUInt8(1);
                        inventory.WriteUInt8(res);
                        inventory.WriteUInt16(nItems);
                        inventory.WriteUInt32(0);
                        //m_ClientSecurity.Send(inventory);
                        session.SendPacketToClient(inventory);
                        //------------------------------------------

                        Packet inventory2 = new Packet(0xB034);
                        inventory2.WriteUInt8(1);
                        inventory2.WriteUInt8(7);
                        inventory2.WriteUInt8((byte)(res));
                        //  m_ClientSecurity.Send(inventory2);
                        session.SendPacketToClient(inventory2);

                        //------------------------------------------

                        //  Global.g_LogManager.WriteLog(LogLevel.Notify, "GetBuyMallResult OK slot {0}", res);
                    }
                    return PacketProcessResult.ContinueLoop;
                }
            }

            return PacketProcessResult.DoNothing;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// DownloadServer info / patch info request packet (Module -> Client)
        /// </summary>
        /// <param name="pck"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public static PacketProcessResult HandleModule(Packet pck, RelaySession session, SilkroadServer server)
        {
            if (server.HasDownloadRedirectRules())
            {
                //Read original data
                byte result = pck.ReadUInt8();

                //UpdateInfo
                if (result == 0x02)
                {
                    byte errorCode = pck.ReadUInt8();

                    if (errorCode == 0x02)
                    {
                        Packet myPacket = new Packet(0xA100, false, true);

                        string tmpIp   = pck.ReadAscii();
                        ushort tmpPort = pck.ReadUInt16();

                        bool redirectRuleFound = false;
                        for (int i = 0; i < server.RedirectRules.Count; i++)
                        {
                            if (server.RedirectRules[i].OriginalIp == tmpIp && server.RedirectRules[i].OriginalPort == tmpPort)
                            {
                                tmpIp             = server.RedirectRules[i].NewIp;
                                tmpPort           = (ushort)server.RedirectRules[i].NewPort;
                                redirectRuleFound = true;
                            }
                        }

                        if (!redirectRuleFound)
                        {
                            Global.logmgr.WriteLog(LogLevel.Warning, "Download redirect rules given, but [{0}:{1}] is unknown download server", tmpIp, tmpPort);
                        }

                        uint version  = pck.ReadUInt32();
                        byte fileFlag = pck.ReadUInt8();

                        myPacket.WriteUInt8(result);
                        myPacket.WriteUInt8(errorCode);

                        myPacket.WriteAscii(tmpIp);
                        myPacket.WriteUInt16(tmpPort);
                        myPacket.WriteUInt32(version);
                        myPacket.WriteUInt8(fileFlag);

                        while (fileFlag == 0x01)
                        {
                            uint   fileId     = pck.ReadUInt32();
                            string fileName   = pck.ReadAscii();
                            string filePath   = pck.ReadAscii();
                            uint   fileLength = pck.ReadUInt32();
                            byte   doPack     = pck.ReadUInt8();

                            fileFlag = pck.ReadUInt8();

                            myPacket.WriteUInt32(fileId);
                            myPacket.WriteAscii(fileName);
                            myPacket.WriteAscii(filePath);
                            myPacket.WriteUInt32(fileLength);
                            myPacket.WriteUInt8(doPack);
                            myPacket.WriteUInt8(fileFlag);
                        }
                        session.SendPacketToClient(myPacket);
                    }
                    //Do not send original packet
                    return(PacketProcessResult.ContinueLoop);
                }
            }
            return(PacketProcessResult.DoNothing);
        }