File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
mc-server-wrapper-lib/src Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -64,14 +64,21 @@ impl ConsoleMsgSpecific {
6464 ConsoleMsgSpecific :: PlayerAuth { name, uuid }
6565 } else if console_msg. msg_type == ConsoleMsgType :: Info
6666 && ( console_msg. thread_name . starts_with ( "Async Chat Thread" )
67- || console_msg. msg . starts_with ( '<' ) && console_msg. thread_name == "Server thread" )
67+ || ( console_msg. msg . starts_with ( '<' )
68+ || console_msg. msg . starts_with ( "[Not Secure]" ) )
69+ && console_msg. thread_name == "Server thread" )
6870 {
6971 let ( name, msg) = {
70- let ( name, remain) = console_msg
72+ // trim prefix from insecure messages.
73+ let msg = console_msg
7174 . msg
75+ . strip_prefix ( "[Not Secure] " )
76+ . unwrap_or ( & console_msg. msg ) ;
77+
78+ let ( name, remain) = msg
7279 // If a > cannot be found, this is not a player message
7380 // and therefore we return
74- . split_at ( console_msg . msg . find ( '>' ) ?) ;
81+ . split_at ( msg. find ( '>' ) ?) ;
7582
7683 // Trim "<" from the player's name and "> " from the msg
7784 ( name[ 1 ..] . to_string ( ) , remain[ 2 ..] . to_string ( ) )
Original file line number Diff line number Diff line change @@ -77,6 +77,21 @@ fn player_msg() {
7777 }
7878}
7979
80+ #[ test]
81+ fn insecure_player_msg ( ) {
82+ let msg = "[19:19:48] [Server thread/INFO]: [Not Secure] <despiuvas> hello world! :)" ;
83+ let specific_msg =
84+ ConsoleMsgSpecific :: try_parse_from ( & ConsoleMsg :: try_parse_from ( msg) . unwrap ( ) ) . unwrap ( ) ;
85+
86+ match specific_msg {
87+ ConsoleMsgSpecific :: PlayerMsg { name, msg } => {
88+ assert_eq ! ( name, "despiuvas" ) ;
89+ assert_eq ! ( msg, "hello world! :)" ) ;
90+ }
91+ _ => unreachable ! ( ) ,
92+ }
93+ }
94+
8095#[ test]
8196fn player_login ( ) {
8297 let msg = "[23:11:12] [Server thread/INFO]: Cldfire[/127.0.0.1:56538] logged in with entity \
You can’t perform that action at this time.
0 commit comments