Exemplo n.º 1
0
        private PyObject OldHandle(PyObject packet)
        {
            // Check for login packets and just forward them
            if (packet is PyTuple)
            {
                // Those are the first packets, sent by both client and server
                return(packet);
            }
            else if (packet is PyInt)
            {
                // This is only sent by the server
                return(packet);
            }
            else if (packet is PyString)
            {
                // This is only sent by the server
                return(packet);
            }
            else if (packet is PyDict)
            {
                // Packet sent by the client(HandshakeAck)
                // We need to modify it in order to put our own client address, as it isnt the same as the address that the server sends
                PyDict handshake = packet as PyDict;

                PyDict session = handshake.Get("session_init") as PyDict;

                session.Set("address", new PyString(socket.GetAddress()));

                handshake.Set("session_init", session);

                return(handshake);
            }
            else if (packet is PyObjectEx) // Exceptions... just check the type and decide what to do
            {
                PyException exception = new PyException();

                if (exception.Decode(packet) == true) // Ignore the error
                {
                    Log.Debug("Exceptions", "Got exception of type " + exception.exception_type);
                }

                return(packet);
            }
            else // Normal packets
            {
                PyPacket p = new PyPacket();
                if (p.Decode(packet) == false)
                {
                    // Big problem here, we dont know who to send this
                    Log.Error("Client", "Cannot decode PyPacket");
                }
                else
                {
                    return(HandlePyPacket(p));
                }

                return(packet);
            }
        }
Exemplo n.º 2
0
        public static PyDict GetCacheHints()
        {
            PyDict result = new PyDict();

            for (int i = 0; i < LoginCacheTableSize; i++)
            {
                result.Set(LoginCacheTable[i], GetCacheData(LoginCacheTable[i]));
            }

            return(result);
        }
Exemplo n.º 3
0
        public static PyObject DBResultToRowset(ref MySqlDataReader dat)
        {
            int column = dat.FieldCount;

            if (column == 0)
            {
                dat.Close();
                return(new PyObjectData("util.Rowset", new PyDict()));
            }

            PyDict args = new PyDict();

            PyList header = new PyList();

            for (int i = 0; i < column; i++)
            {
                header.Items.Add(new PyString(dat.GetName(i)));
            }

            args.Set("header", header);

            args.Set("RowClass", new PyToken("util.Row"));

            PyList rowlist = new PyList();

            while (dat.Read())
            {
                PyList linedata = new PyList();
                for (int r = 0; r < column; r++)
                {
                    linedata.Items.Add(DBColumnToPyObject(r, ref dat));
                }

                rowlist.Items.Add(linedata);
            }

            dat.Close();

            return(new PyObjectData("util.Rowset", args));
        }
Exemplo n.º 4
0
        public PyObject Encode()
        {
            PyDict res = new PyDict();

            res.Set("live_updated", live_updates);

            PyDict main = new PyDict();

            main.Set("jit", new PyString(jit));
            main.Set("userid", new PyInt(userid));
            main.Set("maxSessionTime", maxSessionTime);
            main.Set("userType", new PyInt(userType));
            main.Set("role", new PyInt(role));
            main.Set("address", new PyString(address));
            main.Set("inDetention", inDetention);

            res.Set("session_init", main);
            res.Set("client_hashes", client_hashes);
            res.Set("user_clientid", new PyInt(user_clientid));

            return(res.As <PyObject>());
        }
Exemplo n.º 5
0
        public PyDict EncodeChanges()
        {
            PyDict res = new PyDict();
            PyDict tmp = new PyDict();

            // Iterate through the session data
            foreach (PyString s in session.Dictionary.Keys)
            {
                PyTuple value = session[s].As <PyTuple>();

                PyObject last    = value.Items[0];
                PyObject current = value.Items[1];

                // Check if they have the same type and value
                if (last != current)
                {
                    // Add the change to the dict
                    PyTuple change = new PyTuple();

                    change.Items.Add(last);
                    change.Items.Add(current);

                    res.Set(s.Value, change);

                    // Update the session with the new last value
                    PyTuple update = new PyTuple();

                    update.Items.Add(current);
                    update.Items.Add(current);

                    // We cant modify the session here, just store it on something temporal
                    tmp[s] = update;
                }
                else
                {
                    // We havent updated anything, but this would be later set as the session
                    // This will prevent the loss of session data
                    tmp[s] = value;
                }
            }

            // Send back the session from temporal to the final storage
            session = tmp;

            return(res);
        }
Exemplo n.º 6
0
        public PyObject Encode()
        {
            PyTuple res = new PyTuple();

            res.Items.Add(new PyString(serverChallenge));

            PyTuple extra = new PyTuple();

            extra.Items.Add(new PyBuffer(func_marshaled_code));
            extra.Items.Add(new PyBool(verification));

            res.Items.Add(extra);

            if (context == null)
            {
                res.Items.Add(new PyDict());
            }
            else
            {
                res.Items.Add(context);
            }

            PyDict info = new PyDict();

            info.Set("macho_version", new PyInt(macho_version));
            info.Set("boot_version", new PyFloat(boot_version));
            info.Set("boot_build", new PyInt(boot_build));
            info.Set("boot_codename", new PyString(boot_codename));
            info.Set("boot_region", new PyString(boot_region));
            info.Set("cluster_usercount", new PyInt(cluster_usercount));
            info.Set("proxy_nodeid", new PyInt(proxy_nodeid));
            info.Set("user_logonqueueposition", new PyInt(user_logonqueueposition));
            info.Set("challenge_responsehash", new PyString(challenge_responsehash));

            res.Items.Add(info);

            return(res.As <PyObject>());
        }
Exemplo n.º 7
0
        public PyObject Encode()
        {
            PyTuple args = new PyTuple();

            args.Items.Add(new PyToken("dbutil.CRowset"));

            PyDict dict = new PyDict();

            dict.Set("header", descriptor.Encode());

            PyObjectEx res = new PyObjectEx();

            res.IsType2 = true;

            args.Items.Add(dict);
            res.List = items.Items;

            return(res);
        }
Exemplo n.º 8
0
        private PyObject HandlePyPacket(PyPacket data)
        {
            // Just forward it if we dont want to look for a specific one
            if (data.dest.type == PyAddress.AddrType.Client)
            {
                // Look for SessionChangeNotifications
                if (data.type == Macho.MachoNetMsg_Type.SESSIONCHANGENOTIFICATION)
                {
                    // Search for address change in session
                    PyTuple payload = data.payload;
                    PyDict  session = payload.Items[0].As <PyTuple>().Items[1].As <PyDict>();

                    if (session.Contains("address") == true)
                    {
                        PyTuple address = session.Get("address").As <PyTuple>();

                        address[0] = new PyString(socket.GetAddress());
                        address[1] = new PyString(socket.GetAddress());
                        session.Set("address", address);
                    }

                    payload.Items[0].As <PyTuple>().Items[1] = session;

                    data.payload = payload;
                }

                // SendClient(data);
            }
            else if (data.dest.type == PyAddress.AddrType.Node)
            {
                // SendServer(data);
            }
            else if (data.dest.type == PyAddress.AddrType.Broadcast)
            {
                // What to do now ?
                Log.Error("Client", "Broadcast packets not supported yet");
                // throw new NotImplementedException("Broadcast packets are not supported yet");
            }

            return(data.Encode());
        }
Exemplo n.º 9
0
        public PyObject Encode()
        {
            PyTuple header    = new PyTuple();
            PyTuple args      = new PyTuple();
            PyToken exception = new PyToken(exception_type);
            PyDict  keywords  = new PyDict();

            args.Items.Add(new PyString(reason));

            keywords.Set("reasonArgs", reasonArgs);
            keywords.Set("clock", new PyLongLong(clock));
            keywords.Set("region", new PyString(region));
            keywords.Set("reason", new PyString(reason));
            keywords.Set("version", new PyFloat(version));
            keywords.Set("build", new PyInt(build));
            keywords.Set("codename", new PyString(codename));
            keywords.Set("machoVersion", new PyInt(machoVersion));

            header.Items.Add(exception);
            header.Items.Add(args);
            header.Items.Add(keywords);

            return(new PyObjectEx(false, header));
        }
