Ejemplo n.º 1
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));
        }
        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));
        }
        public static byte[] VoiceChatChunkTo(AresClient client, String sender, byte[] buffer)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(client, sender);
            packet.WriteBytes(buffer);
            byte[] buf = packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_VC_CHUNK_FROM);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_ADVANCED_FEATURES_PROTOCOL));
        }
        public static byte[] SupportsVoiceClips()
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteByte((byte)(Settings.Get <bool>("voice") ? 1 : 0));
            packet.WriteByte(0);
            byte[] buf = packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_VC_SUPPORTED);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_ADVANCED_FEATURES_PROTOCOL));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
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));
        }
Ejemplo n.º 8
0
        public static byte[] CryptoKey(AresClient client)
        {
            byte[] guid = client.Guid.ToByteArray();
            byte[] key  = client.Encryption.IV.Concat(client.Encryption.Key).ToArray();

            for (int i = 0; i < guid.Length; i += 2)
            {
                key = Crypto.e67(key, BitConverter.ToUInt16(guid, i));
            }

            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteBytes(key);
            byte[] data = packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_CRYPTO_KEY);
            packet = new TCPPacketWriter();
            packet.WriteBytes(data);
            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_ADVANCED_FEATURES_PROTOCOL));
        }
Ejemplo n.º 9
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));
        }
Ejemplo n.º 10
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));
        }
Ejemplo n.º 11
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));
        }
Ejemplo n.º 12
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));
        }