Exemple #1
0
        public TorSocks5Request(byte[] bytes)
        {
            Guard.NotNullOrEmpty(nameof(bytes), bytes);
            Guard.MinimumAndNotNull($"{nameof(bytes)}.{nameof(bytes.Length)}", bytes.Length, 6);

            Ver = new VerField(bytes[0]);

            Cmd = new CmdField();
            Cmd.FromByte(bytes[1]);

            Rsv = new RsvField();
            Rsv.FromByte(bytes[2]);

            Atyp = new AtypField(bytes[3]);

            DstAddr = new AddrField(bytes[4..^ 2]);
Exemple #2
0
        public override void FromBytes(byte[] bytes)
        {
            Guard.NotNullOrEmpty(nameof(bytes), bytes);
            Guard.MinimumAndNotNull($"{nameof(bytes)}.{nameof(bytes.Length)}", bytes.Length, 6);

            Ver = new VerField();
            Ver.FromByte(bytes[0]);

            Cmd = new CmdField();
            Cmd.FromByte(bytes[1]);

            Rsv = new RsvField();
            Rsv.FromByte(bytes[2]);

            Atyp = new AtypField();
            Atyp.FromByte(bytes[3]);

            DstAddr = new AddrField();
            DstAddr.FromBytes(bytes.Skip(4).Take(bytes.Length - 4 - 2).ToArray());

            DstPort = new PortField();
            DstPort.FromBytes(bytes.Skip(bytes.Length - 2).ToArray());
        }