Exemplo n.º 10
0
            public override PyObject Run(PyTuple args, object client)
            {
                Log.Debug("machoNet", "Called GetInitVals stub");

                if (Cache.LoadCacheFor("machoNet.serviceInfo") == false)
                {
                    // Cache does not exists, create it
                    PyDict dict = new PyDict();

                    dict.Set("trademgr", new PyString("station"));
                    dict.Set("tutorialSvc", new PyString("station"));
                    dict.Set("bookmark", new PyString("station"));
                    dict.Set("slash", new PyString("station"));
                    dict.Set("wormholeMgr", new PyString("station"));
                    dict.Set("account", new PyString("station"));
                    dict.Set("gangSvc", new PyString("station"));
                    dict.Set("contractMgr", new PyString("station"));

                    dict.Set("LSC", new PyString("location"));
                    dict.Set("station", new PyString("location"));
                    dict.Set("config", new PyString("locationPreferred"));

                    dict.Set("scanMgr", new PyString("solarsystem"));
                    dict.Set("keeper", new PyString("solarsystem"));

                    dict.Set("stationSvc", new PyNone());
                    dict.Set("zsystem", new PyNone());
                    dict.Set("invbroker", new PyNone());
                    dict.Set("droneMgr", new PyNone());
                    dict.Set("userSvc", new PyNone());
                    dict.Set("map", new PyNone());
                    dict.Set("beyonce", new PyNone());
                    dict.Set("standing2", new PyNone());
                    dict.Set("ram", new PyNone());
                    dict.Set("DB", new PyNone());
                    dict.Set("posMgr", new PyNone());
                    dict.Set("voucher", new PyNone());
                    dict.Set("entity", new PyNone());
                    dict.Set("damageTracker", new PyNone());
                    dict.Set("agentMgr", new PyNone());
                    dict.Set("dogmaIM", new PyNone());
                    dict.Set("machoNet", new PyNone());
                    dict.Set("dungeonExplorationMgr", new PyNone());
                    dict.Set("watchdog", new PyNone());
                    dict.Set("ship", new PyNone());
                    dict.Set("DB2", new PyNone());
                    dict.Set("market", new PyNone());
                    dict.Set("dungeon", new PyNone());
                    dict.Set("npcSvc", new PyNone());
                    dict.Set("sessionMgr", new PyNone());
                    dict.Set("allianceRegistry", new PyNone());
                    dict.Set("cache", new PyNone());
                    dict.Set("character", new PyNone());
                    dict.Set("factory", new PyNone());
                    dict.Set("facWarMgr", new PyNone());
                    dict.Set("corpStationMgr", new PyNone());
                    dict.Set("authentication", new PyNone());
                    dict.Set("effectCompiler", new PyNone());
                    dict.Set("charmgr", new PyNone());
                    dict.Set("BSD", new PyNone());
                    dict.Set("reprocessingSvc", new PyNone());
                    dict.Set("billingMgr", new PyNone());
                    dict.Set("billMgr", new PyNone());
                    dict.Set("lookupSvc", new PyNone());
                    dict.Set("emailreader", new PyNone());
                    dict.Set("lootSvc", new PyNone());
                    dict.Set("http", new PyNone());
                    dict.Set("repairSvc", new PyNone());
                    dict.Set("gagger", new PyNone());
                    dict.Set("dataconfig", new PyNone());
                    dict.Set("lien", new PyNone());
                    dict.Set("i2", new PyNone());
                    dict.Set("pathfinder", new PyNone());
                    dict.Set("alert", new PyNone());
                    dict.Set("director", new PyNone());
                    dict.Set("dogma", new PyNone());
                    dict.Set("aggressionMgr", new PyNone());
                    dict.Set("corporationSvc", new PyNone());
                    dict.Set("certificateMgr", new PyNone());
                    dict.Set("clones", new PyNone());
                    dict.Set("jumpCloneSvc", new PyNone());
                    dict.Set("insuranceSvc", new PyNone());
                    dict.Set("corpmgr", new PyNone());
                    dict.Set("warRegistry", new PyNone());
                    dict.Set("corpRegistry", new PyNone());
                    dict.Set("objectCaching", new PyNone());
                    dict.Set("counter", new PyNone());
                    dict.Set("petitioner", new PyNone());
                    dict.Set("LPSvc", new PyNone());
                    dict.Set("clientStatsMgr", new PyNone());
                    dict.Set("jumpbeaconsvc", new PyNone());
                    dict.Set("debug", new PyNone());
                    dict.Set("languageSvc", new PyNone());
                    dict.Set("skillMgr", new PyNone());
                    dict.Set("voiceMgr", new PyNone());
                    dict.Set("onlineStatus", new PyNone());
                    dict.Set("gangSvcObjectHandler", new PyNone());

                    Cache.SaveCacheFor("machoNet.serviceInfo", dict, DateTime.Now.ToFileTime());
                }

                PyObject srvInfo = Cache.GetCacheData("machoNet.serviceInfo");
                PyTuple  res     = new PyTuple();

                res.Items.Add(srvInfo);
                res.Items.Add(new PyNone()); // Rest of the cache data

                return(res);
            }