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); }
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); }
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); }
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); }
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); }
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(); }
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(); }
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); }
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); }
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); }