commit ccc5351
Hubert Hirtz
·
2021-11-16 08:51:31 +0000 UTC
parent aef7703
Also retrieve username on registration
1 files changed,
+10,
-9
+10,
-9
1@@ -493,13 +493,15 @@ func (s *Session) handleUnregistered(msg Message) (Event, error) {
2 s.out <- NewMessage("AUTHENTICATE", res)
3 }
4 case rplLoggedin:
5- var userhost string
6- if err := msg.ParseParams(nil, &userhost, &s.acct); err != nil {
7+ var nuh string
8+ if err := msg.ParseParams(nil, &nuh, &s.acct); err != nil {
9 return nil, err
10 }
11
12 s.endRegistration()
13- s.host = ParsePrefix(userhost).Host
14+ prefix := ParsePrefix(nuh)
15+ s.user = prefix.User
16+ s.host = prefix.Host
17 case errNicklocked, errSaslfail, errSasltoolong, errSaslaborted, errSaslalready, rplSaslmechs:
18 s.endRegistration()
19 case errNicknameinuse:
20@@ -553,15 +555,16 @@ func (s *Session) handleRegistered(msg Message) (Event, error) {
21 }
22 s.updateFeatures(msg.Params[1 : len(msg.Params)-1])
23 case rplWhoreply:
24- var nick, host, stats string
25- if err := msg.ParseParams(nil, nil, nil, &host, nil, &nick, &stats, nil); err != nil {
26+ var nick, host, flags, username string
27+ if err := msg.ParseParams(nil, nil, &username, &host, nil, &nick, &flags, nil); err != nil {
28 return nil, err
29 }
30
31 nickCf := s.Casemap(nick)
32- away := stats[0] == 'G' // stats is not empty because it's not the trailing parameter
33+ away := flags[0] == 'G' // flags is not empty because it's not the trailing parameter
34
35 if s.nickCf == nickCf {
36+ s.user = username
37 s.host = host
38 }
39
40@@ -1203,9 +1206,7 @@ func (s *Session) updateFeatures(features []string) {
41 func (s *Session) endRegistration() {
42 if _, ok := s.enabledCaps["soju.im/bouncer-networks"]; !ok {
43 s.out <- NewMessage("CAP", "END")
44- return
45- }
46- if s.netID == "" {
47+ } else if s.netID == "" {
48 s.out <- NewMessage("CAP", "END")
49 s.out <- NewMessage("BOUNCER", "LISTNETWORKS")
50 } else {