From 66fd1b62907956c1d77e2d602e945ef8a9e6c6dd Mon Sep 17 00:00:00 2001 From: drumglow Date: Tue, 9 Apr 2024 19:11:42 +0200 Subject: [PATCH] fixed hello handling --- unreliable_chat_check/BrokenChatServerLocal.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/unreliable_chat_check/BrokenChatServerLocal.go b/unreliable_chat_check/BrokenChatServerLocal.go index 2cb3c7d..cd7a39f 100644 --- a/unreliable_chat_check/BrokenChatServerLocal.go +++ b/unreliable_chat_check/BrokenChatServerLocal.go @@ -369,7 +369,11 @@ func handleHello(message string, addr net.Addr, output BrokenMessageOutputStream } else { // HELLO-FROM format is correct. Enough space for new client name := match[3] if cb.IsKnown(name) { // But this username already exists - output.Send(addr, ReplyInUse) + if cb.nameToAddr[name] == addr.String(){ // check if username belongs to this address + output.Send(addr, ReplyBadHdr) + } else { + output.Send(addr, ReplyInUse) + } } else { // We don't know this user cb.Add(addr, name) output.Send(addr, "HELLO "+name+"\n") @@ -377,10 +381,8 @@ func handleHello(message string, addr net.Addr, output BrokenMessageOutputStream } } else { if match := regexDisallowedNameCharacters.FindStringSubmatch(message); match != nil { - output.Send(addr, ReplyBadHdr) - } else { output.Send(addr, ReplyBadBody) - } + } } }