コード例 #1
0
        private void Fail(List <object> output, Exception cause)
        {
            if (!(cause is DecoderException))
            {
                cause = new DecoderException(cause);
            }

            Checkpoint(Socks5InitialRequestDecoderState.Failure);

            ISocks5Message m = new DefaultSocks5InitialRequest(Socks5AuthMethod.NoAuth);

            m.SetDecoderResult(DecoderResult.Failure(cause));
            output.Add(m);
        }
コード例 #2
0
        private void Fail(List <object> output, Exception cause)
        {
            if (!(cause is DecoderException))
            {
                cause = new DecoderException(cause);
            }

            var m = new DefaultSocks4CommandResponse(Socks4CommandStatus.RejectedOrFailed);

            m.SetDecoderResult(DecoderResult.Failure(cause));
            output.Add(m);

            Checkpoint(Socks4ClientDecoderState.Failure);
        }
コード例 #3
0
        private void Fail(List <object> output, Exception cause)
        {
            if (!(cause is DecoderException))
            {
                cause = new DecoderException(cause);
            }

            Checkpoint(Socks5PasswordAuthRequestDecoderState.Failure);

            ISocks5Message m = new DefaultSocks5PasswordAuthRequest("", "");

            m.SetDecoderResult(DecoderResult.Failure(cause));
            output.Add(m);
        }
コード例 #4
0
        IHttpContent InvalidChunk(IByteBuffer buf, Exception cause)
        {
            this.currentState = State.BadMessage;

            // Advance the readerIndex so that ByteToMessageDecoder does not complain
            // when we produced an invalid message without consuming anything.
            buf.SkipBytes(buf.ReadableBytes);

            IHttpContent chunk = new DefaultLastHttpContent(Unpooled.Empty);

            chunk.Result = DecoderResult.Failure(cause);
            this.message = null;
            this.trailer = null;
            return(chunk);
        }
コード例 #5
0
        private void Fail(List <object> output, Exception cause)
        {
            if (!(cause is DecoderException))
            {
                cause = new DecoderException(cause);
            }

            Checkpoint(Socks5CommandResponseDecoderState.Failure);

            ISocks5Message m = new DefaultSocks5CommandResponse(
                Socks5CommandStatus.Failure,
                Socks5AddressType.Pv4,
                null,
                0);

            m.SetDecoderResult(DecoderResult.Failure(cause));
            output.Add(m);
        }
コード例 #6
0
        public void ReplaceAggregatedResponse()
        {
            var ch = new EmbeddedChannel(new HttpObjectAggregator(1024 * 1024));

            var boom = new Exception("boom");
            var rep  = new DefaultHttpResponse(HttpVersion.Http11, HttpResponseStatus.OK);

            rep.Result = DecoderResult.Failure(boom);

            Assert.True(ch.WriteInbound(rep) && ch.Finish());

            var aggregatedRep = ch.ReadInbound <IFullHttpResponse>();
            var replacedRep   = (IFullHttpResponse)aggregatedRep.Replace(Unpooled.Empty);

            Assert.Equal(replacedRep.Result, aggregatedRep.Result);
            aggregatedRep.Release();
            replacedRep.Release();
        }
コード例 #7
0
        public void ReplaceAggregatedRequest()
        {
            var ch = new EmbeddedChannel(new HttpObjectAggregator(1024 * 1024));

            var boom = new Exception("boom");
            var req  = new DefaultHttpRequest(HttpVersion.Http11, HttpMethod.Get, "http://localhost");

            req.Result = DecoderResult.Failure(boom);

            Assert.True(ch.WriteInbound(req) && ch.Finish());

            var aggregatedReq = ch.ReadInbound <IFullHttpRequest>();
            var replacedReq   = (IFullHttpRequest)aggregatedReq.Replace(Unpooled.Empty);

            Assert.Equal(replacedReq.Result, aggregatedReq.Result);
            aggregatedReq.Release();
            replacedReq.Release();
        }
コード例 #8
0
        private void Fail(List <object> output, Exception cause)
        {
            if (!(cause is DecoderException))
            {
                cause = new DecoderException(cause);
            }

            Checkpoint(Socks5CommandRequestDecoderState.Failure);

            ISocks5Message m = new DefaultSocks5CommandRequest(
                Socks5CommandType.Connect,
                Socks5AddressType.Pv4,
                "0.0.0.0",
                1);

            m.SetDecoderResult(DecoderResult.Failure(cause));
            output.Add(m);
        }
コード例 #9
0
ファイル: HttpObjectDecoder.cs プロジェクト: wxlonstar/Fenix
        IHttpMessage InvalidMessage(IByteBuffer buf, Exception cause)
        {
            _currentState = State.BadMessage;

            // Advance the readerIndex so that ByteToMessageDecoder does not complain
            // when we produced an invalid message without consuming anything.
            _ = buf.SkipBytes(buf.ReadableBytes);

            if (_message is null)
            {
                _message = CreateInvalidMessage();
            }
            _message.Result = DecoderResult.Failure(cause);

            IHttpMessage ret = _message;

            _message = null;
            return(ret);
        }
コード例 #10
0
        private void Fail(List <object> output, Exception cause)
        {
            if (!(cause is DecoderException))
            {
                cause = new DecoderException(cause);
            }

            ISocks4CommandRequest m = new DefaultSocks4CommandRequest(
                _type ?? Socks4CommandType.Connect,
                _dstAddr ?? "",
                _dstPort != 0
                    ? _dstPort
                    : 65535,
                _userId ?? "");

            m.SetDecoderResult(DecoderResult.Failure(cause));
            output.Add(m);

            Checkpoint(Socks4ServerDecoderState.Failure);
        }