Beispiel #1
0
        public Client (ClientFlags flags)
        {
            spoll = avahi_simple_poll_new ();

            pollcb = OnPollCallback;
            avahi_simple_poll_set_func (spoll, pollcb);
            IntPtr poll = avahi_simple_poll_get (spoll);
            cb = OnClientCallback;

            int error;
            handle = avahi_client_new (poll, flags, cb, IntPtr.Zero, out error);
            if (error != 0)
                throw new ClientException (error);

            thread = new Thread (PollLoop);
            thread.IsBackground = true;
            thread.Start ();
        }
Beispiel #2
0
 public ExpansionInfo(
     int id,
     string name,
     ClientFlags clientFlags,
     FeatureFlags supportedFeatures,
     CharacterListFlags charListFlags,
     HousingFlags customHousingFlag)
     : this(id, name, supportedFeatures, charListFlags, customHousingFlag)
 {
     ClientFlags = clientFlags;
 }
        /// <summary>
        /// Return the appropriate set of connection flags for our
        /// server capabilities and our user requested options.
        /// </summary>
        private void SetConnectionFlags()
        {
            ClientFlags flags = ClientFlags.FOUND_ROWS;

            if (version.isAtLeast(4, 1, 1))
            {
                flags |= ClientFlags.PROTOCOL_41;
                // Need this to get server status values
                flags |= ClientFlags.TRANSACTIONS;

                // user allows/disallows batch statements
                if (connectionString.AllowBatch)
                    flags |= ClientFlags.MULTI_STATEMENTS;

                // We always allow multiple result sets
                flags |= ClientFlags.MULTI_RESULTS;
            }
            else if (version.isAtLeast(4, 1, 0))
                flags |= ClientFlags.RESERVED;

            // if the server allows it, tell it that we want long column info
            if ((serverCaps & ClientFlags.LONG_FLAG) != 0)
                flags |= ClientFlags.LONG_FLAG;

            // if the server supports it and it was requested, then turn on compression
            if ((serverCaps & ClientFlags.COMPRESS) != 0 && connectionString.UseCompression)
                flags |= ClientFlags.COMPRESS;

            if (protocol > 9)
                flags |= ClientFlags.LONG_PASSWORD; // for long passwords
            else
                flags &= ~ClientFlags.LONG_PASSWORD;

            // allow load data local infile
            flags |= ClientFlags.LOCAL_FILES;

            // if the server allows it and a database was specified, then indicate
            // that we will connect with a database name
            if ((serverCaps & ClientFlags.CONNECT_WITH_DB) != 0 &&
                connectionString.Database != null && connectionString.Database.Length > 0)
                flags |= ClientFlags.CONNECT_WITH_DB;

            // if the server is requesting a secure connection, then we oblige
            if ((serverCaps & ClientFlags.SECURE_CONNECTION) != 0)
                flags |= ClientFlags.SECURE_CONNECTION;

            // if the server is capable of SSL and the user is requesting SSL
            if ((serverCaps & ClientFlags.SSL) != 0 && connectionString.UseSSL)
                flags |= ClientFlags.SSL;

            connectionFlags = flags;
        }
Beispiel #4
0
 private static extern IntPtr avahi_client_new (IntPtr poll, ClientFlags flags, ClientCallback handler,
                                                IntPtr userData, out int error);
        public MoongateGump(Mobile mobile, Item moongate) : base(100, 100)
        {
            m_Mobile   = mobile;
            m_Moongate = moongate;

            PMList[] checkLists;

            if (mobile.Player)
            {
                if (Sigil.ExistsOn(mobile))
                {
                    checkLists = PMList.SigilLists;
                }
                else if (mobile.Kills >= 5)
                {
                    checkLists = PMList.RedLists;
                }
                else
                {
                    ClientFlags flags = mobile.NetState?.Flags ?? ClientFlags.None;
                    bool        young = mobile is PlayerMobile playerMobile && playerMobile.Young;

                    if (Core.SE && (flags & ClientFlags.Tokuno) != 0)
                    {
                        checkLists = young ? PMList.SEListsYoung : PMList.SELists;
                    }
                    else if (Core.AOS && (flags & ClientFlags.Malas) != 0)
                    {
                        checkLists = young ? PMList.AOSListsYoung : PMList.AOSLists;
                    }
                    else if ((flags & ClientFlags.Ilshenar) != 0)
                    {
                        checkLists = young ? PMList.LBRListsYoung : PMList.LBRLists;
                    }
                    else
                    {
                        checkLists = young ? PMList.UORListsYoung : PMList.UORLists;
                    }
                }
            }
            else
            {
                checkLists = PMList.SELists;
            }

            m_Lists = new PMList[checkLists.Length];

            for (int i = 0; i < m_Lists.Length; ++i)
            {
                m_Lists[i] = checkLists[i];
            }

            for (int i = 0; i < m_Lists.Length; ++i)
            {
                if (m_Lists[i].Map == mobile.Map)
                {
                    PMList temp = m_Lists[i];

                    m_Lists[i] = m_Lists[0];
                    m_Lists[0] = temp;

                    break;
                }
            }

            AddPage(0);

            AddBackground(0, 0, 380, 280, 5054);

            AddButton(10, 210, 4005, 4007, 1);
            AddHtmlLocalized(45, 210, 140, 25, 1011036); // OKAY

            AddButton(10, 235, 4005, 4007, 0);
            AddHtmlLocalized(45, 235, 140, 25, 1011012); // CANCEL

            AddHtmlLocalized(5, 5, 200, 20, 1012011);    // Pick your destination:

            for (int i = 0; i < checkLists.Length; ++i)
            {
                AddButton(10, 35 + i * 25, 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf(m_Lists, checkLists[i]) + 1);
                AddHtmlLocalized(30, 35 + i * 25, 150, 20, checkLists[i].Number);
            }

            for (int i = 0; i < m_Lists.Length; ++i)
            {
                RenderPage(i, Array.IndexOf(checkLists, m_Lists[i]));
            }
        }
