attempt at fixing #4
This commit is contained in:
parent
a979cc25c6
commit
600a24ea79
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -9,6 +9,7 @@ dependencies = [
|
||||
"colorful",
|
||||
"lazy_static",
|
||||
"ozelot",
|
||||
"radix64",
|
||||
"serde",
|
||||
"toml",
|
||||
]
|
||||
@ -34,6 +35,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d"
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.0"
|
||||
@ -336,6 +343,16 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "radix64"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d22a338c2456e0b6ca64681985cbc1b60a50473474f224899b0ee932e244893e"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.56"
|
||||
|
@ -14,3 +14,4 @@ ozelot = "0.9.0" # Ozelot 0.9.0 supports protocol version 578 (1.15.2)
|
||||
toml = "0.5.6"
|
||||
serde = { version = "1.0.114", features = ["serde_derive"]}
|
||||
base64 = "0.12.3"
|
||||
radix64 = "0.3.0"
|
||||
|
@ -2,4 +2,4 @@ port = 25565
|
||||
protocol_version = 578
|
||||
max_players = 20
|
||||
motd = "Composition MOTD"
|
||||
favicon = "composition_icon.png"
|
||||
favicon = "server-icon.png"
|
||||
|
BIN
server-icon.png
Normal file
BIN
server-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
17
src/net.rs
17
src/net.rs
@ -3,7 +3,7 @@
|
||||
// description:
|
||||
// The module with everything to do with networkng.
|
||||
|
||||
extern crate base64;
|
||||
extern crate radix64;
|
||||
|
||||
use crate::mctypes::*;
|
||||
use crate::protocol::*;
|
||||
@ -64,18 +64,21 @@ fn handle_client(t: TcpStream) -> std::io::Result<()> {
|
||||
let (_request_packet_len, _request_packet_id) = read_packet_header(&mut gc.stream)?;
|
||||
// Send the response packet.
|
||||
let mut base64_encoded_favicon = "".to_owned();
|
||||
let a = || -> std::io::Result<String> {
|
||||
let a = || -> std::io::Result<Vec<u8>> {
|
||||
// Only call this if config.favicon is not None, or it'll panic.
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
let mut file = File::open(config.favicon.as_ref().unwrap())?;
|
||||
let mut favicon = String::new();
|
||||
file.read_to_string(&mut favicon)?;
|
||||
Ok(favicon)
|
||||
let mut buffer = Vec::new();
|
||||
file.read_to_end(&mut buffer)?;
|
||||
Ok(buffer)
|
||||
};
|
||||
if config.favicon.is_some() {
|
||||
if let Ok(s) = a() {
|
||||
base64_encoded_favicon = base64::encode(s);
|
||||
let temp = a();
|
||||
if let Ok(s) = temp {
|
||||
base64_encoded_favicon = radix64::STD.encode(&s);
|
||||
} else {
|
||||
println!("{:?}", temp);
|
||||
}
|
||||
}
|
||||
let response = MCString::from(format!("{{\n\t\"version\": {{\n\t\t\"name\": \"Composition 1.15.2\",\n\t\t\"protocol\": {}\n\t}},\n\t\"players\": {{\n\t\t\"max\": {},\n\t\t\"online\": 2147483648,\n\t\t\"sample\": [\n\t\t\t{{\n\t\t\t\t\"name\": \"fumolover12\",\n\t\t\t\t\"id\": \"4566e69f-c907-48ee-8d71-d7ba5aa00d20\"\n\t\t\t}}\n\t\t]\n\t}},\n\t\"description\": {{\n\t\t\"text\": \"{}\"\n\t}},\n\t\"favicon\": \"data:image/png;base64,{}\"\n}}", config.protocol_version, config.max_players, config.motd, base64_encoded_favicon));
|
||||
|
Loading…
x
Reference in New Issue
Block a user