Changeset 729 in code
- Timestamp:
- Nov 30, 2021, 11:02:54 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r727 r729 1080 1080 } 1081 1081 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 1082 1097 if _, ok := dc.user.msgStore.(chatHistoryMessageStore); ok && dc.network != nil { 1083 1098 dc.setSupportedCap("draft/event-playback", "") … … 2409 2424 if uc == nil || !uc.caps["sasl"] { 2410 2425 return ircError{&irc.Message{ 2411 Prefix: dc.srv.prefix(),2412 2426 Command: irc.ERR_SASLFAIL, 2413 2427 Params: []string{dc.nick, "Upstream network authentication not supported"}, … … 2437 2451 }) 2438 2452 } 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) 2439 2470 case "MONITOR": 2440 2471 // MONITOR is unsupported in multi-upstream mode -
trunk/upstream.go
r725 r729 36 36 "setname": true, 37 37 38 "draft/extended-monitor": true, 38 "draft/account-registration": true, 39 "draft/extended-monitor": true, 39 40 } 40 41 … … 301 302 Params: []string{dc.nick, "SASL authentication aborted"}, 302 303 }) 304 case "REGISTER", "VERIFY": 305 dc.SendMessage(&irc.Message{ 306 Prefix: dc.srv.prefix(), 307 Command: "FAIL", 308 Params: []string{pendingCmd.msg.Command, "TEMPORARILY_UNAVAILABLE", pendingCmd.msg.Params[0], "Command aborted"}, 309 }) 303 310 default: 304 311 panic(fmt.Errorf("Unsupported pending command %q", pendingCmd.msg.Command)) … … 319 326 func (uc *upstreamConn) enqueueCommand(dc *downstreamConn, msg *irc.Message) { 320 327 switch msg.Command { 321 case "LIST", "WHO", "AUTHENTICATE" :328 case "LIST", "WHO", "AUTHENTICATE", "REGISTER", "VERIFY": 322 329 // Supported 323 330 default: … … 633 640 Params: []string{"END"}, 634 641 }) 642 } 643 case "REGISTER", "VERIFY": 644 if dc, cmd := uc.dequeueCommand(msg.Command); dc != nil { 645 if msg.Command == "REGISTER" { 646 var account, password string 647 if err := parseMessageParams(msg, nil, &account); err != nil { 648 return err 649 } 650 if err := parseMessageParams(cmd, nil, nil, &password); err != nil { 651 return err 652 } 653 uc.network.autoSaveSASLPlain(context.TODO(), account, password) 654 } 655 656 dc.SendMessage(msg) 635 657 } 636 658 case irc.RPL_WELCOME: … … 1570 1592 } 1571 1593 1572 if command == "LIST" || command == "WHO" { 1573 dc, _ := uc.dequeueCommand(command) 1574 if dc != nil && downstreamID == 0 { 1575 downstreamID = dc.id 1576 } 1594 if dc, _ := uc.dequeueCommand(command); dc != nil && downstreamID == 0 { 1595 downstreamID = dc.id 1577 1596 } 1578 1597 … … 1583 1602 Params: []string{dc.nick, command, reason}, 1584 1603 }) 1604 }) 1605 case "FAIL": 1606 var command string 1607 if err := parseMessageParams(msg, &command); err != nil { 1608 return err 1609 } 1610 1611 if dc, _ := uc.dequeueCommand(command); dc != nil && downstreamID == 0 { 1612 downstreamID = dc.id 1613 } 1614 1615 uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) { 1616 dc.SendMessage(msg) 1585 1617 }) 1586 1618 case "ACK":
Note:
See TracChangeset
for help on using the changeset viewer.