Remove old test code
This commit is contained in:
parent
883bc07d62
commit
4129f09c77
|
@ -955,96 +955,3 @@ pub trait PacketType: Sized {
|
|||
|
||||
fn write(self, buf: &mut io::Write) -> Result<(), io::Error>;
|
||||
}
|
||||
|
||||
// REMOVE ME
|
||||
// #[test]
|
||||
pub fn test() {
|
||||
let mut c = Conn::new("localhost:25565").unwrap();
|
||||
|
||||
c.write_packet(packet::handshake::serverbound::Handshake {
|
||||
protocol_version: VarInt(SUPPORTED_PROTOCOL),
|
||||
host: "localhost".to_owned(),
|
||||
port: 25565,
|
||||
next: VarInt(2),
|
||||
})
|
||||
.unwrap();
|
||||
c.state = State::Login;
|
||||
c.write_packet(packet::login::serverbound::LoginStart { username: "Thinkofdeath".to_owned() })
|
||||
.unwrap();
|
||||
|
||||
let packet = match c.read_packet().unwrap() {
|
||||
packet::Packet::EncryptionRequest(val) => val,
|
||||
val => panic!("Wrong packet: {:?}", val),
|
||||
};
|
||||
|
||||
let mut key = openssl::PublicKey::new(&packet.public_key.data);
|
||||
let shared = openssl::gen_random(16);
|
||||
|
||||
let shared_e = key.encrypt(&shared);
|
||||
let token_e = key.encrypt(&packet.verify_token.data);
|
||||
|
||||
let profile = mojang::Profile {
|
||||
username: "Thinkofdeath".to_owned(),
|
||||
id: "4566e69fc90748ee8d71d7ba5aa00d20".to_owned(),
|
||||
access_token: "".to_owned(),
|
||||
};
|
||||
|
||||
profile.join_server(&packet.server_id, &shared, &packet.public_key.data);
|
||||
|
||||
c.write_packet(packet::login::serverbound::EncryptionResponse {
|
||||
shared_secret: LenPrefixedBytes::new(shared_e),
|
||||
verify_token: LenPrefixedBytes::new(token_e),
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let mut read = c.clone();
|
||||
let mut write = c.clone();
|
||||
|
||||
read.enable_encyption(&shared, true);
|
||||
write.enable_encyption(&shared, false);
|
||||
|
||||
loop {
|
||||
match read.read_packet().unwrap() {
|
||||
packet::Packet::LoginDisconnect(val) => {
|
||||
panic!("Discconect {}", val.reason);
|
||||
}
|
||||
packet::Packet::SetInitialCompression(val) => {
|
||||
read.set_compresssion(val.threshold.0, true);
|
||||
write.set_compresssion(val.threshold.0, false);
|
||||
println!("Compression: {}", val.threshold.0)
|
||||
}
|
||||
packet::Packet::LoginSuccess(val) => {
|
||||
println!("Login: {} {}", val.username, val.uuid);
|
||||
read.state = State::Play;
|
||||
write.state = State::Play;
|
||||
break;
|
||||
}
|
||||
_ => panic!("Unknown packet"),
|
||||
}
|
||||
}
|
||||
|
||||
let mut first = true;
|
||||
let mut count = 0;
|
||||
loop {
|
||||
match read.read_packet().unwrap() {
|
||||
packet::Packet::ServerMessage(val) => println!("MSG: {}", val.message),
|
||||
packet::Packet::ChunkData(_) => {}
|
||||
val => {
|
||||
println!("{:?}", val);
|
||||
if first {
|
||||
write.write_packet(packet::play::serverbound::ChatMessage {
|
||||
message: "Hello world".to_owned(),
|
||||
})
|
||||
.unwrap();
|
||||
first = false;
|
||||
}
|
||||
count += 1;
|
||||
if count > 200 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unimplemented!();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue