⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 requirmentsocks5message.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.CommLayer.SocksSipConnection
{
    using System;
    using System.IO;
    using System.Text;

    internal abstract class RequirmentSocks5Message : Socks5Message
    {
        private Imps.Client.CommLayer.SocksSipConnection.HostNameType _atyp;
        private RequirementType _cmd;
        private string _dstAddr;
        private int _dstPort;

        public RequirmentSocks5Message()
        {
            this._cmd = RequirementType.Connect;
            this._dstAddr = "0.0.0.0";
            this._atyp = Imps.Client.CommLayer.SocksSipConnection.HostNameType.Ip4;
        }

        public RequirmentSocks5Message(RequirementType requirementType, string dstAddr, int dstPort)
        {
            this._cmd = RequirementType.Connect;
            this._dstAddr = "0.0.0.0";
            this._atyp = Imps.Client.CommLayer.SocksSipConnection.HostNameType.Ip4;
            this.Cmd = requirementType;
            this.DstAddr = dstAddr;
            this.DstPort = dstPort;
        }

        public override byte[] ToBinary()
        {
            MemoryStream stream = new MemoryStream();
            stream.WriteByte((byte) base.Ver);
            stream.WriteByte((byte) this.Cmd);
            stream.WriteByte(0);
            stream.WriteByte((byte) this.Atyp);
            if (this.Atyp == Imps.Client.CommLayer.SocksSipConnection.HostNameType.HostName)
            {
                stream.WriteByte((byte) this.DstAddr.Length);
                byte[] bytes = Encoding.UTF8.GetBytes(this.DstAddr);
                stream.Write(bytes, 0, bytes.Length);
            }
            else
            {
                try
                {
                    foreach (string text in this.DstAddr.Split(new char[] { '.' }))
                    {
                        stream.WriteByte(byte.Parse(text));
                    }
                }
                catch (Exception exception)
                {
                    throw new ArgumentException("所指定的目标服务器无效!", exception);
                }
            }
            stream.WriteByte((byte) (this.DstPort >> 8));
            stream.WriteByte((byte) this.DstPort);
            return stream.ToArray();
        }

        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("VER : {0}\n", base.Ver);
            builder.AppendFormat("CMD : {0}\n", this.Cmd);
            builder.AppendFormat("RSV : {0}\n", 0);
            builder.AppendFormat("ATYP : {0}\n", this.Atyp);
            builder.AppendFormat("BND.ADDR : {0}\n", this.DstAddr);
            builder.AppendFormat("BND.PORT : {0}", this.DstPort);
            return builder.ToString();
        }

        public Imps.Client.CommLayer.SocksSipConnection.HostNameType Atyp
        {
            get
            {
                return this._atyp;
            }
        }

        public RequirementType Cmd
        {
            get
            {
                return this._cmd;
            }
            set
            {
                this._cmd = value;
            }
        }

        public string DstAddr
        {
            get
            {
                return this._dstAddr;
            }
            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("DstAddr");
                }
                int length = value.Split(new char[] { '.' }).Length;
                switch (length)
                {
                    case 4:
                        this._atyp = Imps.Client.CommLayer.SocksSipConnection.HostNameType.Ip4;
                        break;

                    case 0x10:
                        this._atyp = Imps.Client.CommLayer.SocksSipConnection.HostNameType.Ip6;
                        break;

                    default:
                        if (length > 2)
                        {
                            throw new ArgumentException("指定的服务器无效");
                        }
                        this._atyp = Imps.Client.CommLayer.SocksSipConnection.HostNameType.HostName;
                        break;
                }
                this._dstAddr = value;
            }
        }

        public int DstPort
        {
            get
            {
                return this._dstPort;
            }
            set
            {
                this._dstPort = value;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -