protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List <object> output) { try { switch (State) { case EState.Init: var version = input.ReadByte(); if (version != 1) { throw new DecoderException("unsupported subnegotiation version: " + version + " (expected: 1)"); } output.Add(new DefaultSocks5PasswordAuthResponse( Socks5PasswordAuthStatus.ValueOf(input.ReadByte()))); Checkpoint(EState.Success); break; case EState.Success: var readableBytes = ActualReadableBytes; if (readableBytes > 0) { output.Add(input.ReadRetainedSlice(readableBytes)); } break; case EState.Failure: input.SkipBytes(ActualReadableBytes); break; } } catch (Exception e) { Fail(output, e); } }
public DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus status) { Status = status; }