Beispiel #6
0
        private static CityInfo GetStartLocation(CharacterCreatedEventArgs args, bool isYoung)
        {
            if (Core.ML)
            {
                //if( args.State != null && args.State.NewHaven )
                return(m_NewHavenInfo);  //We don't get the client Version until AFTER Character creation
                //return args.City;  TODO: Uncomment when the old quest system is actually phased out
            }

            bool useHaven = isYoung;

            ClientFlags flags = args.State == null ? ClientFlags.None : args.State.Flags;
            Mobile      m     = args.Mobile;

            /*
             * switch ( args.Profession )
             * {
             *  case 4: //Necro
             *      {
             *          if ((flags & ClientFlags.Malas) != 0)
             *          {
             *              return new CityInfo("Umbra", "Mardoth's Tower", 2114, 1301, -50, Map.Malas);
             *          }
             *          else
             *          {
             *              useHaven = true;
             *
             *              new BadStartMessage(m, 1062205);
             *
             *              // Unfortunately you are playing on a *NON-Age-Of-Shadows* game
             *              // installation and cannot be transported to Malas.
             *              // You will not be able to take your new player quest in Malas
             *              // without an AOS client.  You are now being taken to the city of
             *              // Haven on the Trammel facet.
             *
             *          }
             *
             *          break;
             *      }
             *  case 5:	//Paladin
             *      {
             *          return m_NewHavenInfo;
             *      }
             *  case 6:	//Samurai
             *      {
             *          if ((flags & ClientFlags.Tokuno) != 0)
             *          {
             *              return new CityInfo("Samurai DE", "Haoti's Grounds", 368, 780, -1, Map.Malas);
             *          }
             *          else
             *          {
             *              useHaven = true;
             *
             *              new BadStartMessage(m, 1063487);
             *
             *              // Unfortunately you are playing on a *NON-Samurai-Empire* game
             *              // installation and cannot be transported to Tokuno.
             *              // You will not be able to take your new player quest in Tokuno
             *              // without an SE client. You are now being taken to the city of
             *              // Haven on the Trammel facet.
             *
             *          }
             *
             *          break;
             *      }
             *  case 7:	//Ninja
             *      {
             *          if ((flags & ClientFlags.Tokuno) != 0)
             *          {
             *              return new CityInfo("Ninja DE", "Enimo's Residence", 414,	823, -1, Map.Malas);
             *          }
             *          else
             *          {
             *              useHaven = true;
             *
             *              new BadStartMessage(m, 1063487);
             *
             *              // Unfortunately you are playing on a *NON-Samurai-Empire* game
             *              // installation and cannot be transported to Tokuno.
             *              // You will not be able to take your new player quest in Tokuno
             *              // without an SE client. You are now being taken to the city of
             *              // Haven on the Trammel facet.
             *
             *          }
             *
             *          break;
             *      }
             * }
             */
            if (useHaven && (Core.ML))// (!Core.bEnforceExpansionClient)
            {
                return(m_NewHavenInfo);
            }
            else
            {
                return(args.City);
            }
        }
        public void Open()
        {
            // connect to one of our specified hosts
            try
            {
#if !CF
                if (Settings.ConnectionProtocol == MySqlConnectionProtocol.SharedMemory)
                {
                    var str = new SharedMemoryStream(Settings.SharedMemoryName);
                    str.Open(Settings.ConnectionTimeout);
                    baseStream = str;
                }
                else
                {
#endif
                var pipeName = Settings.PipeName;
                if (Settings.ConnectionProtocol != MySqlConnectionProtocol.NamedPipe)
                {
                    pipeName = null;
                }
                var sc = new StreamCreator(Settings.Server, Settings.Port, pipeName,
                                           Settings.Keepalive, Version);
#if !CF
                MySqlSecurityPermission.CreatePermissionSet(false).Assert();
#endif
                baseStream = sc.GetStream(Settings.ConnectionTimeout);
#if !CF
            }
#endif
            }
            catch (SecurityException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new MySqlException(Resources.UnableToConnectToHost,
                                         (int)MySqlErrorCode.UnableToConnectToHost, ex);
            }
            if (baseStream == null)
            {
                throw new MySqlException(Resources.UnableToConnectToHost,
                                         (int)MySqlErrorCode.UnableToConnectToHost);
            }

            var maxSinglePacket = 255 * 255 * 255;
            stream = new MySqlStream(baseStream, Encoding, false);

            stream.ResetTimeout((int)Settings.ConnectionTimeout * 1000);

            // read off the welcome packet and parse out it's values
            packet = stream.ReadPacket();
            int protocol      = packet.ReadByte();
            var versionString = packet.ReadString();
            version = DBVersion.Parse(versionString);
            if (!version.isAtLeast(5, 0, 0))
            {
                throw new NotSupportedException(Resources.ServerTooOld);
            }
            threadId       = packet.ReadInteger(4);
            encryptionSeed = packet.ReadString();

            maxSinglePacket = (256 * 256 * 256) - 1;

            // read in Server capabilities if they are provided
            ClientFlags serverCaps = 0;
            if (packet.HasMoreData)
            {
                serverCaps = (ClientFlags)packet.ReadInteger(2);
            }

            /* New protocol with 16 bytes to describe server characteristics */
            owner.ConnectionCharSetIndex = (int)packet.ReadByte();

            serverStatus = (ServerStatusFlags)packet.ReadInteger(2);

            // Since 5.5, high bits of server caps are stored after status.
            // Previously, it was part of reserved always 0x00 13-byte filler.
            var serverCapsHigh = (uint)packet.ReadInteger(2);
            serverCaps |= (ClientFlags)(serverCapsHigh << 16);

            packet.Position += 11;
            var seedPart2 = packet.ReadString();
            encryptionSeed += seedPart2;

            var authenticationMethod = "";
            if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
            {
                authenticationMethod = packet.ReadString();
            }
            else
            {
                // Some MySql versions like 5.1, don't give name of plugin, default to native password.
                authenticationMethod = "mysql_native_password";
            }

            // based on our settings, set our connection flags
            SetConnectionFlags(serverCaps);

            packet.Clear();
            packet.WriteInteger((int)connectionFlags, 4);

#if !CF
            if ((serverCaps & ClientFlags.SSL) == 0)
            {
                if ((Settings.SslMode != MySqlSslMode.None) &&
                    (Settings.SslMode != MySqlSslMode.Preferred))
                {
                    // Client requires SSL connections.
                    var message = String.Format(Resources.NoServerSSLSupport,
                                                Settings.Server);
                    throw new MySqlException(message);
                }
            }
            else if (Settings.SslMode != MySqlSslMode.None)
            {
                stream.SendPacket(packet);
                StartSSL();
                packet.Clear();
                packet.WriteInteger((int)connectionFlags, 4);
            }
#endif

            packet.WriteInteger(maxSinglePacket, 4);
            packet.WriteByte(8);
            packet.Write(new byte[23]);

            Authenticate(authenticationMethod, false);

            // if we are using compression, then we use our CompressedStream class
            // to hide the ugliness of managing the compression
            if ((connectionFlags & ClientFlags.COMPRESS) != 0)
            {
                stream = new MySqlStream(baseStream, Encoding, true);
            }

            // give our stream the server version we are connected to.
            // We may have some fields that are read differently based
            // on the version of the server we are connected to.
            packet.Version      = version;
            stream.MaxBlockSize = maxSinglePacket;
        }
    /// <summary>
    /// Return the appropriate set of connection flags for our
    /// server capabilities and our user requested options.
    /// </summary>
    private void SetConnectionFlags(ClientFlags serverCaps)
    {
      // allow load data local infile
      ClientFlags flags = ClientFlags.LOCAL_FILES;

      if (!Settings.UseAffectedRows)
        flags |= ClientFlags.FOUND_ROWS;

      flags |= ClientFlags.PROTOCOL_41;
      // Need this to get server status values
      flags |= ClientFlags.TRANSACTIONS;

      // user allows/disallows batch statements
      if (Settings.AllowBatch)
        flags |= ClientFlags.MULTI_STATEMENTS;

      // We always allow multiple result sets
      flags |= ClientFlags.MULTI_RESULTS;

      // if the server allows it, tell it that we want long column info
      if ((serverCaps & ClientFlags.LONG_FLAG) != 0)
        flags |= ClientFlags.LONG_FLAG;

      // if the server supports it and it was requested, then turn on compression
      if ((serverCaps & ClientFlags.COMPRESS) != 0 && Settings.UseCompression)
        flags |= ClientFlags.COMPRESS;

      flags |= ClientFlags.LONG_PASSWORD; // for long passwords

      // did the user request an interactive session?
      if (Settings.InteractiveSession)
        flags |= ClientFlags.INTERACTIVE;

      // if the server allows it and a database was specified, then indicate
      // that we will connect with a database name
      if ((serverCaps & ClientFlags.CONNECT_WITH_DB) != 0 &&
          Settings.Database != null && Settings.Database.Length > 0)
        flags |= ClientFlags.CONNECT_WITH_DB;

      // if the server is requesting a secure connection, then we oblige
      if ((serverCaps & ClientFlags.SECURE_CONNECTION) != 0)
        flags |= ClientFlags.SECURE_CONNECTION;

#if !CF
      // if the server is capable of SSL and the user is requesting SSL
      if ((serverCaps & ClientFlags.SSL) != 0 && Settings.SslMode != MySqlSslMode.None)
        flags |= ClientFlags.SSL;
#endif

      // if the server supports output parameters, then we do too
      if ((serverCaps & ClientFlags.PS_MULTI_RESULTS) != 0)
        flags |= ClientFlags.PS_MULTI_RESULTS;

      if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
        flags |= ClientFlags.PLUGIN_AUTH;

      connectionFlags = flags;
    }
            public PlayerTravelBookGump(Mobile mobile, Item PlayerTravelBook) : base(100, 100)
            {
                m_Mobile           = mobile;
                m_PlayerTravelBook = PlayerTravelBook;

                PMList[] checkLists;

                if (mobile.Player)
                {
                    if (mobile.Kills >= 5)
                    {
                        checkLists = PMList.RedLists;
                    }
                    else
                    {
                        ClientFlags flags = mobile.NetState == null ? ClientFlags.None : mobile.NetState.Flags;
                        // bool young = mobile is PlayerMobile ? ((PlayerMobile)mobile).Young : false;

                        if (Core.AOS && (flags & ClientFlags.Malas) != 0)
                        {
                            checkLists = PMList.AOSLists;
                        }
                        else if (Core.SE && (flags & ClientFlags.Tokuno) != 0)
                        {
                            checkLists = PMList.LBRLists;
                        }
                        else
                        {
                            checkLists = PMList.UORLists;
                        }
                    }
                }
                else
                {
                    checkLists = PMList.AOSLists;
                }

                m_Lists = new PMList[checkLists.Length];

                for (int i = 0; i < m_Lists.Length; ++i)
                {
                    m_Lists[i] = checkLists[i];
                }

                for (int i = 0; i < m_Lists.Length; ++i)
                {
                    if (m_Lists[i].Map == mobile.Map)
                    {
                        PMList temp = m_Lists[i];

                        m_Lists[i] = m_Lists[0];
                        m_Lists[0] = temp;

                        break;
                    }
                }

                AddPage(0);

                AddBackground(0, 0, 450, 590, 5054);

                AddButton(10, 475, 4005, 4007, 1, GumpButtonType.Reply, 0);
                AddHtmlLocalized(45, 475, 140, 25, 1011036, false, false); // OKAY

                AddButton(10, 500, 4005, 4007, 0, GumpButtonType.Reply, 0);
                AddHtmlLocalized(45, 500, 140, 25, 1011012, false, false); // CANCEL

                AddHtmlLocalized(5, 5, 200, 20, 1012011, false, false);    // Pick your destination:

                for (int i = 0; i < checkLists.Length; ++i)
                {
                    AddButton(10, 35 + (i * 25), 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf(m_Lists, checkLists[i]) + 1);
                    AddHtml(30, 35 + (i * 25), 150, 20, checkLists[i].Text, false, false);
                }

                for (int i = 0; i < m_Lists.Length; ++i)
                {
                    RenderPage(i, Array.IndexOf(checkLists, m_Lists[i]));
                }
            }
