Exemplo n.º 1
0
 private void toolStripButton3_Click(object sender, EventArgs e)
 {
     Profiles.Refresh();
     RefreshProfileList();
 }
Exemplo n.º 2
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=\"18\">";
                    string[] ids      = "3001 3005 2023 3004 3024 2017 3013 3003 2004 3012 3018 2021 2054 3008 3006 3027 2005 2168 3114 3100 3075 3067 3099 3011 3094 3132 3127 3097 3110 3071 3095 3007 3096 3133 3120 3062 3041 3021 3043 3051 3131 3020 3124 3009 3052 3019 3118 3115 3012 3073 3078 3016 3047 3017 3085 3069 3112 3088 3064 3122 3091 3018 3117 3089 3092 3086 3137 3129 3087 3090 3136 3044 3061 3029 3130 3008 3038 3025 3000 3026 3050 3002 3044 3061 3130 3080 3014 3063 3048 3082 3116 3135 3013 3081 3134 3101 3072 3076 3121 3128 3003 3084 3015 3068 3113 3074 3079 3080 3103 3066 3045 3107 3111 3104 3138 3004 3070 3024 3022 3105 3109 3119 3023 3102 3108 3106 3065 3139 3077 3126 3066 3045 3107 3111 3004 3070 3090".Split(' ');
                    int      i        = 1;
                    foreach (var entitlement in ids)
                    {
                        response += "<entitlement><entitlementId>"
                                    + Convert.ToString(i)
                                    + "</entitlementId><entitlementTag>"
                                    + entitlement
                                    + "-UNLM-</entitlementTag><useCount>0</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));
                }
            }
        }
Exemplo n.º 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));
                }
            }
        }
Exemplo n.º 4
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", 1234);
            }
            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;
            BlazeServer.Log("[CLNT] #" + pi.userId + " is a " + (pi.isServer ? "server" : "client"), System.Drawing.Color.Blue);
            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();
        }