Exemple #1
0
        public Ss1a(byte[] bytes) :
            this()
        {
            var ver = VgcApis.Libs.Streams.BitStream.ReadVersion(bytes);

            if (ver != version)
            {
                throw new NotSupportedException(
                          $"Not supported version ${ver}");
            }

            using (var bs = new VgcApis.Libs.Streams.BitStream(bytes))
            {
                var readString = Utils.GenReadStringHelper(bs, strTable);

                alias       = bs.Read <string>();
                description = readString();

                address     = bs.ReadAddress();
                port        = bs.Read <int>();
                password    = bs.Read <string>();
                method      = readString();
                networkType = bs.ReadTinyInt(networkTypeLenInBits);
                isUseOta    = bs.Read <bool>();

                isUseTls     = bs.Read <bool>();
                streamType   = readString();
                streamParam1 = readString();
                streamParam2 = readString();
                streamParam3 = readString();
            }
        }
Exemple #2
0
        public Socks2a(byte[] bytes) :
            this()
        {
            var ver = VgcApis.Libs.Streams.BitStream.ReadVersion(bytes);

            if (ver != version)
            {
                throw new NotSupportedException($"Not supported version ${ver}");
            }

            using (var bs = new VgcApis.Libs.Streams.BitStream(bytes))
            {
                var readString = Utils.GenReadStringHelper(bs, strTable);

                alias        = bs.Read <string>();
                description  = readString();
                isUseTls     = bs.Read <bool>();
                isSecTls     = bs.Read <bool>();
                port         = bs.Read <int>();
                address      = bs.ReadAddress();
                userName     = readString();
                userPassword = readString();
                streamType   = readString();
                streamParam1 = readString();
                streamParam2 = readString();
                streamParam3 = readString();
            }
        }
Exemple #3
0
        public void StringTest(string str)
        {
            bs.Clear();
            bs.Write(str);
            var result = bs.Read <string>();

            Assert.AreEqual(str, result);
        }
Exemple #4
0
        public static string ReadString(
            VgcApis.Libs.Streams.BitStream bitStream,
            List <string> strTable)
        {
            var lenInBits = VgcApis.Misc.Utils.GetLenInBitsOfInt(strTable.Count);

            if (bitStream.Read <bool>())
            {
                // using string table
                var index = bitStream.ReadTinyInt(lenInBits);
                return(strTable[index]);
            }
            else
            {
                return(bitStream.Read <string>());
            }
        }
Exemple #5
0
        public Vless4a(byte[] bytes) :
            this()
        {
            var ver = VgcApis.Libs.Streams.BitStream.ReadVersion(bytes);

            if (ver != version)
            {
                throw new NotSupportedException($"Not supported version ${ver}");
            }

            using (var bs = new VgcApis.Libs.Streams.BitStream(bytes))
            {
                var readString = Utils.GenReadStringHelper(bs, strTable);

                alias        = bs.Read <string>();
                description  = readString();
                isUseTls     = bs.Read <bool>();
                isSecTls     = bs.Read <bool>();
                port         = bs.Read <int>();
                encryption   = bs.Read <string>();
                uuid         = bs.Read <Guid>();
                address      = bs.ReadAddress();
                streamType   = readString();
                streamParam1 = readString();
                streamParam2 = readString();
                streamParam3 = readString();
            }

            if (string.IsNullOrEmpty(encryption))
            {
                encryption = "none";
            }
        }