Beispiel #10
0
        public void Open()
        {
            // connect to one of our specified hosts
            try
            {
                var streamTask = StreamCreator.GetStream(Settings);
                streamTask.Wait();
                baseStream = streamTask.Result;

#if !CF && !RT && !NETSTANDARD1_3
                if (Settings.IncludeSecurityAsserts)
                {
                    MySqlSecurityPermission.CreatePermissionSet(false).Assert();
                }
#endif
            }
            catch (System.Security.SecurityException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new MySqlException(Resources.UnableToConnectToHost,
                                         (int)MySqlErrorCode.UnableToConnectToHost, ex);
            }
            if (baseStream == null)
            {
                throw new MySqlException(Resources.UnableToConnectToHost,
                                         (int)MySqlErrorCode.UnableToConnectToHost);
            }

            int maxSinglePacket = 255 * 255 * 255;
            stream = new MySqlStream(baseStream, Encoding, false);

            stream.ResetTimeout((int)Settings.ConnectionTimeout * 1000);

            // read off the welcome packet and parse out it's values
            packet = stream.ReadPacket();
            int    protocol      = packet.ReadByte();
            string versionString = packet.ReadString();
            owner.isFabric = versionString.EndsWith("fabric", StringComparison.OrdinalIgnoreCase);
            version        = DBVersion.Parse(versionString);
            if (!owner.isFabric && !version.isAtLeast(5, 0, 0))
            {
                throw new NotSupportedException(Resources.ServerTooOld);
            }
            threadId = packet.ReadInteger(4);

            byte[] seedPart1 = packet.ReadStringAsBytes();

            maxSinglePacket = (256 * 256 * 256) - 1;

            // read in Server capabilities if they are provided
            ClientFlags serverCaps = 0;
            if (packet.HasMoreData)
            {
                serverCaps = (ClientFlags)packet.ReadInteger(2);
            }

            /* New protocol with 16 bytes to describe server characteristics */
            owner.ConnectionCharSetIndex = (int)packet.ReadByte();

            serverStatus = (ServerStatusFlags)packet.ReadInteger(2);

            // Since 5.5, high bits of server caps are stored after status.
            // Previously, it was part of reserved always 0x00 13-byte filler.
            uint serverCapsHigh = (uint)packet.ReadInteger(2);
            serverCaps |= (ClientFlags)(serverCapsHigh << 16);

            packet.Position += 11;
            byte[] seedPart2 = packet.ReadStringAsBytes();
            encryptionSeed = new byte[seedPart1.Length + seedPart2.Length];
            seedPart1.CopyTo(encryptionSeed, 0);
            seedPart2.CopyTo(encryptionSeed, seedPart1.Length);

            string authenticationMethod = "";
            if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
            {
                authenticationMethod = packet.ReadString();
            }
            else
            {
                // Some MySql versions like 5.1, don't give name of plugin, default to native password.
                authenticationMethod = "mysql_native_password";
            }

            // based on our settings, set our connection flags
            SetConnectionFlags(serverCaps);

            packet.Clear();
            packet.WriteInteger((int)connectionFlags, 4);
            packet.WriteInteger(maxSinglePacket, 4);
            packet.WriteByte(33); //character set utf-8
            packet.Write(new byte[23]);

#if !CF && !RT
            if ((serverCaps & ClientFlags.SSL) == 0)
            {
                if ((Settings.SslMode != MySqlSslMode.None) &&
                    (Settings.SslMode != MySqlSslMode.Preferred))
                {
                    // Client requires SSL connections.
                    string message = String.Format(Resources.NoServerSSLSupport,
                                                   Settings.Server);
                    throw new MySqlException(message);
                }
            }
            else if (Settings.SslMode != MySqlSslMode.None)
            {
                stream.SendPacket(packet);
                StartSSL();
                packet.Clear();
                packet.WriteInteger((int)connectionFlags, 4);
                packet.WriteInteger(maxSinglePacket, 4);
                packet.WriteByte(33); //character set utf-8
                packet.Write(new byte[23]);
            }
#endif

#if RT
            if (Settings.SslMode != MySqlSslMode.None)
            {
                throw new NotImplementedException("SSL not supported in this WinRT release.");
            }
#endif

            Authenticate(authenticationMethod, false);

            // if we are using compression, then we use our CompressedStream class
            // to hide the ugliness of managing the compression
            if ((connectionFlags & ClientFlags.COMPRESS) != 0)
            {
                stream = new MySqlStream(baseStream, Encoding, true);
            }

            // give our stream the server version we are connected to.
            // We may have some fields that are read differently based
            // on the version of the server we are connected to.
            packet.Version      = version;
            stream.MaxBlockSize = maxSinglePacket;
        }
        /// <summary>
        /// Return the appropriate set of connection flags for our
        /// server capabilities and our user requested options.
        /// </summary>
        private void SetConnectionFlags()
        {
            // allow load data local infile
            ClientFlags flags = ClientFlags.LOCAL_FILES;

            if (!Settings.UseAffectedRows)
            {
                flags |= ClientFlags.FOUND_ROWS;
            }

            if (version.isAtLeast(4, 1, 1))
            {
                flags |= ClientFlags.PROTOCOL_41;
                // Need this to get server status values
                flags |= ClientFlags.TRANSACTIONS;

                // user allows/disallows batch statements
                if (connectionString.AllowBatch)
                {
                    flags |= ClientFlags.MULTI_STATEMENTS;
                }

                // We always allow multiple result sets
                flags |= ClientFlags.MULTI_RESULTS;
            }
            else if (version.isAtLeast(4, 1, 0))
            {
                flags |= ClientFlags.RESERVED;
            }

            // if the server allows it, tell it that we want long column info
            if ((serverCaps & ClientFlags.LONG_FLAG) != 0)
            {
                flags |= ClientFlags.LONG_FLAG;
            }

            // if the server supports it and it was requested, then turn on compression
            if ((serverCaps & ClientFlags.COMPRESS) != 0 && connectionString.UseCompression)
            {
                flags |= ClientFlags.COMPRESS;
            }

            if (protocol > 9)
            {
                flags |= ClientFlags.LONG_PASSWORD; // for long passwords
            }
            else
            {
                flags &= ~ClientFlags.LONG_PASSWORD;
            }

            // did the user request an interactive session?
            if (Settings.InteractiveSession)
            {
                flags |= ClientFlags.INTERACTIVE;
            }

            // if the server allows it and a database was specified, then indicate
            // that we will connect with a database name
            if ((serverCaps & ClientFlags.CONNECT_WITH_DB) != 0 &&
                connectionString.Database != null && connectionString.Database.Length > 0)
            {
                flags |= ClientFlags.CONNECT_WITH_DB;
            }

            // if the server is requesting a secure connection, then we oblige
            if ((serverCaps & ClientFlags.SECURE_CONNECTION) != 0)
            {
                flags |= ClientFlags.SECURE_CONNECTION;
            }

            // if the server is capable of SSL and the user is requesting SSL
            if ((serverCaps & ClientFlags.SSL) != 0 && connectionString.UseSSL)
            {
                flags |= ClientFlags.SSL;
            }

            connectionFlags = flags;
        }
