diff --git a/log.txt b/log.txt index 7b0d106..45601c8 100644 --- a/log.txt +++ b/log.txt @@ -220,3 +220,97 @@ 2020-07-08 21:23:13 [INFO] - Next state: Status 2020-07-08 21:23:13 [INFO] - Ping number: MCLong { value: 7487517 } 2020-07-08 21:23:13 [INFO] - Client at 127.0.0.1:55872 closed connection +2020-07-08 21:08:05 [INFO] - Network thread started +2020-07-08 21:08:05 [IMPORTANT] - Started server on 0.0.0.0:25565 +2020-07-08 21:08:19 [INFO] - Got a client! +2020-07-08 21:08:19 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:08:19 [INFO] - Next state: Closed +2020-07-08 21:08:19 [INFO] - Client at 192.168.0.88:55408 closed connection +2020-07-08 21:08:19 [INFO] - Got a client! +2020-07-08 21:08:19 [INFO] - Handshake { protocol_version: MCVarInt { value: 11 }, server_address: MCString { value: "" }, server_port: MCUnsignedShort { value: 19712 }, next_state: MCVarInt { value: 67 } } +2020-07-08 21:08:19 [INFO] - Next state: Closed +2020-07-08 21:08:19 [INFO] - Client at 192.168.0.88:55409 closed connection +2020-07-08 21:08:59 [INFO] - Got a client! +2020-07-08 21:08:59 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:08:59 [INFO] - Next state: Closed +2020-07-08 21:08:59 [INFO] - Client at 192.168.0.88:55414 closed connection +2020-07-08 21:08:59 [INFO] - Got a client! +2020-07-08 21:08:59 [INFO] - Handshake { protocol_version: MCVarInt { value: 11 }, server_address: MCString { value: "" }, server_port: MCUnsignedShort { value: 19712 }, next_state: MCVarInt { value: 67 } } +2020-07-08 21:08:59 [INFO] - Next state: Closed +2020-07-08 21:08:59 [INFO] - Client at 192.168.0.88:55415 closed connection +2020-07-08 21:09:06 [INFO] - Got a client! +2020-07-08 21:09:06 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 2 } } +2020-07-08 21:09:06 [INFO] - Next state: Closed +2020-07-08 21:09:06 [INFO] - Client at 192.168.0.88:55416 closed connection +2020-07-08 21:10:30 [INFO] - Got a client! +2020-07-08 21:10:30 [INFO] - Handshake { protocol_version: MCVarInt { value: 578 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:10:30 [INFO] - Next state: Status +2020-07-08 21:10:30 [INFO] - Ping number: MCLong { value: 28962 } +2020-07-08 21:10:30 [INFO] - Client at 192.168.0.88:55679 closed connection +2020-07-08 21:12:50 [INFO] - Network thread started +2020-07-08 21:12:50 [IMPORTANT] - Started server on 0.0.0.0:25565 +2020-07-08 21:12:58 [INFO] - Got a client! +2020-07-08 21:12:58 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:12:58 [INFO] - Next state: Status +2020-07-08 21:12:58 [INFO] - Ping number: MCLong { value: 177626 } +2020-07-08 21:12:58 [INFO] - Client at 192.168.0.88:55688 closed connection +2020-07-08 21:13:23 [INFO] - Got a client! +2020-07-08 21:13:23 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 2 } } +2020-07-08 21:13:23 [INFO] - Next state: Status +2020-07-08 21:13:23 [INFO] - Ping number: MCLong { value: 8029147796280267361 } +2020-07-08 21:13:23 [INFO] - Client at 192.168.0.88:55689 closed connection +2020-07-08 21:16:48 [INFO] - Network thread started +2020-07-08 21:16:48 [IMPORTANT] - Started server on 0.0.0.0:25565 +2020-07-08 21:17:03 [INFO] - Got a client! +2020-07-08 21:17:03 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:17:03 [INFO] - Next state: Status +2020-07-08 21:17:03 [INFO] - Ping number: MCLong { value: 422535 } +2020-07-08 21:17:03 [INFO] - Client at 192.168.0.88:55700 closed connection +2020-07-08 21:17:50 [INFO] - Got a client! +2020-07-08 21:17:50 [INFO] - Handshake { protocol_version: MCVarInt { value: 578 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:17:50 [INFO] - Next state: Status +2020-07-08 21:17:50 [INFO] - Ping number: MCLong { value: 469501 } +2020-07-08 21:17:50 [INFO] - Client at 192.168.0.88:55706 closed connection +2020-07-08 21:18:17 [INFO] - Network thread started +2020-07-08 21:18:17 [IMPORTANT] - Started server on 0.0.0.0:25565 +2020-07-08 21:18:24 [INFO] - Got a client! +2020-07-08 21:18:24 [INFO] - Handshake { protocol_version: MCVarInt { value: 578 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:18:24 [INFO] - Next state: Status +2020-07-08 21:18:24 [INFO] - Ping number: MCLong { value: 503077 } +2020-07-08 21:18:24 [INFO] - Client at 192.168.0.88:55712 closed connection +2020-07-08 21:18:31 [INFO] - Got a client! +2020-07-08 21:18:31 [INFO] - Handshake { protocol_version: MCVarInt { value: 47 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:18:31 [INFO] - Next state: Status +2020-07-08 21:18:32 [INFO] - Ping number: MCLong { value: 510863 } +2020-07-08 21:18:32 [INFO] - Client at 192.168.0.88:55718 closed connection +2020-07-08 21:18:40 [INFO] - Got a client! +2020-07-08 21:18:40 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:18:40 [INFO] - Next state: Status +2020-07-08 21:18:40 [INFO] - Ping number: MCLong { value: 519010 } +2020-07-08 21:18:40 [INFO] - Client at 192.168.0.88:55724 closed connection +2020-07-08 21:19:16 [INFO] - Got a client! +2020-07-08 21:19:16 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 2 } } +2020-07-08 21:19:16 [INFO] - Next state: Status +2020-07-08 21:19:16 [INFO] - Ping number: MCLong { value: 8029147796280267361 } +2020-07-08 21:19:16 [INFO] - Client at 192.168.0.88:55726 closed connection +2020-07-08 21:21:09 [INFO] - Got a client! +2020-07-08 21:21:09 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 2 } } +2020-07-08 21:21:09 [INFO] - Next state: Status +2020-07-08 21:21:09 [INFO] - Ping number: MCLong { value: 8029147796280267361 } +2020-07-08 21:21:09 [INFO] - Client at 192.168.0.88:55732 closed connection +2020-07-08 21:22:38 [INFO] - Network thread started +2020-07-08 21:22:38 [IMPORTANT] - Started server on 0.0.0.0:25565 +2020-07-08 21:22:48 [INFO] - Got a client! +2020-07-08 21:22:48 [INFO] - Handshake { protocol_version: MCVarInt { value: 578 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:22:48 [INFO] - Next state: Status +2020-07-08 21:22:48 [INFO] - Ping number: MCLong { value: 767030 } +2020-07-08 21:22:48 [INFO] - Client at 192.168.0.88:55738 closed connection +2020-07-08 21:23:06 [INFO] - Got a client! +2020-07-08 21:23:06 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 1 } } +2020-07-08 21:23:06 [INFO] - Next state: Status +2020-07-08 21:23:06 [INFO] - Ping number: MCLong { value: 785172 } +2020-07-08 21:23:06 [INFO] - Client at 192.168.0.88:55744 closed connection +2020-07-08 21:23:12 [INFO] - Got a client! +2020-07-08 21:23:12 [INFO] - Handshake { protocol_version: MCVarInt { value: 736 }, server_address: MCString { value: "192.168.0.98" }, server_port: MCUnsignedShort { value: 25565 }, next_state: MCVarInt { value: 2 } } +2020-07-08 21:23:12 [INFO] - Next state: Closed +2020-07-08 21:23:12 [INFO] - Client at 192.168.0.88:55745 closed connection diff --git a/src/net.rs b/src/net.rs index d18f431..5c85d8b 100644 --- a/src/net.rs +++ b/src/net.rs @@ -5,7 +5,7 @@ use crate::mctypes::*; use crate::protocol::*; pub fn start_listening() { - let server_address: &str = &format!("127.0.0.1:{}", config.port); + let server_address: &str = &format!("0.0.0.0:{}", config.port); let listener = TcpListener::bind(server_address); if listener.is_err() { log.error("Could not start listener"); @@ -39,7 +39,7 @@ fn handle_client(t: TcpStream) -> std::io::Result<()> { let (_packet_len, packet_id) = read_packet_header(&mut gc.stream)?; let handshake = Handshake::read(&mut gc.stream)?; log.info(&format!("{:?}", handshake)); - gc.state = if handshake.protocol_version.value != config.protocol_version as i32 { + gc.state = if handshake.protocol_version.value != config.protocol_version as i32 && handshake.next_state.value == 2 { GameState::Closed } else { match handshake.next_state.value { @@ -58,7 +58,7 @@ fn handle_client(t: TcpStream) -> std::io::Result<()> { let response = MCString::from( r#"{ "version": { - "name": "1.15.2", + "name": "Composition Alpha 1.15.2", "protocol": 578 }, "players": {