Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        public static byte[] CustomData(IClient client, String sender, String ident, byte[] data)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, ident);
            packet.WriteString(client, sender);
            packet.WriteBytes(data);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_CUSTOM_DATA));
        }
Beispiel #7
0
        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));
        }
Beispiel #8
0
        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));
        }
Beispiel #9
0
        public static byte[] HTML(String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(text, false, true);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_HTML));
        }
Beispiel #10
0
        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));
        }
Beispiel #11
0
        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));
        }
Beispiel #12
0
        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));
        }
Beispiel #13
0
        public static byte[] IsIgnoringYou(AresClient client, String name)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, name);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_ISIGNORINGYOU));
        }
Beispiel #14
0
        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));
        }
Beispiel #15
0
        public static byte[] OfflineUser(AresClient client, String name)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, name);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_OFFLINEUSER));
        }
Beispiel #16
0
        public static byte[] UpdateUserStatus(AresClient client, IClient target)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, target.Name);
            packet.WriteUInt16(target.FileCount);
            packet.WriteByte((byte)(target.Browsable ? 1 : 0));
            packet.WriteIP(target.NodeIP);
            packet.WriteUInt16(target.NodePort);
            packet.WriteIP(Settings.HideIps ? IPAddress.Parse("0.0.0.0") : (client.Ares ? target.ExternalIP : IPAddress.Parse("0.0.0.0")));
            packet.WriteByte((byte)target.Level);
            packet.WriteByte(target.Age);
            packet.WriteByte(target.Sex);
            packet.WriteByte(target.Country);
            packet.WriteString(client, target.Region);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_UPDATE_USER_STATUS));
        }
Beispiel #17
0
        public static byte[] CustomFont(AresClient client, AresClient target)
        {
            TCPPacketWriter packet = new TCPPacketWriter();
            AresFont        f      = (AresFont)target.Font;

            packet.WriteString(client, target.Name);          // user's name + null
            packet.WriteByte(f.size);
            packet.WriteString(client, target.Font.FontName); // null terminated
            packet.WriteByte(f.oldN);
            packet.WriteByte(f.oldT);
            packet.WriteString(client, target.Font.NameColor);
            packet.WriteString(client, target.Font.TextColor);

            byte[] buf = packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_CUSTOM_FONT); // id = 204
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_ADVANCED_FEATURES_PROTOCOL));
        }
Beispiel #18
0
        public static byte[] Private(IClient client, String username, String text)
        {
            if (text.Length > 300)
            {
                text = text.Substring(0, 300);
            }

            while (Encoding.UTF8.GetByteCount(text) > 300)
            {
                text = text.Substring(0, text.Length - 1);
            }

            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, username);
            packet.WriteString(client, text, false);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_PVT));
        }
Beispiel #19
0
        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));
        }
Beispiel #20
0
        public static byte[] DirectChatPush(AresClient client, IClient target, byte[] cookie)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, target.Name);
            packet.WriteIP(target.ExternalIP);
            packet.WriteUInt16(target.DataPort);
            packet.WriteIP(target.LocalIP);
            packet.WriteBytes(cookie);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_CLIENT_DIRCHATPUSH));
        }
Beispiel #21
0
        public static byte[] UserlistBot(AresClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt16(0);
            packet.WriteUInt32(0);
            packet.WriteIP("0.0.0.0");
            packet.WriteUInt16(69);
            packet.WriteIP("0.0.0.0");
            packet.WriteUInt16(0);
            packet.WriteByte(0);
            packet.WriteString(client, Settings.Get <String>("bot"));
            packet.WriteIP("0.0.0.0");
            packet.WriteByte(1);
            packet.WriteByte(3);
            packet.WriteByte(0);
            packet.WriteByte(0);
            packet.WriteByte(0);
            packet.WriteString(client, String.Empty);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_CHANNEL_USER_LIST));
        }
Beispiel #22
0
        public static byte[] VoiceChatUserSupport(AresClient client, AresClient target)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, target.Name);
            packet.WriteByte((byte)(target.VoiceChatPublic ? 1 : 0));
            packet.WriteByte((byte)(target.VoiceChatPrivate ? 1 : 0));
            byte[] buf = packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_VC_USER_SUPPORTED);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_ADVANCED_FEATURES_PROTOCOL));
        }
Beispiel #23
0
        public static byte[] NoSuch(AresClient client, String text)
        {
            String str = text;

            if (str.Length == 0)
            {
                str = " ";
            }

            while (Encoding.UTF8.GetByteCount(str) > 4000)
            {
                str = str.Substring(0, str.Length - 1);
            }

            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, str, false);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_NOSUCH));
        }
Beispiel #24
0
        public static byte[] SearchHit(AresClient client, ushort id, AresClient target, SharedFile file)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt16(id);
            packet.WriteByte((byte)file.Mime);
            packet.WriteUInt32(file.Size);
            packet.WriteBytes(file.Data);
            packet.WriteString(client, target.Name);
            packet.WriteIP(target.ExternalIP);
            packet.WriteUInt16(target.DataPort);
            packet.WriteIP(target.NodeIP);
            packet.WriteUInt16(target.NodePort);
            packet.WriteIP(target.LocalIP);
            packet.WriteByte(target.CurrentUploads);
            packet.WriteByte(target.MaxUploads);
            packet.WriteByte(target.CurrentQueued);
            packet.WriteByte(1);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_SEARCHHIT));
        }