Ejemplo n.º 1
0
        private DnsResourceRecord ResolveWksRecord(ResourceRecordInfo info)
        {
            var address  = _reader.ReadIPAddress();
            var protocol = _reader.ReadByte();
            var bitmap   = _reader.ReadBytes(info.RawDataLength - 5);

            return(new WksRecord(info, address, protocol, bitmap.ToArray()));
        }
Ejemplo n.º 2
0
        public static string ParseString(DnsDatagramReader reader, int length)
        {
            var builder = new StringBuilder();

            for (var i = 0; i < length; i++)
            {
                byte b = reader.ReadByte();
                char c = (char)b;

                if (b < 32 || b > 126)
                {
                    builder.Append("\\" + b.ToString("000"));
                }
                else if (c == ';')
                {
                    builder.Append("\\;");
                }
                else if (c == '\\')
                {
                    builder.Append("\\\\");
                }
                else if (c == '"')
                {
                    builder.Append("\\\"");
                }
                else
                {
                    builder.Append(c);
                }
            }

            return(builder.ToString());
        }
Ejemplo n.º 3
0
        public static string ParseString(DnsDatagramReader reader, int length)
        {
            if (reader._count < reader._index + length)
            {
                throw new DnsResponseParseException("Cannot parse string.", reader._data.ToArray(), reader._index, length);
            }

            var builder = StringBuilderObjectPool.Default.Get();

            for (var i = 0; i < length; i++)
            {
                byte b = reader.ReadByte();
                char c = (char)b;

                if (b < 32 || b > 126)
                {
                    builder.Append("\\" + b.ToString("000"));
                }
                else if (c == ';')
                {
                    builder.Append("\\;");
                }
                else if (c == '\\')
                {
                    builder.Append("\\\\");
                }
                else if (c == '"')
                {
                    builder.Append("\\\"");
                }
                else
                {
                    builder.Append(c);
                }
            }

            var value = builder.ToString();

            StringBuilderObjectPool.Default.Return(builder);
            return(value);
        }
Ejemplo n.º 4
0
        public static string ParseString(DnsDatagramReader reader, int length)
        {
            var builder = StringBuilderObjectPool.Default.Get();

            for (var i = 0; i < length; i++)
            {
                byte b = reader.ReadByte();
                char c = (char)b;

                if (b < 32 || b > 126)
                {
                    builder.Append("\\" + b.ToString("000"));
                }
                else if (c == ';')
                {
                    builder.Append("\\;");
                }
                else if (c == '\\')
                {
                    builder.Append("\\\\");
                }
                else if (c == '"')
                {
                    builder.Append("\\\"");
                }
                else
                {
                    builder.Append(c);
                }
            }

            var value = builder.ToString();

            StringBuilderObjectPool.Default.Return(builder);
            return(value);
        }