Beispiel #12
0
        public MoongateGump(Mobile mobile, Item moongate)
            : base(100, 100)
        {
            this.m_Mobile   = mobile;
            this.m_Moongate = moongate;

            PMList[] checkLists;

            if (mobile.Player)
            {
                if (Factions.Sigil.ExistsOn(mobile))
                {
                    checkLists = PMList.SigilLists;
                }
                else if (mobile.Kills >= 5)
                {
                    checkLists = PMList.RedLists;
                }
                else
                {
                    ClientFlags flags = mobile.NetState == null ? ClientFlags.None : mobile.NetState.Flags;
                    bool        young = mobile is PlayerMobile ? ((PlayerMobile)mobile).Young : false;

                    if (Core.SA && (flags & ClientFlags.TerMur) != 0)
                    {
                        checkLists = young ? PMList.SAListsYoung : PMList.SALists;
                    }
                    else if (Core.SE && (flags & ClientFlags.Tokuno) != 0)
                    {
                        checkLists = young ? PMList.SEListsYoung : PMList.SELists;
                    }
                    else if (Core.AOS && (flags & ClientFlags.Malas) != 0)
                    {
                        checkLists = young ? PMList.AOSListsYoung : PMList.AOSLists;
                    }
                    else if ((flags & ClientFlags.Ilshenar) != 0)
                    {
                        checkLists = young ? PMList.LBRListsYoung : PMList.LBRLists;
                    }
                    else
                    {
                        checkLists = young ? PMList.UORListsYoung : PMList.UORLists;
                    }
                }
            }
            else
            {
                checkLists = PMList.SELists;
            }

            this.m_Lists = new PMList[checkLists.Length];

            for (int i = 0; i < this.m_Lists.Length; ++i)
            {
                this.m_Lists[i] = checkLists[i];
            }

            for (int i = 0; i < this.m_Lists.Length; ++i)
            {
                if (this.m_Lists[i].Map == mobile.Map)
                {
                    PMList temp = this.m_Lists[i];

                    this.m_Lists[i] = this.m_Lists[0];
                    this.m_Lists[0] = temp;

                    break;
                }
            }

            this.AddPage(0);

            this.AddBackground(0, 0, 380, 280, 5054);

            this.AddButton(10, 210, 4005, 4007, 1, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(45, 210, 140, 25, 1011036, false, false); // OKAY

            this.AddButton(10, 235, 4005, 4007, 0, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(45, 235, 140, 25, 1011012, false, false); // CANCEL

            this.AddHtmlLocalized(5, 5, 200, 20, 1012011, false, false);    // Pick your destination:

            for (int i = 0; i < checkLists.Length; ++i)
            {
                this.AddButton(10, 35 + (i * 25), 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf(this.m_Lists, checkLists[i]) + 1);
                this.AddHtmlLocalized(30, 35 + (i * 25), 150, 20, checkLists[i].Number, false, false);
            }

            for (int i = 0; i < this.m_Lists.Length; ++i)
            {
                this.RenderPage(i, Array.IndexOf(checkLists, this.m_Lists[i]));
            }
        }
Beispiel #13
0
        internal static ClientInfo[] Parse(string input)
        {
            if (input == null)
            {
                return(null);
            }

            var clients = new List <ClientInfo>();

            using (var reader = new StringReader(input))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    var      client = new ClientInfo();
                    string[] tokens = line.Split(' ');
                    for (int i = 0; i < tokens.Length; i++)
                    {
                        string tok = tokens[i];
                        int    idx = tok.IndexOf('=');
                        if (idx < 0)
                        {
                            continue;
                        }
                        string key = tok.Substring(0, idx), value = tok.Substring(idx + 1);

                        switch (key)
                        {
                        case "addr": client.Address = value; break;

                        case "age": client.AgeSeconds = int.Parse(value, CultureInfo.InvariantCulture); break;

                        case "idle": client.IdleSeconds = int.Parse(value, CultureInfo.InvariantCulture); break;

                        case "db": client.Database = int.Parse(value, CultureInfo.InvariantCulture); break;

                        case "name": client.Name = value; break;

                        case "sub": client.SubscriptionCount = int.Parse(value, CultureInfo.InvariantCulture); break;

                        case "psub": client.PatternSubscriptionCount = int.Parse(value, CultureInfo.InvariantCulture); break;

                        case "multi": client.TransactionCommandLength = int.Parse(value, CultureInfo.InvariantCulture); break;

                        case "cmd": client.LastCommand = value; break;

                        case "flags":
                            client.FlagsRaw = value;
                            ClientFlags flags = ClientFlags.None;
                            AddFlag(ref flags, value, ClientFlags.SlaveMonitor, 'O');
                            AddFlag(ref flags, value, ClientFlags.Slave, 'S');
                            AddFlag(ref flags, value, ClientFlags.Master, 'M');
                            AddFlag(ref flags, value, ClientFlags.Transaction, 'x');
                            AddFlag(ref flags, value, ClientFlags.Blocked, 'b');
                            AddFlag(ref flags, value, ClientFlags.TransactionDoomed, 'd');
                            AddFlag(ref flags, value, ClientFlags.Closing, 'c');
                            AddFlag(ref flags, value, ClientFlags.Unblocked, 'u');
                            AddFlag(ref flags, value, ClientFlags.CloseASAP, 'A');
                            client.Flags = flags;
                            break;
                        }
                    }
                    clients.Add(client);
                }
            }

            return(clients.ToArray());
        }
 private static void AddFlag(ref ClientFlags value, string raw, ClientFlags toAdd, char token)
 {
     if (raw.IndexOf(token) >= 0) value |= toAdd;
 }
