コード例 #1
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] Topic(AresClient client, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, text, false);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_TOPIC));
        }
コード例 #2
0
 private static void AddClientTag(AresClient client, TCPPacketReader packet)
 {
     while (packet.Remaining > 0)
     {
         client.CustomClientTags.Add(packet.ReadString(client));
     }
 }
コード例 #3
0
ファイル: TCPProcessor.cs プロジェクト: miromancekimika/hola
 private static void Dummy(AresClient client)
 {
     if (Events.ProxyDetected(client))
     {
         client.Disconnect();
     }
 }
コード例 #4
0
 public WebWorker(AresClient client)
 {
     this.Sock       = client.Sock;
     this.SocketAddr = ((IPEndPoint)this.Sock.RemoteEndPoint).Address;
     this.data_in.AddRange(client.ReceiveDump);
     this.UserName = String.Empty;
 }
コード例 #5
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] Part(AresClient client, IClient target)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, target.Name);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_PART));
        }
コード例 #6
0
ファイル: TCPProcessor.cs プロジェクト: miromancekimika/hola
        private static void CustomDataAll(AresClient client, TCPPacketReader packet)
        {
            if (client.Quarantined || !client.Captcha)
            {
                return;
            }

            String ident = packet.ReadString(client);

            byte[] data = packet;

            if (ident.Contains("scribble"))
            {
                return;
            }

            if (ident.Contains("cb0t_writing") && client.Muzzled)
            {
                return;
            }

            UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.CustomData(x, client.Name, ident, data)),
                                         x => x.LoggedIn && x.Vroom == client.Vroom && x.CustomClient && !x.Quarantined && x.ID != client.ID && !x.IgnoreList.Contains(client.Name));

            if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
            {
                ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafCustomDataAll(ServerCore.Linker, client.Vroom, client.Name, ident, data));
            }
        }
コード例 #7
0
        private static void VCFirstTo(AresClient client, TCPPacketReader packet)
        {
            if (Settings.Get <bool>("voice"))
            {
                String     name   = packet.ReadString(client);
                AresClient target = UserPool.AUsers.Find(x => x.Name == name);
                byte[]     data   = packet;

                if (target != null)
                {
                    if (!target.VoiceChatIgnoreList.Contains(client.Name) && !target.IgnoreList.Contains(client.Name))
                    {
                        if (target.VoiceChatPrivate)
                        {
                            target.SendPacket(TCPOutbound.VoiceChatFirstTo(target, client.Name, data));
                        }
                        else
                        {
                            client.SendPacket(TCPOutbound.VoiceChatNoPrivate(client, name));
                        }
                    }
                    else
                    {
                        client.SendPacket(TCPOutbound.VoiceChatIgnored(client, name));
                    }
                }
                else
                {
                    client.SendPacket(TCPOutbound.OfflineUser(client, name));
                }
            }
        }
コード例 #8
0
        private static void ScribbleRoomChunk(AresClient client, TCPPacketReader packet)
        {
            if (!Settings.Get <bool>("can_room_scribble"))
            {
                return;
            }

            if (client.ScribbleRoomObject.IsReceiving)
            {
                client.ScribbleRoomObject.ChunkCount++;
                client.ScribbleRoomObject.DataIn.AddRange(((byte[])packet));

                if (client.ScribbleRoomObject.ChunkCount == client.ScribbleRoomObject.Chunks)
                {
                    if (client.ScribbleRoomObject.ReceivedCount == client.ScribbleRoomObject.Size)
                    {
                        byte[] img    = client.ScribbleRoomObject.DataIn.ToArray();
                        String sender = Settings.Get <String>("bot");
                        int    height = 123; // not important

                        UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.NoSuch(x, "\x000314--- From " + client.Name)),
                                                     x => x.LoggedIn && x.Vroom == client.Vroom && x.CustomClient && !x.Quarantined && x.ID != client.ID && !x.IgnoreList.Contains(client.Name));

                        UserPool.AUsers.ForEachWhere(x => x.Scribble(sender, img, height),
                                                     x => x.LoggedIn && x.Vroom == client.Vroom && x.CustomClient && !x.Quarantined && x.ID != client.ID && !x.IgnoreList.Contains(client.Name));
                    }

                    client.ScribbleRoomObject.Reset();
                }
            }
        }
コード例 #9
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] IsIgnoringYou(AresClient client, String name)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, name);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_ISIGNORINGYOU));
        }
コード例 #10
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] OfflineUser(AresClient client, String name)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, name);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_OFFLINEUSER));
        }
コード例 #11
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] BotAvatarCleared(AresClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, Settings.Get <String>("bot"));
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_AVATAR));
        }
コード例 #12
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] AvatarCleared(AresClient client, IClient target)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, target.Name);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_AVATAR));
        }
コード例 #13
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] MyFeatures(AresClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, Settings.VERSION + " - " + Settings.RELEASE_URL);

            ServerFeatures flag = (ServerFeatures.SERVER_SUPPORTS_PVT |
                                   ServerFeatures.SERVER_SUPPORTS_SHARING |
                                   ServerFeatures.SERVER_SUPPORTS_COMPRESSION |
                                   ServerFeatures.SERVER_SUPPORTS_VC |
                                   ServerFeatures.SERVER_SUPPORTS_OPUS_VC |
                                   ServerFeatures.SERVER_SUPPORTS_PM_SCRIBBLES);

            if (client.SupportsHTML)
            {
                flag |= ServerFeatures.SERVER_SUPPORTS_HTML;
            }

            if (Settings.Get <bool>("can_room_scribble"))
            {
                flag |= ServerFeatures.SERVER_SUPPORTS_ROOM_SCRIBBLES;
            }

            packet.WriteByte((byte)flag);
            packet.WriteByte(63);
            packet.WriteByte(Settings.Get <byte>("language"));
            packet.WriteUInt32(client.Cookie);
            packet.WriteByte(1);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_MYFEATURES));
        }
コード例 #14
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] PersonalMessage(AresClient client, IClient target)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, target.Name);
            packet.WriteString(client, target.PersonalMessage, false);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_PERSONAL_MESSAGE));
        }
コード例 #15
0
ファイル: TCPProcessor.cs プロジェクト: miromancekimika/hola
        private static void LinkProto(AresClient client, TCPPacketReader packet, ulong time)
        {
            Leaf leaf = new Leaf(client.Sock, time, packet.ToArray());

            client.IsLeaf = true;
            client.Sock   = null;
            LeafPool.Leaves.Add(leaf);
        }
コード例 #16
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] PersonalMessageBot(AresClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, Settings.Get <String>("bot"));
            packet.WriteString(client, Settings.VERSION, false);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_PERSONAL_MESSAGE));
        }
コード例 #17
0
ファイル: TCPProcessor.cs プロジェクト: miromancekimika/hola
 private static void SecureLogin(AresClient client, TCPPacketReader packet)
 {
     if (!client.HasSecureLoginAttempted)
     {
         client.HasSecureLoginAttempted = true;
         AccountManager.SecureLogin(client, packet);
     }
 }
コード例 #18
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] Url(AresClient client, String addr, String tag)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, addr);
            packet.WriteString(client, tag);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_URL));
        }
コード例 #19
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] OpChange(AresClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteByte((byte)(client.Level > 0 ? 1 : 0));
            packet.WriteByte(0);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_OPCHANGE));
        }
コード例 #20
0
 private static void RemClientTag(AresClient client, TCPPacketReader packet)
 {
     while (packet.Remaining > 0)
     {
         String tag = packet.ReadString(client);
         client.CustomClientTags.RemoveAll(x => x == tag);
     }
 }
コード例 #21
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] Ack(AresClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, client.Name);
            packet.WriteString(client, Settings.Get <String>("name"));
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_LOGIN_ACK));
        }
コード例 #22
0
        private static void VCSupported(AresClient client, TCPPacketReader packet)
        {
            client.VoiceChatPublic  = (byte)packet == 1;
            client.VoiceChatPrivate = (byte)packet == 1;

            UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.VoiceChatUserSupport(x, client)),
                                         x => x.VoiceChatPrivate || x.VoiceChatPublic);
        }
コード例 #23
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] Userlist(AresClient client, IClient target)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt16(target.FileCount);
            packet.WriteUInt32(0);
            packet.WriteIP(Settings.HideIps ? IPAddress.Parse("0.0.0.0") : client.Ares ? target.ExternalIP : IPAddress.Parse("0.0.0.0"));
            packet.WriteUInt16(Settings.HideIps ? (ushort)0 : target.DataPort);
            packet.WriteIP(target.NodeIP);
            packet.WriteUInt16(target.NodePort);
            packet.WriteByte(0);
            packet.WriteString(client, target.Name);
            packet.WriteIP(Settings.HideIps ? IPAddress.Parse("0.0.0.0") : client.Ares ? target.LocalIP : IPAddress.Parse("0.0.0.0"));
            packet.WriteByte((byte)(target.Browsable ? 1 : 0));
            packet.WriteByte((byte)target.Level);
            packet.WriteByte(target.Age);
            packet.WriteByte(target.Sex);
            packet.WriteByte(target.Country);
            packet.WriteString(client, target.Region);

            byte b = 0;

            if (target.SupportsHTML)
            {
                b |= CLIENT_SUPPORTS_HTML;
            }

            if (target is AresClient)
            {
                AresClient ac = (AresClient)target;

                if (ac != null)
                {
                    if (ac.VoiceChatPublic)
                    {
                        b |= CLIENT_SUPPORTS_VC;
                    }

                    if (ac.VoiceChatPrivate)
                    {
                        b |= CLIENT_SUPPORTS_PM_VC;
                    }

                    if (ac.VoiceOpusChatPublic)
                    {
                        b |= CLIENT_SUPPORTS_OPUS_VC;
                    }

                    if (ac.VoiceOpusChatPrivate)
                    {
                        b |= CLIENT_SUPPORTS_OPUS_PM_VC;
                    }
                }
            }

            packet.WriteByte(b);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_CHANNEL_USER_LIST));
        }
コード例 #24
0
        private static void Font(AresClient client, TCPPacketReader packet)
        {
            if (packet.Remaining < 2)
            {
                client.Font = new AresFont();
                return;
            }

            AresFont font = new AresFont();

            font.Enabled  = true;
            font.size     = packet;
            font.FontName = packet.ReadString(client);
            font.oldN     = packet;
            font.oldT     = packet;

            if (packet.Remaining > 0)
            {
                font.NameColor = packet.ReadString(client);
            }

            if (packet.Remaining > 0)
            {
                font.TextColor = packet.ReadString(client);
            }

            if (String.IsNullOrEmpty(font.NameColor))
            {
                font.NameColor = Helpers.AresColorToHTMLColor(font.oldN);
            }

            if (String.IsNullOrEmpty(font.TextColor))
            {
                font.TextColor = Helpers.AresColorToHTMLColor(font.oldT);
            }

            // fonts cannot be bigger than 18
            if (font.size > 18)
            {
                font.size = 18;
            }

            if (!Settings.Get <bool>("fonts_enabled"))
            {
                return;
            }

            client.Font = font;

            if (!client.Quarantined)
            {
                UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.CustomFont(x, client)),
                                             x => x.IsCbot && !x.Quarantined && x.LoggedIn && x.Vroom == client.Vroom);
                UserPool.WUsers.ForEachWhere(x => x.QueuePacket(ib0t.WebOutbound.FontTo(x, client.Name, font.oldN, font.oldT)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);
            }
        }
