mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
fix some issues found with staticcheck.io
This commit is contained in:
parent
ce6a3e42df
commit
c193def606
@ -5,7 +5,6 @@ package irc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/smtp"
|
"net/smtp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -480,7 +479,7 @@ func (am *AccountManager) dispatchCallback(client *Client, casefoldedAccount str
|
|||||||
} else if callbackNamespace == "mailto" {
|
} else if callbackNamespace == "mailto" {
|
||||||
return am.dispatchMailtoCallback(client, casefoldedAccount, callbackValue)
|
return am.dispatchMailtoCallback(client, casefoldedAccount, callbackValue)
|
||||||
} else {
|
} else {
|
||||||
return "", errors.New(fmt.Sprintf("Callback not implemented: %s", callbackNamespace))
|
return "", fmt.Errorf("Callback not implemented: %s", callbackNamespace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1262,7 +1261,6 @@ func (am *AccountManager) Logout(client *Client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
am.accountToClients[casefoldedAccount] = remainingClients
|
am.accountToClients[casefoldedAccount] = remainingClients
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -1043,34 +1043,6 @@ func (channel *Channel) ShowMaskList(client *Client, mode modes.Mode, rb *Respon
|
|||||||
rb.Add(nil, client.server.name, rplendoflist, nick, channel.name, client.t("End of list"))
|
rb.Add(nil, client.server.name, rplendoflist, nick, channel.name, client.t("End of list"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) applyModeMask(client *Client, mode modes.Mode, op modes.ModeOp, mask string, rb *ResponseBuffer) bool {
|
|
||||||
list := channel.lists[mode]
|
|
||||||
if list == nil {
|
|
||||||
// This should never happen, but better safe than panicky.
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (op == modes.List) || (mask == "") {
|
|
||||||
channel.ShowMaskList(client, mode, rb)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if !channel.ClientIsAtLeast(client, modes.ChannelOperator) {
|
|
||||||
rb.Add(nil, client.server.name, ERR_CHANOPRIVSNEEDED, client.Nick(), channel.Name(), client.t("You're not a channel operator"))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if op == modes.Add {
|
|
||||||
return list.Add(mask)
|
|
||||||
}
|
|
||||||
|
|
||||||
if op == modes.Remove {
|
|
||||||
return list.Remove(mask)
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Quit removes the given client from the channel
|
// Quit removes the given client from the channel
|
||||||
func (channel *Channel) Quit(client *Client) {
|
func (channel *Channel) Quit(client *Client) {
|
||||||
channelEmpty := func() bool {
|
channelEmpty := func() bool {
|
||||||
|
@ -538,14 +538,12 @@ func (client *Client) tryResume() (success bool) {
|
|||||||
func (client *Client) tryResumeChannels() {
|
func (client *Client) tryResumeChannels() {
|
||||||
details := client.resumeDetails
|
details := client.resumeDetails
|
||||||
|
|
||||||
channels := make([]*Channel, len(details.Channels))
|
|
||||||
for _, name := range details.Channels {
|
for _, name := range details.Channels {
|
||||||
channel := client.server.channels.Get(name)
|
channel := client.server.channels.Get(name)
|
||||||
if channel == nil {
|
if channel == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
channel.Resume(client, details.OldClient, details.Timestamp)
|
channel.Resume(client, details.OldClient, details.Timestamp)
|
||||||
channels = append(channels, channel)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// replay direct PRIVSMG history
|
// replay direct PRIVSMG history
|
||||||
|
@ -393,7 +393,7 @@ func (conf *Config) OperatorClasses() (map[string]*OperClass, error) {
|
|||||||
|
|
||||||
// get inhereted info from other operclasses
|
// get inhereted info from other operclasses
|
||||||
if len(info.Extends) > 0 {
|
if len(info.Extends) > 0 {
|
||||||
einfo, _ := ocs[info.Extends]
|
einfo := ocs[info.Extends]
|
||||||
|
|
||||||
for capab := range einfo.Capabilities {
|
for capab := range einfo.Capabilities {
|
||||||
oc.Capabilities[capab] = true
|
oc.Capabilities[capab] = true
|
||||||
|
@ -1184,20 +1184,14 @@ func inviteHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
func isonHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
func isonHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
||||||
var nicks = msg.Params
|
var nicks = msg.Params
|
||||||
|
|
||||||
var err error
|
ison := make([]string, 0, len(msg.Params))
|
||||||
var casefoldedNick string
|
|
||||||
ison := make([]string, 0)
|
|
||||||
for _, nick := range nicks {
|
for _, nick := range nicks {
|
||||||
casefoldedNick, err = CasefoldName(nick)
|
if iclient := server.clients.Get(nick); iclient != nil {
|
||||||
if err != nil {
|
ison = append(ison, iclient.Nick())
|
||||||
continue
|
|
||||||
}
|
|
||||||
if iclient := server.clients.Get(casefoldedNick); iclient != nil {
|
|
||||||
ison = append(ison, iclient.nick)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rb.Add(nil, server.name, RPL_ISON, client.nick, strings.Join(nicks, " "))
|
rb.Add(nil, server.name, RPL_ISON, client.nick, strings.Join(ison, " "))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2099,7 +2093,7 @@ func npcaHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
|||||||
|
|
||||||
// OPER <name> <password>
|
// OPER <name> <password>
|
||||||
func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
func operHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
|
||||||
if client.HasMode(modes.Operator) == true {
|
if client.HasMode(modes.Operator) {
|
||||||
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), "OPER", client.t("You're already opered-up!"))
|
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), "OPER", client.t("You're already opered-up!"))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ func SplitChannelMembershipPrefixes(target string) (prefixes string, name string
|
|||||||
prefixes = target[:i+1]
|
prefixes = target[:i+1]
|
||||||
name = target[i+1:]
|
name = target[i+1:]
|
||||||
default:
|
default:
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,5 +36,4 @@ func (serversem *ServerSemaphores) Initialize() {
|
|||||||
capacity = MaxServerSemaphoreCapacity
|
capacity = MaxServerSemaphoreCapacity
|
||||||
}
|
}
|
||||||
serversem.ClientDestroy.Initialize(capacity)
|
serversem.ClientDestroy.Initialize(capacity)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/goshuirc/irc-go/ircfmt"
|
"github.com/goshuirc/irc-go/ircfmt"
|
||||||
"github.com/oragono/oragono/irc/caps"
|
"github.com/oragono/oragono/irc/caps"
|
||||||
"github.com/oragono/oragono/irc/connection_limits"
|
"github.com/oragono/oragono/irc/connection_limits"
|
||||||
"github.com/oragono/oragono/irc/isupport"
|
|
||||||
"github.com/oragono/oragono/irc/logger"
|
"github.com/oragono/oragono/irc/logger"
|
||||||
"github.com/oragono/oragono/irc/modes"
|
"github.com/oragono/oragono/irc/modes"
|
||||||
"github.com/oragono/oragono/irc/sno"
|
"github.com/oragono/oragono/irc/sno"
|
||||||
@ -73,12 +72,10 @@ type Server struct {
|
|||||||
ctime time.Time
|
ctime time.Time
|
||||||
dlines *DLineManager
|
dlines *DLineManager
|
||||||
helpIndexManager HelpIndexManager
|
helpIndexManager HelpIndexManager
|
||||||
isupport *isupport.List
|
|
||||||
klines *KLineManager
|
klines *KLineManager
|
||||||
listeners map[string]*ListenerWrapper
|
listeners map[string]*ListenerWrapper
|
||||||
logger *logger.Manager
|
logger *logger.Manager
|
||||||
monitorManager *MonitorManager
|
monitorManager *MonitorManager
|
||||||
motdLines []string
|
|
||||||
name string
|
name string
|
||||||
nameCasefolded string
|
nameCasefolded string
|
||||||
rehashMutex sync.Mutex // tier 4
|
rehashMutex sync.Mutex // tier 4
|
||||||
@ -176,13 +173,6 @@ func (config *Config) generateISupport() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadChannelList(channel *Channel, list string, maskMode modes.Mode) {
|
|
||||||
if list == "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
channel.lists[maskMode].AddAll(strings.Split(list, " "))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shutdown shuts down the server.
|
// Shutdown shuts down the server.
|
||||||
func (server *Server) Shutdown() {
|
func (server *Server) Shutdown() {
|
||||||
//TODO(dan): Make sure we disallow new nicks
|
//TODO(dan): Make sure we disallow new nicks
|
||||||
@ -518,9 +508,7 @@ func (client *Client) getWhoisOf(target *Client, rb *ResponseBuffer) {
|
|||||||
tLanguages := target.Languages()
|
tLanguages := target.Languages()
|
||||||
if 0 < len(tLanguages) {
|
if 0 < len(tLanguages) {
|
||||||
params := []string{cnick, tnick}
|
params := []string{cnick, tnick}
|
||||||
for _, str := range client.server.Languages().Codes(tLanguages) {
|
params = append(params, client.server.Languages().Codes(tLanguages)...)
|
||||||
params = append(params, str)
|
|
||||||
}
|
|
||||||
params = append(params, client.t("can speak these languages"))
|
params = append(params, client.t("can speak these languages"))
|
||||||
rb.Add(nil, client.server.name, RPL_WHOISLANGUAGE, params...)
|
rb.Add(nil, client.server.name, RPL_WHOISLANGUAGE, params...)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ func (m *SnoManager) RemoveMasks(client *Client, masks ...sno.Mask) {
|
|||||||
for _, mask := range masks {
|
for _, mask := range masks {
|
||||||
currentClientList := m.sendLists[mask]
|
currentClientList := m.sendLists[mask]
|
||||||
|
|
||||||
if currentClientList == nil || len(currentClientList) == 0 {
|
if len(currentClientList) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ func (m *SnoManager) RemoveClient(client *Client) {
|
|||||||
for mask := range m.sendLists {
|
for mask := range m.sendLists {
|
||||||
currentClientList := m.sendLists[mask]
|
currentClientList := m.sendLists[mask]
|
||||||
|
|
||||||
if currentClientList == nil || len(currentClientList) == 0 {
|
if len(currentClientList) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ func (m *SnoManager) Send(mask sno.Mask, content string) {
|
|||||||
|
|
||||||
currentClientList := m.sendLists[mask]
|
currentClientList := m.sendLists[mask]
|
||||||
|
|
||||||
if currentClientList == nil || len(currentClientList) == 0 {
|
if len(currentClientList) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user