Beispiel #15
0
        /// <summary>
        /// Return the appropriate set of connection flags for our
        /// server capabilities and our user requested options.
        /// </summary>
        private void SetConnectionFlags(ClientFlags serverCaps)
        {
            // allow load data local infile
            var flags = ClientFlags.LOCAL_FILES;

            if (!Settings.UseAffectedRows)
            {
                flags |= ClientFlags.FOUND_ROWS;
            }

            flags |= ClientFlags.PROTOCOL_41;
            // Need this to get server status values
            flags |= ClientFlags.TRANSACTIONS;

            // user allows/disallows batch statements
            if (Settings.AllowBatch)
            {
                flags |= ClientFlags.MULTI_STATEMENTS;
            }

            // We always allow multiple result sets
            flags |= ClientFlags.MULTI_RESULTS;

            // if the server allows it, tell it that we want long column info
            if ((serverCaps & ClientFlags.LONG_FLAG) != 0)
            {
                flags |= ClientFlags.LONG_FLAG;
            }

            // if the server supports it and it was requested, then turn on compression
            if ((serverCaps & ClientFlags.COMPRESS) != 0 && Settings.UseCompression)
            {
                flags |= ClientFlags.COMPRESS;
            }

            flags |= ClientFlags.LONG_PASSWORD; // for long passwords

            // did the user request an interactive session?
            if (Settings.InteractiveSession)
            {
                flags |= ClientFlags.INTERACTIVE;
            }

            // if the server allows it and a database was specified, then indicate
            // that we will connect with a database name
            if ((serverCaps & ClientFlags.CONNECT_WITH_DB) != 0 &&
                Settings.Database != null && Settings.Database.Length > 0)
            {
                flags |= ClientFlags.CONNECT_WITH_DB;
            }

            // if the server is requesting a secure connection, then we oblige
            if ((serverCaps & ClientFlags.SECURE_CONNECTION) != 0)
            {
                flags |= ClientFlags.SECURE_CONNECTION;
            }

#if !CF
            // if the server is capable of SSL and the user is requesting SSL
            if ((serverCaps & ClientFlags.SSL) != 0 && Settings.SslMode != MySqlSslMode.None)
            {
                flags |= ClientFlags.SSL;
            }
#endif

            // if the server supports output parameters, then we do too
            if ((serverCaps & ClientFlags.PS_MULTI_RESULTS) != 0)
            {
                flags |= ClientFlags.PS_MULTI_RESULTS;
            }

            if (Settings.IntegratedSecurity)
            {
                if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
                {
                    flags |= ClientFlags.PLUGIN_AUTH;
                }
            }
            connectionFlags = flags;
        }
