예제 #1
0
        private static void PreAuth(Blaze.Packet p, PlayerInfo pi, NetworkStream ns)
        {
            List <Blaze.Tdf> input = Blaze.ReadPacketContent(p);

            Blaze.TdfStruct  CDAT = (Blaze.TdfStruct)input[0];
            Blaze.TdfInteger TYPE = (Blaze.TdfInteger)CDAT.Values[3];
            pi.isServer = TYPE.Value != 0;
            if (pi.isServer)
            {
                pi.game    = new GameInfo();
                pi.profile = Profiles.Create("test-server", 999);
                pi.userId  = 999;
            }
            Blaze.TdfStruct  CINF = (Blaze.TdfStruct)input[1];
            Blaze.TdfString  CVER = (Blaze.TdfString)CINF.Values[4];
            Blaze.TdfInteger LOC  = (Blaze.TdfInteger)CINF.Values[7];
            pi.loc     = LOC.Value;
            pi.version = CVER.Value;
            Logger.Data("[CLNT] #" + pi.userId + " is a " + (pi.isServer ? "server" : "client"));
            List <Blaze.Tdf> Result = new List <Blaze.Tdf>();

            Result.Add(Blaze.TdfInteger.Create("ANON", 0));
            Result.Add(Blaze.TdfString.Create("ASRC", "300294"));
            List <string> t  = Helper.ConvertStringList("{1} {25} {4} {27} {28} {6} {7} {9} {10} {11} {30720} {30721} {30722} {30723} {20} {30725} {30726} {2000}");
            List <long>   t2 = new List <long>();

            foreach (string v in t)
            {
                t2.Add(Convert.ToInt64(v));
            }
            Result.Add(Blaze.TdfList.Create("CIDS", 0, t2.Count, t2));
            t = new List <string>();
            List <string> t3 = new List <string>();

            Helper.ConvertDoubleStringList("{connIdleTimeout ; 90s} {defaultRequestTimeout ; 60s} {pingPeriod ; 20s} {voipHeadsetUpdateRate ; 1000} {xlspConnectionIdleTimeout ; 300}", out t, out t3);
            Blaze.TdfDoubleList conf2 = Blaze.TdfDoubleList.Create("CONF", 1, 1, t, t3, t.Count);
            List <Blaze.Tdf>    t4    = new List <Blaze.Tdf>();

            t4.Add(conf2);
            Result.Add(Blaze.TdfStruct.Create("CONF", t4));
            Result.Add(Blaze.TdfString.Create("INST", "battlefield-assault-pc"));
            Result.Add(Blaze.TdfInteger.Create("MINR", 0));
            Result.Add(Blaze.TdfString.Create("NASP", "cem_ea_id"));
            Result.Add(Blaze.TdfString.Create("PILD", ""));
            Result.Add(Blaze.TdfString.Create("PLAT", "pc"));
            List <Blaze.Tdf> QOSS = new List <Blaze.Tdf>();
            List <Blaze.Tdf> BWPS = new List <Blaze.Tdf>();

            BWPS.Add(Blaze.TdfString.Create("PSA\0", ProviderInfo.QOS_IP));
            BWPS.Add(Blaze.TdfInteger.Create("PSP\0", ProviderInfo.QOS_Port));
            BWPS.Add(Blaze.TdfString.Create("SNA\0", ProviderInfo.QOS_Name));
            QOSS.Add(Blaze.TdfStruct.Create("BWPS", BWPS));
            QOSS.Add(Blaze.TdfInteger.Create("LNP\0", 0xA));
            List <Blaze.Tdf> LTPS1 = new List <Blaze.Tdf>();

            LTPS1.Add(Blaze.TdfString.Create("PSA\0", ProviderInfo.QOS_IP));
            LTPS1.Add(Blaze.TdfInteger.Create("PSP\0", ProviderInfo.QOS_Port));
            LTPS1.Add(Blaze.TdfString.Create("SNA\0", ProviderInfo.QOS_Name));
            List <Blaze.TdfStruct> LTPS = new List <Blaze.TdfStruct>();

            LTPS.Add(Blaze.CreateStructStub(LTPS1));
            t = Helper.ConvertStringList("{" + ProviderInfo.QOS_SName + "}");
            QOSS.Add(Blaze.TdfDoubleList.Create("LTPS", 1, 3, t, LTPS, 1));
            QOSS.Add(Blaze.TdfInteger.Create("SVID", 0x45410805));
            Result.Add(Blaze.TdfStruct.Create("QOSS", QOSS));
            Result.Add(Blaze.TdfString.Create("RSRC", "300294"));
            Result.Add(Blaze.TdfString.Create("SVER", "WV Server"));
            byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, Result);
            ns.Write(buff, 0, buff.Length);
            ns.Flush();
        }
