Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ibigbug committed Oct 16, 2024
1 parent 19be843 commit 7adeb18
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions clash_lib/src/proxy/hysteria2/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ impl Decoder for Hy2TcpCodec {
type Error = std::io::Error;
type Item = Hy2TcpResp;

fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
fn decode(
&mut self,
src: &mut BytesMut,
) -> Result<Option<Self::Item>, Self::Error> {
if !src.has_remaining() {
return Err(ErrorKind::UnexpectedEof.into());
}
Expand All @@ -42,8 +45,8 @@ impl Decoder for Hy2TcpCodec {
}

let msg: Vec<u8> = src.split_to(msg_len).into();
let msg: String =
String::from_utf8(msg).map_err(|e| std::io::Error::new(ErrorKind::InvalidData, e))?;
let msg: String = String::from_utf8(msg)
.map_err(|e| std::io::Error::new(ErrorKind::InvalidData, e))?;

let padding_len = VarInt::decode(src)
.map_err(|_| ErrorKind::UnexpectedEof)?
Expand All @@ -68,7 +71,12 @@ pub fn padding(range: std::ops::RangeInclusive<u32>) -> Vec<u8> {

impl Encoder<&'_ SocksAddr> for Hy2TcpCodec {
type Error = std::io::Error;
fn encode(&mut self, item: &'_ SocksAddr, buf: &mut BytesMut) -> Result<(), Self::Error> {

fn encode(
&mut self,
item: &'_ SocksAddr,
buf: &mut BytesMut,
) -> Result<(), Self::Error> {
const REQ_ID: VarInt = VarInt::from_u32(0x401);

let padding = padding(64..=512);
Expand Down

0 comments on commit 7adeb18

Please sign in to comment.