Beispiel #16
0
 private void SetConnectionFlags()
 {
     ClientFlags flags = ClientFlags.FOUND_ROWS;
     if (this.version.isAtLeast(4, 1, 1))
     {
         flags |= ClientFlags.PROTOCOL_41;
         flags |= ClientFlags.TRANSACTIONS;
         if (base.connectionString.AllowBatch)
         {
             flags |= ClientFlags.MULTI_STATEMENTS;
         }
         flags |= ClientFlags.MULTI_RESULTS;
     }
     else if (this.version.isAtLeast(4, 1, 0))
     {
         flags |= ClientFlags.RESERVED;
     }
     if ((base.serverCaps & ClientFlags.LONG_FLAG) != 0)
     {
         flags |= ClientFlags.LONG_FLAG;
     }
     if (((base.serverCaps & ClientFlags.COMPRESS) != 0) && base.connectionString.UseCompression)
     {
         flags |= ClientFlags.COMPRESS;
     }
     if (this.protocol > 9)
     {
         flags |= ClientFlags.LONG_PASSWORD;
     }
     else
     {
         flags &= ~ClientFlags.LONG_PASSWORD;
     }
     flags |= ClientFlags.LOCAL_FILES;
     if (base.Settings.InteractiveSession)
     {
         flags |= ClientFlags.INTERACTIVE;
     }
     if ((((base.serverCaps & ClientFlags.CONNECT_WITH_DB) != 0) && (base.connectionString.Database != null)) && (base.connectionString.Database.Length > 0))
     {
         flags |= ClientFlags.CONNECT_WITH_DB;
     }
     if ((base.serverCaps & ClientFlags.SECURE_CONNECTION) != 0)
     {
         flags |= ClientFlags.SECURE_CONNECTION;
     }
     if (((base.serverCaps & ClientFlags.SSL) != 0) && base.connectionString.UseSSL)
     {
         flags |= ClientFlags.SSL;
     }
     this.connectionFlags = flags;
 }
