From 7a12dfb51d2a176a4bfb08b336557e65e528a0d5 Mon Sep 17 00:00:00 2001 From: MeexReay Date: Thu, 14 Nov 2024 13:25:24 +0300 Subject: [PATCH] connection fix --- Cargo.lock | 46 +++++++++++++++++++------------------- config.yml | 4 ++-- src/meexprox/connection.rs | 5 ++++- src/meexprox/error.rs | 11 +++++++-- src/meexprox/meexprox.rs | 3 ++- 5 files changed, 40 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2aa9919..8781fda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "ignore-result" @@ -92,9 +92,9 @@ checksum = "665ff4dce8edd10d490641ccb78949832f1ddbff02c584fb1f85ab888fe0e50c" [[package]] name = "indexmap" -version = "2.2.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", "hashbrown", @@ -117,9 +117,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libyml" @@ -188,18 +188,18 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -216,7 +216,7 @@ dependencies = [ [[package]] name = "rust_mc_proto" version = "0.1.16" -source = "git+https://github.com/MeexReay/rust_mc_proto#26a78af446bd7ceba54fa2fa34d2f6570e827904" +source = "git+https://github.com/MeexReay/rust_mc_proto#abe738aad5aed4f3dffc121f508ce081a50784bb" dependencies = [ "bytebuffer", "flate2", @@ -231,18 +231,18 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -277,9 +277,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.71" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -330,9 +330,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "uuid" @@ -348,18 +348,18 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ "windows-sys", ] [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] diff --git a/config.yml b/config.yml index bfb7217..040c293 100644 --- a/config.yml +++ b/config.yml @@ -7,13 +7,13 @@ messaging: # messaging server (optional) servers: play: # server internal name - host: 127.0.0.1:12345 # server host + host: sloganmc.ru:25565 # server host domains: - _ # means that this server is default to connect players - play.localhost - mc.localhost forwarding: # player forwarding - enabled: true + enabled: false type: velocity secret: "123456" diff --git a/src/meexprox/connection.rs b/src/meexprox/connection.rs index aefbe55..39618f9 100644 --- a/src/meexprox/connection.rs +++ b/src/meexprox/connection.rs @@ -1,6 +1,7 @@ use std::{net::{SocketAddr, TcpStream}, sync::{Arc, Mutex}, thread}; use ignore_result::Ignore; +use log::debug; use rust_mc_proto::{DataBufferReader, DataBufferWriter, MCConnTcp, Packet, ProtocolError}; use uuid::Uuid; @@ -118,6 +119,7 @@ impl Player { } 0x02 => { player.write_client_packet(&packet)?; + // player.write_server_packet(&player.read_client_packet()?)?; break; } 0x03 => { @@ -142,9 +144,10 @@ impl Player { verify_token }); - player.write_server_packet(&player.read_client_packet()?)?; + debug!("player connected"); player.client_recv_loop(); + player.server_recv_loop(); Ok(player) } diff --git a/src/meexprox/error.rs b/src/meexprox/error.rs index 7e9dfcf..caefb49 100644 --- a/src/meexprox/error.rs +++ b/src/meexprox/error.rs @@ -8,7 +8,8 @@ pub enum ProxyError { HandshakePacket, LoginPacket, PeerAddr, - ProtocolError(ProtocolError) + ProtocolError(ProtocolError), + ConnectionClosed } impl std::fmt::Display for ProxyError { @@ -29,7 +30,13 @@ pub trait AsProxyResult { impl AsProxyError for ProtocolError { fn as_proxy(self) -> ProxyError { - ProxyError::ProtocolError(self) + match self { + Self::ConnectionClosedError => { + ProxyError::ConnectionClosed + }, i => { + ProxyError::ProtocolError(i) + } + } } } diff --git a/src/meexprox/meexprox.rs b/src/meexprox/meexprox.rs index d38efa7..002c1a5 100644 --- a/src/meexprox/meexprox.rs +++ b/src/meexprox/meexprox.rs @@ -1,4 +1,4 @@ -use log::{error, info}; +use log::{debug, error, info}; use rust_mc_proto::{ read_packet, write_packet, DataBufferReader, DataBufferWriter, MCConnTcp, Packet }; @@ -117,6 +117,7 @@ impl MeexProx { Ok(_) => {} Err(e) => { error!("connection error: {:?}", e); + } }; });