I'm working up some changes to this effect in my fork; I'd prefer to merge them back here if you are amenable.
The high level outline is as below; the names and so on can be tweaked to match your preference.
- Add
SocksV5Command::Other(u8)
SocksV5Command::from_u8 continues to return Option<SocksV5Command> and return only RFC 1928 commands, so that read_request continues to have the same semantics wrt. rejecting unknown commands.
- Add
SocksV5Command::from_any_u8(u8) -> SocksV5Command that will populate Other for values outside of RFC 1928
- Add
read_request_impl(reader: Reader, allow_extensions: bool) that can opt-in to using SocksV5Command::from_any_u8.
- Adjust
read_request to call through to read_request_impl to avoid duplicating the logic
I've tried to avoid making backwards-incompatible API changes in the above, but if you prefer, SocksV5Command::from_u8 could be renamed to SocksV5Command::from_rfc1928(u8) to more closely indicate its underlying action/effect and so on.
Is this something that you'd be interesting in merging? I'll send a PR if that is ok!
I'm working up some changes to this effect in my fork; I'd prefer to merge them back here if you are amenable.
The high level outline is as below; the names and so on can be tweaked to match your preference.
SocksV5Command::Other(u8)SocksV5Command::from_u8continues to returnOption<SocksV5Command>and return only RFC 1928 commands, so thatread_requestcontinues to have the same semantics wrt. rejecting unknown commands.SocksV5Command::from_any_u8(u8) -> SocksV5Commandthat will populateOtherfor values outside of RFC 1928read_request_impl(reader: Reader, allow_extensions: bool)that can opt-in to usingSocksV5Command::from_any_u8.read_requestto call through toread_request_implto avoid duplicating the logicI've tried to avoid making backwards-incompatible API changes in the above, but if you prefer,
SocksV5Command::from_u8could be renamed toSocksV5Command::from_rfc1928(u8)to more closely indicate its underlying action/effect and so on.Is this something that you'd be interesting in merging? I'll send a PR if that is ok!