示例#1
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));
        }
示例#2
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));
        }
示例#3
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));
        }
示例#4
0
        public static byte[] SuperNodes()
        {
            var linq = from x in UserPool.AUsers
                       where x.NodePort > 0 && (x.Version.StartsWith("Ares 2.") || x.Version.StartsWith("Ares_2."))
                       select new IPEndPoint(x.ExternalIP, x.DataPort);

            TCPPacketWriter packet = new TCPPacketWriter();

            if (linq.Count() > 0)
            {
                List <IPEndPoint> nodes = linq.ToList();
                nodes.Randomize();

                if (nodes.Count > 20)
                {
                    nodes = nodes.GetRange(0, 20);
                }

                foreach (IPEndPoint n in nodes)
                {
                    packet.WriteIP(n.Address);
                    packet.WriteUInt16((ushort)n.Port);
                }
            }

            return(packet.ToAresPacket(TCPMsg.MSG_CHAT_SERVER_HERE_SUPERNODES));
        }
示例#5
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));
        }
示例#6
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));
        }
示例#7
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));
        }