Changeset 729 in code for trunk/downstream.go


Ignore:
Timestamp:
Nov 30, 2021, 11:02:54 AM (4 years ago)
Author:
contact
Message:

Add support for draft/account-registration proxying

This adds support for the draft/account-registration extension [1].
This allows downstreams to register on upstream networks.

[1]: https://ircv3.net/specs/extensions/account-registration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r727 r729  
    10801080        }
    10811081
     1082        if uc := dc.upstream(); uc != nil && uc.caps["draft/account-registration"] {
     1083                // Strip "before-connect", because we require downstreams to be fully
     1084                // connected before attempting account registration.
     1085                values := strings.Split(uc.supportedCaps["draft/account-registration"], ",")
     1086                for i, v := range values {
     1087                        if v == "before-connect" {
     1088                                values = append(values[:i], values[i+1:]...)
     1089                                break
     1090                        }
     1091                }
     1092                dc.setSupportedCap("draft/account-registration", strings.Join(values, ","))
     1093        } else {
     1094                dc.unsetSupportedCap("draft/account-registration")
     1095        }
     1096
    10821097        if _, ok := dc.user.msgStore.(chatHistoryMessageStore); ok && dc.network != nil {
    10831098                dc.setSupportedCap("draft/event-playback", "")
     
    24092424                if uc == nil || !uc.caps["sasl"] {
    24102425                        return ircError{&irc.Message{
    2411                                 Prefix:  dc.srv.prefix(),
    24122426                                Command: irc.ERR_SASLFAIL,
    24132427                                Params:  []string{dc.nick, "Upstream network authentication not supported"},
     
    24372451                        })
    24382452                }
     2453        case "REGISTER", "VERIFY":
     2454                // Check number of params here, since we'll use that to save the
     2455                // credentials on command success
     2456                if (msg.Command == "REGISTER" && len(msg.Params) < 3) || (msg.Command == "VERIFY" && len(msg.Params) < 2) {
     2457                        return newNeedMoreParamsError(msg.Command)
     2458                }
     2459
     2460                uc := dc.upstream()
     2461                if uc == nil || !uc.caps["draft/account-registration"] {
     2462                        return ircError{&irc.Message{
     2463                                Command: "FAIL",
     2464                                Params:  []string{msg.Command, "TEMPORARILY_UNAVAILABLE", "*", "Upstream network account registration not supported"},
     2465                        }}
     2466                }
     2467
     2468                uc.logger.Printf("starting %v with account name %v", msg.Command, msg.Params[0])
     2469                uc.enqueueCommand(dc, msg)
    24392470        case "MONITOR":
    24402471                // MONITOR is unsupported in multi-upstream mode
Note: See TracChangeset for help on using the changeset viewer.