예제 #2
0
 public static void RefreshProfiles()
 {
     Profiles.Refresh();
 }
예제 #3
0
        public static void ProcessMagma(string data, Stream s)
        {
            string[] lines = data.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            Log("[MGMA] Request: " + lines[0]);
            string cmd = lines[0].Split(' ')[0];
            string url = lines[0].Split(' ')[1].Split(':')[0];

            if (cmd == "GET")
            {
                switch (url)
                {
                case "/api/nucleus/authToken":
                    Log("[MGMA] Sending AuthToken");
                    if (lines.Length > 5 && lines[5].StartsWith("x-server-key"))
                    {
                        ReplyWithXML(s, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<success><token>" + lines[5].Split(':')[1].Trim() + "</token></success>");
                    }
                    else
                    {
                        ReplyWithXML(s, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<success><token code=\"NEW_TOKEN\">" + lines[4].Split('=')[1] + "</token></success>");
                    }
                    return;

                case "/api/relationships/roster/nucleus":
                    Log("[MGMA] Sending Roster response");
                    ReplyWithXML(s, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<roster relationships=\"0\"/><success code=\"SUCCESS\"/>");
                    return;

                case "/wv/getProfiles":
                    Log("[MGMA] Sending Player Profiles");
                    StringBuilder sb = new StringBuilder();
                    Profiles.Refresh();
                    sb.Append("<profiles>\r\n");
                    foreach (Profile p in Profiles.profiles)
                    {
                        sb.Append("<profile name='" + Profiles.getProfilePath(p.id) + "'>" + Convert.ToBase64String(Encoding.Unicode.GetBytes(p._raw)) + "</profile>\r\n");
                    }
                    sb.Append("</profiles>\r\n");
                    ReplyWithXML(s, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n" + sb.ToString());
                    break;
                }
                if (url.StartsWith("/api/nucleus/name/"))
                {
                    int id = Convert.ToInt32(url.Substring(18));
                    Log("[MGMA] Sending name response for PID " + id);
                    PlayerInfo p = null;
                    foreach (PlayerInfo pi in BlazeServer.allClients)
                    {
                        if (pi.userId == id)
                        {
                            p = pi;
                            break;
                        }
                    }
                    if (p == null)
                    {
                        Log("[MGMA] Cant find player id!");
                        return;
                    }
                    ReplyWithXML(s, "<name>" + p.profile.name + "</name>");
                }
                if (url.StartsWith("/api/nucleus/entitlements/"))
                {
                    int id = Convert.ToInt32(url.Substring(26));
                    Log("[MGMA] Sending entitlement response for PID " + id);
                    PlayerInfo p = null;
                    foreach (PlayerInfo pi in BlazeServer.allClients)
                    {
                        if (pi.userId == id)
                        {
                            p = pi;
                            break;
                        }
                    }
                    if (p == null)
                    {
                        Log("[MGMA] Cant find player id!");
                        return;
                    }
                    string response = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><entitlements count=\"" + entitlements.Count + "\">";
                    int    i        = 1;
                    foreach (KeyValuePair <int, int> pair in entitlements)
                    {
                        response += "<entitlement><entitlementId>"
                                    + Convert.ToString(i)
                                    + "</entitlementId><entitlementTag>"
                                    + pair.Key
                                    + "-UNLM-</entitlementTag><useCount>" + pair.Value + "</useCount><grantDate>"
                                    + DateTime.UtcNow.ToString("MMM-dd-yyyy HH:mm:ss UTC")
                                    + "</grantDate><terminationDate></terminationDate><status>ACTIVE</status></entitlement>";
                        i++;
                    }
                    response += "</entitlements>";
                    ReplyWithXML(s, response);
                }
            }
            if (cmd == "POST" && !basicMode)
            {
                int pos = data.IndexOf("\r\n\r\n");
                if (pos != -1)
                {
                    Log("[MGMA] Content: \n" + data.Substring(pos + 4));
                }
            }
        }