~emersion/soju-dev

downstream: Start bouncer on first auth for users added out-of-process v1 PROPOSED

mooff: 1
 downstream: Start bouncer on first auth for users added out-of-process

 2 files changed, 9 insertions(+), 5 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/26042/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] downstream: Start bouncer on first auth for users added out-of-process Export this patch

From: mooff <soju@cyberspace.baby>

---
 downstream.go | 10 +++++-----
 server.go     |  4 ++++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/downstream.go b/downstream.go
index 2d089b0..a0d75b9 100644
--- a/downstream.go
+++ b/downstream.go
@@ -1064,11 +1064,11 @@ func (dc *downstreamConn) authenticate(username, password string) error {
		return errAuthFailed
	}

	dc.user = dc.srv.getUser(username)
	if dc.user == nil {
		dc.logger.Printf("failed authentication for %q: user not active", username)
		return errAuthFailed
	}
	dc.srv.lock.Lock()
	defer dc.srv.lock.Unlock()

	dc.user = dc.srv.addUserLocked(u)

	dc.clientName = clientName
	dc.networkName = networkName
	return nil
diff --git a/server.go b/server.go
index 7f853cd..7fe6b03 100644
--- a/server.go
+++ b/server.go
@@ -153,6 +153,10 @@ func (s *Server) getUser(name string) *user {
}

func (s *Server) addUserLocked(user *User) *user {
	if u, ok := s.users[user.Username]; ok {
		return u
	}

	s.Logger.Printf("starting bouncer for user %q", user.Username)
	u := newUser(s, user)
	s.users[u.Username] = u
-- 
2.30.2
emersion already rejected this patch :s

https://lists.sr.ht/~emersion/soju-dev/patches/25249