change how vnc generate c2s messages
This commit is contained in:
parent
4aa8c19adb
commit
098629536a
@ -52,6 +52,7 @@ pub struct VncHandler {
|
|||||||
msg_handling: ServerMessage,
|
msg_handling: ServerMessage,
|
||||||
num_rect_left: u16,
|
num_rect_left: u16,
|
||||||
padding_rect: Option<VncRect>,
|
padding_rect: Option<VncRect>,
|
||||||
|
outbuf: Vec<u8>,
|
||||||
outs: Vec<ProtocalHandlerOutput>,
|
outs: Vec<ProtocalHandlerOutput>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ impl ProtocalImpl for VncHandler {
|
|||||||
msg_handling: ServerMessage::None,
|
msg_handling: ServerMessage::None,
|
||||||
num_rect_left: 0,
|
num_rect_left: 0,
|
||||||
padding_rect: None,
|
padding_rect: None,
|
||||||
|
outbuf: Vec::with_capacity(128),
|
||||||
outs: Vec::with_capacity(10),
|
outs: Vec::with_capacity(10),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,6 +97,10 @@ impl ProtocalImpl for VncHandler {
|
|||||||
for o in self.outs.drain(..) {
|
for o in self.outs.drain(..) {
|
||||||
out.push(o);
|
out.push(o);
|
||||||
}
|
}
|
||||||
|
if !self.outbuf.is_empty() {
|
||||||
|
out.push(ProtocalHandlerOutput::WsBuf(self.outbuf.clone()));
|
||||||
|
self.outbuf.clear();
|
||||||
|
}
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,8 +126,7 @@ impl ProtocalImpl for VncHandler {
|
|||||||
// ConsoleService::log(&format!("challenge {:x?}", self.challenge));
|
// ConsoleService::log(&format!("challenge {:x?}", self.challenge));
|
||||||
let output = des::encrypt(&self.challenge, &key);
|
let output = des::encrypt(&self.challenge, &key);
|
||||||
|
|
||||||
self.outs
|
self.outbuf.extend_from_slice(&output);
|
||||||
.push(ProtocalHandlerOutput::WsBuf(output.to_vec()));
|
|
||||||
self.state = VncState::Authing;
|
self.state = VncState::Authing;
|
||||||
self.require = 4; // the auth result message length
|
self.require = 4; // the auth result message length
|
||||||
}
|
}
|
||||||
@ -202,8 +207,7 @@ impl VncHandler {
|
|||||||
|
|
||||||
// send client_init message
|
// send client_init message
|
||||||
let shared_flag = 0;
|
let shared_flag = 0;
|
||||||
self.outs
|
self.outbuf.push(shared_flag);
|
||||||
.push(ProtocalHandlerOutput::WsBuf(vec![shared_flag]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No. of bytes Type [Value] Description
|
// No. of bytes Type [Value] Description
|
||||||
@ -223,7 +227,7 @@ impl VncHandler {
|
|||||||
sw.write_u16(0);
|
sw.write_u16(0);
|
||||||
sw.write_u16(self.width);
|
sw.write_u16(self.width);
|
||||||
sw.write_u16(self.height);
|
sw.write_u16(self.height);
|
||||||
self.outs.push(ProtocalHandlerOutput::WsBuf(out));
|
self.outbuf.extend_from_slice(&out);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_input(&mut self) {
|
fn handle_input(&mut self) {
|
||||||
@ -251,7 +255,7 @@ impl VncHandler {
|
|||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
self.state = VncState::Handshake;
|
self.state = VncState::Handshake;
|
||||||
self.require = 4; // the length of the security type message
|
self.require = 4; // the length of the security type message
|
||||||
self.outs.push(ProtocalHandlerOutput::WsBuf(v.to_vec()));
|
self.outbuf.extend_from_slice(v);
|
||||||
}
|
}
|
||||||
Err(e) => self.disconnect_with_err(e),
|
Err(e) => self.disconnect_with_err(e),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user