|
@@ -78,6 +78,7 @@ type Server struct {
|
78
|
78
|
accountAuthenticationEnabled bool
|
79
|
79
|
accountRegistration *AccountRegistration
|
80
|
80
|
accounts map[string]*ClientAccount
|
|
81
|
+ batches *BatchManager
|
81
|
82
|
channelRegistrationEnabled bool
|
82
|
83
|
channels *ChannelManager
|
83
|
84
|
channelRegistry *ChannelRegistry
|
|
@@ -138,6 +139,7 @@ func NewServer(config *Config, logger *logger.Manager) (*Server, error) {
|
138
|
139
|
// initialize data structures
|
139
|
140
|
server := &Server{
|
140
|
141
|
accounts: make(map[string]*ClientAccount),
|
|
142
|
+ batches: NewBatchManager(),
|
141
|
143
|
channels: NewChannelManager(),
|
142
|
144
|
clients: NewClientManager(),
|
143
|
145
|
connectionLimiter: connection_limits.NewLimiter(),
|
|
@@ -972,8 +974,12 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
972
|
974
|
masksString = msg.Params[0]
|
973
|
975
|
}
|
974
|
976
|
|
|
977
|
+ rb := NewResponseBuffer(client)
|
|
978
|
+ rb.Label = GetLabel(msg)
|
|
979
|
+
|
975
|
980
|
if len(strings.TrimSpace(masksString)) < 1 {
|
976
|
|
- client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("No masks given"))
|
|
981
|
+ rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.nick, msg.Command, client.t("No masks given"))
|
|
982
|
+ rb.Send()
|
977
|
983
|
return false
|
978
|
984
|
}
|
979
|
985
|
|
|
@@ -982,16 +988,16 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
982
|
988
|
for _, mask := range masks {
|
983
|
989
|
casefoldedMask, err := Casefold(mask)
|
984
|
990
|
if err != nil {
|
985
|
|
- client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
|
|
991
|
+ rb.Add(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
|
986
|
992
|
continue
|
987
|
993
|
}
|
988
|
994
|
matches := server.clients.FindAll(casefoldedMask)
|
989
|
995
|
if len(matches) == 0 {
|
990
|
|
- client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
|
|
996
|
+ rb.Add(nil, client.server.name, ERR_NOSUCHNICK, client.nick, mask, client.t("No such nick"))
|
991
|
997
|
continue
|
992
|
998
|
}
|
993
|
999
|
for mclient := range matches {
|
994
|
|
- client.getWhoisOf(mclient)
|
|
1000
|
+ client.getWhoisOf(mclient, rb)
|
995
|
1001
|
}
|
996
|
1002
|
}
|
997
|
1003
|
} else {
|
|
@@ -999,41 +1005,42 @@ func whoisHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
999
|
1005
|
casefoldedMask, err := Casefold(strings.Split(masksString, ",")[0])
|
1000
|
1006
|
mclient := server.clients.Get(casefoldedMask)
|
1001
|
1007
|
if err != nil || mclient == nil {
|
1002
|
|
- client.Send(nil, client.server.name, ERR_NOSUCHNICK, client.nick, masksString, client.t("No such nick"))
|
|
1008
|
+ rb.Add(nil, client.server.name, ERR_NOSUCHNICK, client.nick, masksString, client.t("No such nick"))
|
1003
|
1009
|
// fall through, ENDOFWHOIS is always sent
|
1004
|
1010
|
} else {
|
1005
|
|
- client.getWhoisOf(mclient)
|
|
1011
|
+ client.getWhoisOf(mclient, rb)
|
1006
|
1012
|
}
|
1007
|
1013
|
}
|
1008
|
|
- client.Send(nil, server.name, RPL_ENDOFWHOIS, client.nick, masksString, client.t("End of /WHOIS list"))
|
|
1014
|
+ rb.Add(nil, server.name, RPL_ENDOFWHOIS, client.nick, masksString, client.t("End of /WHOIS list"))
|
|
1015
|
+ rb.Send()
|
1009
|
1016
|
return false
|
1010
|
1017
|
}
|
1011
|
1018
|
|
1012
|
|
-func (client *Client) getWhoisOf(target *Client) {
|
|
1019
|
+func (client *Client) getWhoisOf(target *Client, rb *ResponseBuffer) {
|
1013
|
1020
|
target.stateMutex.RLock()
|
1014
|
1021
|
defer target.stateMutex.RUnlock()
|
1015
|
1022
|
|
1016
|
|
- client.Send(nil, client.server.name, RPL_WHOISUSER, client.nick, target.nick, target.username, target.hostname, "*", target.realname)
|
|
1023
|
+ rb.Add(nil, client.server.name, RPL_WHOISUSER, client.nick, target.nick, target.username, target.hostname, "*", target.realname)
|
1017
|
1024
|
|
1018
|
1025
|
whoischannels := client.WhoisChannelsNames(target)
|
1019
|
1026
|
if whoischannels != nil {
|
1020
|
|
- client.Send(nil, client.server.name, RPL_WHOISCHANNELS, client.nick, target.nick, strings.Join(whoischannels, " "))
|
|
1027
|
+ rb.Add(nil, client.server.name, RPL_WHOISCHANNELS, client.nick, target.nick, strings.Join(whoischannels, " "))
|
1021
|
1028
|
}
|
1022
|
1029
|
if target.class != nil {
|
1023
|
|
- client.Send(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, target.whoisLine)
|
|
1030
|
+ rb.Add(nil, client.server.name, RPL_WHOISOPERATOR, client.nick, target.nick, target.whoisLine)
|
1024
|
1031
|
}
|
1025
|
1032
|
if client.flags[Operator] || client == target {
|
1026
|
|
- client.Send(nil, client.server.name, RPL_WHOISACTUALLY, client.nick, target.nick, fmt.Sprintf("%s@%s", target.username, utils.LookupHostname(target.IPString())), target.IPString(), client.t("Actual user@host, Actual IP"))
|
|
1033
|
+ rb.Add(nil, client.server.name, RPL_WHOISACTUALLY, client.nick, target.nick, fmt.Sprintf("%s@%s", target.username, utils.LookupHostname(target.IPString())), target.IPString(), client.t("Actual user@host, Actual IP"))
|
1027
|
1034
|
}
|
1028
|
1035
|
if target.flags[TLS] {
|
1029
|
|
- client.Send(nil, client.server.name, RPL_WHOISSECURE, client.nick, target.nick, client.t("is using a secure connection"))
|
|
1036
|
+ rb.Add(nil, client.server.name, RPL_WHOISSECURE, client.nick, target.nick, client.t("is using a secure connection"))
|
1030
|
1037
|
}
|
1031
|
1038
|
accountName := target.AccountName()
|
1032
|
1039
|
if accountName != "" {
|
1033
|
|
- client.Send(nil, client.server.name, RPL_WHOISACCOUNT, client.nick, accountName, client.t("is logged in as"))
|
|
1040
|
+ rb.Add(nil, client.server.name, RPL_WHOISACCOUNT, client.nick, accountName, client.t("is logged in as"))
|
1034
|
1041
|
}
|
1035
|
1042
|
if target.flags[Bot] {
|
1036
|
|
- client.Send(nil, client.server.name, RPL_WHOISBOT, client.nick, target.nick, ircfmt.Unescape(fmt.Sprintf(client.t("is a $bBot$b on %s"), client.server.networkName)))
|
|
1043
|
+ rb.Add(nil, client.server.name, RPL_WHOISBOT, client.nick, target.nick, ircfmt.Unescape(fmt.Sprintf(client.t("is a $bBot$b on %s"), client.server.networkName)))
|
1037
|
1044
|
}
|
1038
|
1045
|
|
1039
|
1046
|
if 0 < len(target.languages) {
|
|
@@ -1042,13 +1049,13 @@ func (client *Client) getWhoisOf(target *Client) {
|
1042
|
1049
|
params = append(params, str)
|
1043
|
1050
|
}
|
1044
|
1051
|
params = append(params, client.t("can speak these languages"))
|
1045
|
|
- client.Send(nil, client.server.name, RPL_WHOISLANGUAGE, params...)
|
|
1052
|
+ rb.Add(nil, client.server.name, RPL_WHOISLANGUAGE, params...)
|
1046
|
1053
|
}
|
1047
|
1054
|
|
1048
|
1055
|
if target.certfp != "" && (client.flags[Operator] || client == target) {
|
1049
|
|
- client.Send(nil, client.server.name, RPL_WHOISCERTFP, client.nick, target.nick, fmt.Sprintf(client.t("has client certificate fingerprint %s"), target.certfp))
|
|
1056
|
+ rb.Add(nil, client.server.name, RPL_WHOISCERTFP, client.nick, target.nick, fmt.Sprintf(client.t("has client certificate fingerprint %s"), target.certfp))
|
1050
|
1057
|
}
|
1051
|
|
- client.Send(nil, client.server.name, RPL_WHOISIDLE, client.nick, target.nick, strconv.FormatUint(target.IdleSeconds(), 10), strconv.FormatInt(target.SignonTime(), 10), client.t("seconds idle, signon time"))
|
|
1058
|
+ rb.Add(nil, client.server.name, RPL_WHOISIDLE, client.nick, target.nick, strconv.FormatUint(target.IdleSeconds(), 10), strconv.FormatInt(target.SignonTime(), 10), client.t("seconds idle, signon time"))
|
1052
|
1059
|
}
|
1053
|
1060
|
|
1054
|
1061
|
// rplWhoReply returns the WHO reply between one user and another channel/user.
|