From 348e6da1fc638586851f8f794b24ea9fc68cd271 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 3 Mar 2022 08:35:34 +0100 Subject: [PATCH] downstream: be less strict when picking up client name Allow e.g. the SASL username to contain "username/network" and the raw username to contain "username@client", for instance. --- downstream.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/downstream.go b/downstream.go index 63940d0..04f2d9e 100644 --- a/downstream.go +++ b/downstream.go @@ -1287,8 +1287,12 @@ func (dc *downstreamConn) register(ctx context.Context) error { } } - if dc.clientName == "" && dc.networkName == "" { - _, dc.clientName, dc.networkName = unmarshalUsername(dc.rawUsername) + _, fallbackClientName, fallbackNetworkName := unmarshalUsername(dc.rawUsername) + if dc.clientName == "" { + dc.clientName = fallbackClientName + } + if dc.networkName == "" { + dc.networkName = fallbackNetworkName } dc.registered = true