public void WriteString(core.LinkLeaf.LinkClient client, String text, bool null_terminated)
        {
            byte[] data = Encoding.UTF8.GetBytes(text);
            data = Crypto.Encrypt(data, client.Key, client.IV);
            this.WriteUInt16((ushort)data.Length);
            this.WriteBytes(data);

            if (null_terminated)
            {
                this.Data.Add(0);
            }
        }
Exemple #2
0
        public String ReadString(core.LinkLeaf.LinkClient client)
        {
            String str  = String.Empty;
            ushort size = this;

            byte[] data = this.ReadBytes(size);
            data = Crypto.Decrypt(data, client.Key, client.IV);
            str  = Encoding.UTF8.GetString(data);

            if (this.Position < this.Data.Count)
            {
                if (this.Data[this.Position] == 0)
                {
                    this.Position++;
                }
            }

            foreach (String c in bad_chars)
            {
                str = Regex.Replace(str, Regex.Escape(c), "", RegexOptions.IgnoreCase);
            }

            return(str.Trim());
        }
Exemple #3
0
        private void ServerThread()
        {
            this.terminate = false;

            FilterImporter.DoTasks();
            ObSalt.Init();
            CaptchaManager.Load();
            FloodControl.Reset();
            Stats.Reset();
            UserPool.Build();
            core.LinkHub.LeafPool.Build();
            Captcha.Initialize();
            UserHistory.Initialize();
            AccountManager.LoadPasswords();
            BanSystem.LoadBans();
            IdleManager.Reset();
            Proxies.Start(Helpers.UnixTime);
            IgnoreManager.init();

            if (Settings.Get <bool>("roomsearch"))
            {
                UdpChannelList.Start();
            }

            ulong last_update_check  = 0;
            ulong fast_ping_timer    = Time.Now;
            ulong channel_push_timer = (Time.Now - 1200000);
            ulong reset_floods_timer = Time.Now;
            ulong room_search_timer  = (Time.Now - 1800000);
            bool  can_web_chat       = Settings.Get <bool>("enabled", "web");

            core.LinkHub.LinkMode link_mode = (core.LinkHub.LinkMode)Settings.Get <int>("link_mode");
            Linker = new LinkLeaf.LinkClient();

            if (link_mode == LinkHub.LinkMode.Hub)
            {
                Linker.ConnectLocal();
            }

            Events.ServerStarted();

            while (true)
            {
                if (this.terminate)
                {
                    break;
                }

                ulong time = Time.Now;

                if (time > (last_update_check + (30 * 60 * 1000)))
                {
                    last_update_check = time;
                    CheckLatestVersion();
                }

                if (time > (fast_ping_timer + 2000))
                {
                    fast_ping_timer = time;

                    UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.FastPing()),
                                                 x => x.LoggedIn && x.FastPing);

                    BanSystem.AutoClearBans();
                    Avatars.CheckAvatars(time);
                }

                if (time > (reset_floods_timer + 60000))
                {
                    reset_floods_timer = time;
                    FloodControl.Reset();
                    Proxies.Updater(Helpers.UnixTime);
                }

                this.udp.ServiceUdp(time);
                this.CheckTCPListener(time);
                this.ServiceAresSockets(time);
                this.ServiceLeaves(link_mode, time);
                this.ServiceWW();
                Linker.Service(time);

                if (can_web_chat)
                {
                    this.ServiceWebSockets(time);

                    if (time > (channel_push_timer + 1200000))
                    {
                        channel_push_timer = time;
                        ib0t.ChannelPusher.Push();
                    }
                }

                if (time > (room_search_timer + 1800000))
                {
                    room_search_timer = time;

                    if (Settings.Get <bool>("roomsearch"))
                    {
                        UdpChannelList.Update();
                    }
                }

                Events.CycleTick();
                Thread.Sleep(25);
            }
        }
 public void WriteString(core.LinkLeaf.LinkClient client, String text)
 {
     this.WriteString(client, text, true);
 }