Changeset 700 in code
- Timestamp:
- Nov 17, 2021, 11:29:23 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r699 r700 629 629 630 630 func (dc *downstreamConn) handleMessageUnregistered(msg *irc.Message) error { 631 ctx, cancel := context.WithTimeout(context.TODO(), handleDownstreamMessageTimeout) 632 defer cancel() 633 631 634 switch msg.Command { 632 635 case "NICK": … … 698 701 case "PLAIN": 699 702 dc.saslServer = sasl.NewPlainServer(sasl.PlainAuthenticator(func(identity, username, password string) error { 700 return dc.authenticate(username, password) 703 // TODO: we can't use the command context here, because it 704 // gets cancelled once the command handler returns. SASL 705 // might take multiple AUTHENTICATE commands to complete. 706 return dc.authenticate(context.TODO(), username, password) 701 707 })) 702 708 default: … … 806 812 } 807 813 if dc.rawUsername != "" && dc.nick != "" && !dc.negotiatingCaps { 808 return dc.register( )814 return dc.register(ctx) 809 815 } 810 816 return nil … … 1069 1075 } 1070 1076 1071 func (dc *downstreamConn) authenticate( username, password string) error {1077 func (dc *downstreamConn) authenticate(ctx context.Context, username, password string) error { 1072 1078 username, clientName, networkName := unmarshalUsername(username) 1073 1079 1074 u, err := dc.srv.db.GetUser(c ontext.TODO(), username)1080 u, err := dc.srv.db.GetUser(ctx, username) 1075 1081 if err != nil { 1076 1082 dc.logger.Printf("failed authentication for %q: user not found: %v", username, err) … … 1099 1105 } 1100 1106 1101 func (dc *downstreamConn) register( ) error {1107 func (dc *downstreamConn) register(ctx context.Context) error { 1102 1108 if dc.registered { 1103 1109 return fmt.Errorf("tried to register twice") … … 1107 1113 dc.password = "" 1108 1114 if dc.user == nil { 1109 if err := dc.authenticate( dc.rawUsername, password); err != nil {1115 if err := dc.authenticate(ctx, dc.rawUsername, password); err != nil { 1110 1116 return err 1111 1117 }
Note:
See TracChangeset
for help on using the changeset viewer.