From a6ed9109339fb6b5433c8641ccb3736ad1646fc0 Mon Sep 17 00:00:00 2001 From: "." <.@.> Date: Sun, 8 May 2016 13:29:20 +1200 Subject: [PATCH] support bad USER/NICK order for Lite IRC, set realname as the nmdc description --HG-- branch : nmdc-ircfrontend --- COMPATIBILITY.txt | 1 + server.go | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/COMPATIBILITY.txt b/COMPATIBILITY.txt index aeef6b3..14d27b2 100644 --- a/COMPATIBILITY.txt +++ b/COMPATIBILITY.txt @@ -23,6 +23,7 @@ Unusable: 2016/05/07 22:57:04 <<< :Your nickname is already being used KILL A 2016/05/07 22:57:04 >>> 'NICK' [pineapple420] 2016/05/07 22:57:04 Broken loop. + - some patches in place, needs retesting Yaaic/Atomic - doesn't properly understand/parse the room join Atomic diff --git a/server.go b/server.go index afd2084..7ac0fae 100644 --- a/server.go +++ b/server.go @@ -306,6 +306,11 @@ func (s *Server) handleCommand(command string, args []string) { if s.upstreamLauncher.Self.Nick == "" { // allow set, as part of the login phase s.upstreamLauncher.Self.Nick = args[0] + + } else if args[0] == s.upstreamLauncher.Self.Nick { + // Ignore + // Required for compatibility with Lite IRC, which sends USER/NICK in the wrong order + } else { s.reply(rplKill, "Can't change nicks on this server", "") s.DisconnectClient() @@ -322,9 +327,15 @@ func (s *Server) handleCommand(command string, args []string) { } if s.upstreamLauncher.Self.Nick == "" { - s.reply(rplKill, "Your nickname is already being used", "") - s.DisconnectClient() - return + // Whatever, treat it as a NICK call (non-strict client handshake) and take the username field to be the intended nick + // This will allow Lite IRC's bad handshake to log in (as long as the username and the nickname are the same) + s.upstreamLauncher.Self.Nick = args[0] + } + + // Use the client's {real name} field as an NMDC {description} + if len(args) >= 4 && len(args[3]) > 0 && args[3][0] == ':' { + realName := strings.Join(args[3:], " ")[1:] + s.upstreamLauncher.Self.Description = realName } s.reply(rplWelcome)