Changeset 716 in code for trunk/downstream.go
- Timestamp:
- Nov 18, 2021, 8:40:23 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r711 r716 179 179 180 180 // ' ' and ':' break the IRC message wire format, '@' and '!' break prefixes, 181 // '*' and '?' break masks, '$' breaks server masks in PRIVMSG/NOTICE 181 // '*' and '?' break masks, '$' breaks server masks in PRIVMSG/NOTICE, 182 // "*" is the reserved nickname for registration 182 183 const illegalNickChars = " :@!*?$" 183 184 … … 281 282 conn: *newConn(srv, ic, &options), 282 283 id: id, 284 nick: "*", 285 nickCM: "*", 283 286 supportedCaps: make(map[string]string), 284 287 caps: make(map[string]bool), … … 685 688 if !dc.caps["sasl"] { 686 689 return ircError{&irc.Message{ 690 Prefix: dc.srv.prefix(), 687 691 Command: irc.ERR_SASLFAIL, 688 692 Params: []string{"*", "AUTHENTICATE requires the \"sasl\" capability to be enabled"}, … … 691 695 if len(msg.Params) == 0 { 692 696 return ircError{&irc.Message{ 697 Prefix: dc.srv.prefix(), 693 698 Command: irc.ERR_SASLFAIL, 694 699 Params: []string{"*", "Missing AUTHENTICATE argument"}, 695 }}696 }697 if dc.nick == "" {698 return ircError{&irc.Message{699 Command: irc.ERR_SASLFAIL,700 Params: []string{"*", "Expected NICK command before AUTHENTICATE"},701 700 }} 702 701 } … … 706 705 dc.saslServer = nil 707 706 return ircError{&irc.Message{ 707 Prefix: dc.srv.prefix(), 708 708 Command: irc.ERR_SASLABORTED, 709 709 Params: []string{"*", "SASL authentication aborted"}, … … 721 721 default: 722 722 return ircError{&irc.Message{ 723 Prefix: dc.srv.prefix(), 723 724 Command: irc.ERR_SASLFAIL, 724 725 Params: []string{"*", fmt.Sprintf("Unsupported SASL mechanism %q", mech)}, … … 734 735 dc.saslServer = nil 735 736 return ircError{&irc.Message{ 737 Prefix: dc.srv.prefix(), 736 738 Command: irc.ERR_SASLFAIL, 737 739 Params: []string{"*", "Invalid base64-encoded response"}, … … 745 747 if ircErr, ok := err.(ircError); ok && ircErr.Message.Command == irc.ERR_PASSWDMISMATCH { 746 748 return ircError{&irc.Message{ 749 Prefix: dc.srv.prefix(), 747 750 Command: irc.ERR_SASLFAIL, 748 751 Params: []string{"*", ircErr.Message.Params[1]}, … … 824 827 return newUnknownCommandError(msg.Command) 825 828 } 826 if dc.rawUsername != "" && dc.nick != " " && !dc.negotiatingCaps {829 if dc.rawUsername != "" && dc.nick != "*" && !dc.negotiatingCaps { 827 830 return dc.register(ctx) 828 831 } … … 832 835 func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error { 833 836 cmd = strings.ToUpper(cmd) 834 835 replyTo := dc.nick836 if !dc.registered {837 replyTo = "*"838 }839 837 840 838 switch cmd { … … 868 866 Prefix: dc.srv.prefix(), 869 867 Command: "CAP", 870 Params: []string{ replyTo, "LS", strings.Join(caps, " ")},868 Params: []string{dc.nick, "LS", strings.Join(caps, " ")}, 871 869 }) 872 870 … … 891 889 Prefix: dc.srv.prefix(), 892 890 Command: "CAP", 893 Params: []string{ replyTo, "LIST", strings.Join(caps, " ")},891 Params: []string{dc.nick, "LIST", strings.Join(caps, " ")}, 894 892 }) 895 893 case "REQ": … … 897 895 return ircError{&irc.Message{ 898 896 Command: err_invalidcapcmd, 899 Params: []string{ replyTo, cmd, "Missing argument in CAP REQ command"},897 Params: []string{dc.nick, cmd, "Missing argument in CAP REQ command"}, 900 898 }} 901 899 } … … 937 935 Prefix: dc.srv.prefix(), 938 936 Command: "CAP", 939 Params: []string{ replyTo, reply, args[0]},937 Params: []string{dc.nick, reply, args[0]}, 940 938 }) 941 939 … … 948 946 return ircError{&irc.Message{ 949 947 Command: err_invalidcapcmd, 950 Params: []string{ replyTo, cmd, "Unknown CAP command"},948 Params: []string{dc.nick, cmd, "Unknown CAP command"}, 951 949 }} 952 950 } … … 963 961 } 964 962 965 replyTo := dc.nick966 if !dc.registered {967 replyTo = "*"968 }969 970 963 cap := name 971 964 if value != "" && dc.capVersion >= 302 { … … 976 969 Prefix: dc.srv.prefix(), 977 970 Command: "CAP", 978 Params: []string{ replyTo, "NEW", cap},971 Params: []string{dc.nick, "NEW", cap}, 979 972 }) 980 973 } … … 989 982 } 990 983 991 replyTo := dc.nick992 if !dc.registered {993 replyTo = "*"994 }995 996 984 dc.SendMessage(&irc.Message{ 997 985 Prefix: dc.srv.prefix(), 998 986 Command: "CAP", 999 Params: []string{ replyTo, "DEL", name},987 Params: []string{dc.nick, "DEL", name}, 1000 988 }) 1001 989 }
Note:
See TracChangeset
for help on using the changeset viewer.