~emersion/soju-dev

Allow CAP negotiation to happen with CAP REQ v1 APPLIED

Hubert Hirtz: 1
 Allow CAP negotiation to happen with CAP REQ

 1 files changed, 8 insertions(+), 4 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/25283/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] Allow CAP negotiation to happen with CAP REQ Export this patch

See https://ircv3.net/specs/extensions/capability-negotiation

> Upon receiving either a CAP LS or CAP REQ command during connection
> registration, the server MUST not complete registration until the
> client sends a CAP END command to indicate that capability negotiation
> has ended.

This commit should prevent soju from trying to authenticate the user
prior to having received AUTHENTICATE messages, when the client eagerly
requests capabilities with CAP REQ seeing available capabilities
beforehand with CAP LS.

---

Also fix a typo in downstreamConn.negociatingCaps, see
https://en.wiktionary.org/wiki/negociate

 downstream.go | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/downstream.go b/downstream.go
index 9102e5c..0369399 100644
--- a/downstream.go
+++ b/downstream.go
@@ -185,7 +185,7 @@ type downstreamConn struct {
	password    string   // empty after authentication
	network     *network // can be nil

	negociatingCaps bool
	negotiatingCaps bool
	capVersion      int
	supportedCaps   map[string]string
	caps            map[string]bool
@@ -717,7 +717,7 @@ func (dc *downstreamConn) handleMessageUnregistered(msg *irc.Message) error {
		dc.logger.Printf("unhandled message: %v", msg)
		return newUnknownCommandError(msg.Command)
	}
	if dc.rawUsername != "" && dc.nick != "" && !dc.negociatingCaps {
	if dc.rawUsername != "" && dc.nick != "" && !dc.negotiatingCaps {
		return dc.register()
	}
	return nil
@@ -770,7 +770,7 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
		}

		if !dc.registered {
			dc.negociatingCaps = true
			dc.negotiatingCaps = true
		}
	case "LIST":
		var caps []string
@@ -832,8 +832,12 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
			Command: "CAP",
			Params:  []string{replyTo, reply, args[0]},
		})

		if !dc.registered {
			dc.negotiatingCaps = true
		}
	case "END":
		dc.negociatingCaps = false
		dc.negotiatingCaps = false
	default:
		return ircError{&irc.Message{
			Command: err_invalidcapcmd,
-- 
2.33.0
Pushed, thanks for the fix!