diff --git a/idevice/src/services/xpc/http2/h2.rs b/idevice/src/services/xpc/http2/h2.rs index b57e387..c4ee9dc 100644 --- a/idevice/src/services/xpc/http2/h2.rs +++ b/idevice/src/services/xpc/http2/h2.rs @@ -16,19 +16,6 @@ pub struct Frame { } impl Frame { - pub fn new(stream_id: u32, flags: u8, frame_type: FrameType) -> Self { - Self { - stream_id, - flags, - frame_type, - body: Vec::new(), - } - } - - pub fn set_body(&mut self, body: Vec) { - self.body = body; - } - pub fn deserialize(buf: &[u8]) -> Result { let mut len_buf = buf[0..3].to_vec(); len_buf.insert(0, 0); @@ -72,13 +59,8 @@ pub struct SettingsFrame { } impl SettingsFrame { - pub const HEADER_TABLE_SIZE: u16 = 0x01; - pub const ENABLE_PUSH: u16 = 0x02; pub const MAX_CONCURRENT_STREAMS: u16 = 0x03; pub const INITIAL_WINDOW_SIZE: u16 = 0x04; - pub const MAX_FRAME_SIZE: u16 = 0x05; - pub const MAX_HEADER_LIST_SIZE: u16 = 0x06; - pub const ENABLE_CONNECT_PROTOCOL: u16 = 0x08; pub const ACK: u8 = 0x01; pub fn new(/*stream_id: u32, */ settings: HashMap, flags: u8) -> Self { @@ -136,7 +118,6 @@ impl From for SettingsFrame { pub struct WindowUpdateFrame { frame: Frame, - pub window_increment: u32, } impl WindowUpdateFrame { @@ -152,7 +133,6 @@ impl WindowUpdateFrame { frame_type: FrameType::WindowUpdate, body: window_increment.to_be_bytes().to_vec(), }, - window_increment, } } } @@ -165,11 +145,7 @@ impl Framable for WindowUpdateFrame { impl From for WindowUpdateFrame { fn from(value: Frame) -> Self { - let body = value.body.clone(); - Self { - frame: value, - window_increment: u32::from_be_bytes(body.try_into().unwrap()), - } + Self { frame: value } } } @@ -178,7 +154,6 @@ pub struct HeadersFrame { } impl HeadersFrame { - pub const END_STREAM: u8 = 0x01; pub const END_HEADERS: u8 = 0x04; pub const PADDED: u8 = 0x08; pub const PRIORITY: u8 = 0x20; @@ -279,9 +254,3 @@ impl From for FrameType { unsafe { std::mem::transmute::<_, FrameType>(value) } } } - -// impl Drop for Connection { -// fn drop(&mut self) { - -// } -// } diff --git a/idevice/src/services/xpc/http2/mod.rs b/idevice/src/services/xpc/http2/mod.rs index 3e1391f..c862901 100644 --- a/idevice/src/services/xpc/http2/mod.rs +++ b/idevice/src/services/xpc/http2/mod.rs @@ -142,78 +142,3 @@ impl Connection { } } } - -#[cfg(test)] -mod tests { - use super::*; - - #[tokio::test] - async fn it_works() { - // let frame: Frame = Frame::deserialize( - // &BASE64_STANDARD - // .decode("AAAECAAAAAAAAA8AAQ==" /*"AAAABAEAAAAA"*/) - // .unwrap(), - // ) - // .unwrap() - // .into(); - // println!("supposed: {:x?}", frame.frame_type); - // return; - let mut client = Connection::new(Box::new( - tokio::net::TcpStream::connect("0.0.0.0:1010") - .await - .unwrap(), - )) - .await - .unwrap(); - - // apart of spec, settings frame must be immediately sent after. Can be empty but must exist. - client - .send_frame(SettingsFrame::new( - [ - (SettingsFrame::MAX_CONCURRENT_STREAMS, 100), - (SettingsFrame::INITIAL_WINDOW_SIZE, 1048576), - ] - .into_iter() - .collect(), - Default::default(), - )) - .await - .unwrap(); - - // apart of spec we are allowed to send frames before reading any from the server. - // 'INIT_STREAM'/0 applies to all stream_ids. - client - .send_frame(WindowUpdateFrame::new(INIT_STREAM, 983041)) - .await - .unwrap(); - - // We create stream_id '1' by sending Header frame. - let mut frame = Frame::new(ROOT_CHANNEL, 5, FrameType::Headers); - frame.set_body( - [ - 0x41, 0x89, 0x2, 0xe0, 0x5c, 0xb, 0x82, 0xe0, 0x40, 0x10, 0x7f, 0x82, 0x84, 0x86, - 0x50, 0x83, 0x9b, 0xd9, 0xab, 0x7a, 0x8d, 0xc4, 0x75, 0xa7, 0x4a, 0x6b, 0x58, 0x94, - 0x18, 0xb5, 0x25, 0x81, 0x2e, 0xf, - ] - .to_vec(), - ); - - // when server sends 'Settings' on a streamId that the client hasn't sent one on. - // then we must send them back one. - client - .send_frame(Frame::new(ROOT_CHANNEL, 1, FrameType::Settings)) - .await - .unwrap(); - - client - .write_streamid(ROOT_CHANNEL, b"nibba\x00".to_vec()) - .await - .unwrap(); - // 'END_HEADERS' is sent before data. - - println!( - "response: {:?}", - String::from_utf8_lossy(&client.read_streamid(1).await.unwrap()) - ); - } -} diff --git a/tools/src/misagent.rs b/tools/src/misagent.rs index 4dafd38..04057ac 100644 --- a/tools/src/misagent.rs +++ b/tools/src/misagent.rs @@ -77,9 +77,6 @@ async fn main() { .copy_all() .await .expect("Unable to get images"); - for i in &images { - // println!("{:?}", i); - } if let Some(path) = matches.get_one::("save") { tokio::fs::create_dir_all(path) .await diff --git a/tools/src/pair.rs b/tools/src/pair.rs index 19f16df..4ca173d 100644 --- a/tools/src/pair.rs +++ b/tools/src/pair.rs @@ -7,8 +7,6 @@ use idevice::{ IdeviceService, }; -mod common; - #[tokio::main] async fn main() { env_logger::init();