Beispiel #17
0
        public virtual void UseGate(Mobile m)
        {
            ClientFlags flags = m.NetState == null ? ClientFlags.None : m.NetState.Flags;

            bool hasstonewall  = false;
            bool hasgate       = false;
            Item paralyzeField = null;

            IPooledEnumerable eable;

            if (m_TargetMap != null)
            {
                eable = m_TargetMap.GetItemsInRange(m_Target, 0);

                foreach (Item i in eable)
                {
                    if (i.ItemID == 0x80) //Stonewall
                    {
                        hasstonewall = true;
                    }
                    if (i.ItemID == 0xF6C) //Gate
                    {
                        hasgate = true;
                    }
                    if (i.ItemID >= 14695 && i.ItemID <= 14730) //Paralyze field
                    {
                        paralyzeField = i;
                    }
                }

                eable.Free();
            }

            if (Sigil.ExistsOn(m))
            {
                m.SendLocalizedMessage(1061632);                   // You can't do that while carrying the sigil.
            }
            //else if ( m_TargetMap == Map.Felucca && m is PlayerMobile && ((PlayerMobile)m).Young )
            //{
            //    m.SendLocalizedMessage( 1049543 ); // You decide against traveling to Felucca while you are still young.
            //}
            //else if ( (m.Kills >= 5 && m_TargetMap != Map.Felucca) || ( m_TargetMap == Map.Tokuno && (flags & ClientFlags.Tokuno) == 0 ) || ( m_TargetMap == Map.Malas && (flags & ClientFlags.Malas) == 0 ) || ( m_TargetMap == Map.Ilshenar && (flags & ClientFlags.Ilshenar) == 0 ) )
            //{
            //    m.SendLocalizedMessage( 1019004 ); // You are not allowed to travel there.
            //}
            //else if ( m.Spell != null )
            //{
            //    m.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
            //}
            else if (m_TargetMap != null && m_TargetMap != Map.Internal)
            {
                if ((hasgate || !Dispellable) && !hasstonewall)
                {
                    BaseCreature.TeleportPets(m, m_Target, m_TargetMap);

                    m.MoveToWorld(m_Target, m_TargetMap);

                    if (m.AccessLevel == AccessLevel.Player || !m.Hidden)
                    {
                        //Iza - Teleport Poof
                        Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                        Effects.SendLocationParticles(EffectItem.Create(m_Target, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
                        m.PlaySound(0x1FE);
                    }

                    if (paralyzeField != null)
                    {
                        paralyzeField.OnMoveOver(m); //Paralyze player if paralyze field exist
                    }
                    OnGateUsed(m);
                }
                else
                {
                    m.SendAsciiMessage("You cannot teleport to that location.");
                }
            }
            else
            {
                m.SendMessage("This moongate does not seem to go anywhere.");
            }
        }
Beispiel #18
0
		public ExpansionInfo( int id, string name, ClientFlags clientFlags, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, int customHousingFlag )
		{
			m_Name = name;
			m_ID = id;
			m_ClientFlags = clientFlags;
			m_SupportedFeatures = supportedFeatures;
			m_CharListFlags = charListFlags;
			m_CustomHousingFlag = customHousingFlag;
		}
Beispiel #19
0
        public void Open()
        {
            try
            {
                this.baseStream = StreamCreator.GetStream(this.Settings);
                if (this.Settings.IncludeSecurityAsserts)
                {
                    MySqlSecurityPermission.CreatePermissionSet(false).Assert();
                }
            }
            catch (SecurityException)
            {
                throw;
            }
            catch (Exception inner)
            {
                throw new MySqlException(Resources.UnableToConnectToHost, 1042, inner);
            }
            if (this.baseStream == null)
            {
                throw new MySqlException(Resources.UnableToConnectToHost, 1042);
            }
            this.stream = new MySqlStream(this.baseStream, this.Encoding, false);
            this.stream.ResetTimeout((int)(this.Settings.ConnectionTimeout * 1000u));
            this.packet = this.stream.ReadPacket();
            this.packet.ReadByte();
            string versionString = this.packet.ReadString();

            this.version = DBVersion.Parse(versionString);
            if (!this.version.isAtLeast(5, 0, 0))
            {
                throw new NotSupportedException(Resources.ServerTooOld);
            }
            this.threadId       = this.packet.ReadInteger(4);
            this.encryptionSeed = this.packet.ReadString();
            int         num         = 16777215;
            ClientFlags clientFlags = (ClientFlags)0uL;

            if (this.packet.HasMoreData)
            {
                clientFlags = (ClientFlags)((long)this.packet.ReadInteger(2));
            }
            this.owner.ConnectionCharSetIndex = (int)this.packet.ReadByte();
            this.serverStatus = (ServerStatusFlags)this.packet.ReadInteger(2);
            uint num2 = (uint)this.packet.ReadInteger(2);

            clientFlags          |= (ClientFlags)(num2 << 16);
            this.packet.Position += 11;
            string str = this.packet.ReadString();

            this.encryptionSeed += str;
            string authMethod;

            if ((clientFlags & ClientFlags.PLUGIN_AUTH) != (ClientFlags)0uL)
            {
                authMethod = this.packet.ReadString();
            }
            else
            {
                authMethod = "mysql_native_password";
            }
            this.SetConnectionFlags(clientFlags);
            this.packet.Clear();
            this.packet.WriteInteger((long)((int)this.connectionFlags), 4);
            if ((clientFlags & ClientFlags.SSL) == (ClientFlags)0uL)
            {
                if (this.Settings.SslMode != MySqlSslMode.None && this.Settings.SslMode != MySqlSslMode.Preferred)
                {
                    string msg = string.Format(Resources.NoServerSSLSupport, this.Settings.Server);
                    throw new MySqlException(msg);
                }
            }
            else if (this.Settings.SslMode != MySqlSslMode.None)
            {
                this.stream.SendPacket(this.packet);
                this.StartSSL();
                this.packet.Clear();
                this.packet.WriteInteger((long)((int)this.connectionFlags), 4);
            }
            this.packet.WriteInteger((long)num, 4);
            this.packet.WriteByte(8);
            this.packet.Write(new byte[23]);
            this.Authenticate(authMethod, false);
            if ((this.connectionFlags & ClientFlags.COMPRESS) != (ClientFlags)0uL)
            {
                this.stream = new MySqlStream(this.baseStream, this.Encoding, true);
            }
            this.packet.Version      = this.version;
            this.stream.MaxBlockSize = num;
        }