コード例 #25
0
        public static void Browse(AresClient client, TCPPacketReader packet)
        {
            ushort     ident  = packet;
            byte       mime   = packet;
            String     name   = packet.ReadString(client);
            AresClient target = UserPool.AUsers.Find(x => x.Name == name);

            if (target == null && ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
            {
                IClient linked = ServerCore.Linker.FindUser(x => x.Name == name && x.FileCount > 0 && x.Browsable);

                if (linked != null)
                {
                    ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafBrowse(ServerCore.Linker,
                                                                                  linked.IUser.Link.Ident, linked.Name, client.Name, ident, mime));

                    return;
                }
            }

            if (target == null)
            {
                client.SendPacket(TCPOutbound.BrowseError(ident));
            }
            else if (target.SharedFiles.Count == 0)
            {
                client.SendPacket(TCPOutbound.BrowseError(ident));
            }
            else
            {
                var linq = from x in target.SharedFiles
                           where (mime == 0 || mime == 255) || (byte)x.Mime == (mime == 8 ? 0 : mime)
                           select TCPOutbound.BrowseItem(ident, x);

                client.SendPacket(TCPOutbound.StartOfBrowse(ident, (ushort)linq.Count()));

                List <byte> buffer = new List <byte>();

                foreach (byte[] x in linq)
                {
                    buffer.AddRange(x);

                    if (buffer.Count > 1024)
                    {
                        client.SendPacket(TCPOutbound.ClientCompressed(buffer.ToArray()));
                        buffer.Clear();
                    }
                }

                if (buffer.Count > 0)
                {
                    client.SendPacket(TCPOutbound.ClientCompressed(buffer.ToArray()));
                }

                client.SendPacket(TCPOutbound.EndOfBrowse(ident));
            }
        }
コード例 #26
0
        private static void VCChunk(AresClient client, TCPPacketReader packet)
        {
            if (Settings.Get <bool>("voice"))
            {
                byte[] data = packet;

                UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.VoiceChatChunk(x, client.Name, data)),
                                             x => x.ID != client.ID && x.VoiceChatPublic && !x.Quarantined && !x.VoiceChatIgnoreList.Contains(client.Name) && !x.IgnoreList.Contains(client.Name));
            }
        }
コード例 #27
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] VoiceChatNoPrivate(AresClient client, String sender)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, sender);
            byte[] buf = packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_VC_NOPVT);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_ADVANCED_FEATURES_PROTOCOL));
        }
コード例 #28
0
ファイル: TCPOutbound.cs プロジェクト: miromancekimika/hola
        public static byte[] Redirect(AresClient client, Room room)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteIP(room.IP);
            packet.WriteUInt16(room.Port);
            packet.WriteIP(room.IP);
            packet.WriteString(client, room.Name);
            packet.WriteString(client, "Redirecting...");
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_REDIRECT));
        }
コード例 #29
0
        public static void Search(AresClient client, TCPPacketReader packet)
        {
            ushort ident = packet;

            packet.SkipByte();
            byte          mime  = packet;
            ushort        len   = packet;
            List <byte[]> items = new List <byte[]>();

            List <String> search_words = new List <String>(
                Encoding.UTF8.GetString(packet.ReadBytes(len)).ToUpper().Replace("\0",
                                                                                 " ").Split(new String[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                );

            UserPool.AUsers.ForEachWhere(x =>
            {
                x.SharedFiles.ForEachWhere(y =>
                {
                    String[] words = y.FileName.Split(new String[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    words          = words.Concat(y.Title.Split(new String[] { " " }, StringSplitOptions.RemoveEmptyEntries)).ToArray();

                    foreach (String str in words)
                    {
                        if (search_words.Contains(str.ToUpper()))
                        {
                            items.Add(TCPOutbound.SearchHit(client, ident, x, y));
                            break;
                        }
                    }
                },
                                           y => (mime == 0 || mime == 255) || (byte)y.Mime == (mime == 8 ? 0 : mime));
            },
                                         x => x.SocketConnected && x.Browsable);

            List <byte> buffer = new List <byte>();

            foreach (byte[] x in items)
            {
                buffer.AddRange(x);

                if (buffer.Count > 1024)
                {
                    client.SendPacket(TCPOutbound.ClientCompressed(buffer.ToArray()));
                    buffer.Clear();
                }
            }

            if (buffer.Count > 0)
            {
                client.SendPacket(TCPOutbound.ClientCompressed(buffer.ToArray()));
            }

            client.SendPacket(TCPOutbound.EndOfSearch(ident));
        }
コード例 #30
0
 internal static byte[] Server(AresClient client)
 {
     if (server_avatar == null)
     {
         return(TCPOutbound.BotAvatarCleared(client));
     }
     else
     {
         return(TCPOutbound.BotAvatar(client, server_avatar));
     }
 }