mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-23 03:02:48 +01:00
212 lines
5.0 KiB
Go
212 lines
5.0 KiB
Go
// Copyright (c) 2017 Shivaram Lingamneni <slingamn@cs.stanford.edu>
|
|
// released under the MIT license
|
|
|
|
package irc
|
|
|
|
import (
|
|
"github.com/oragono/oragono/irc/isupport"
|
|
"github.com/oragono/oragono/irc/modes"
|
|
)
|
|
|
|
func (server *Server) ISupport() *isupport.List {
|
|
server.configurableStateMutex.RLock()
|
|
defer server.configurableStateMutex.RUnlock()
|
|
return server.isupport
|
|
}
|
|
|
|
func (server *Server) Limits() Limits {
|
|
server.configurableStateMutex.RLock()
|
|
defer server.configurableStateMutex.RUnlock()
|
|
return server.limits
|
|
}
|
|
|
|
func (server *Server) Password() []byte {
|
|
server.configurableStateMutex.RLock()
|
|
defer server.configurableStateMutex.RUnlock()
|
|
return server.password
|
|
}
|
|
|
|
func (server *Server) RecoverFromErrors() bool {
|
|
server.configurableStateMutex.RLock()
|
|
defer server.configurableStateMutex.RUnlock()
|
|
return server.recoverFromErrors
|
|
}
|
|
|
|
func (server *Server) ProxyAllowedFrom() []string {
|
|
server.configurableStateMutex.RLock()
|
|
defer server.configurableStateMutex.RUnlock()
|
|
return server.proxyAllowedFrom
|
|
}
|
|
|
|
func (server *Server) WebIRCConfig() []webircConfig {
|
|
server.configurableStateMutex.RLock()
|
|
defer server.configurableStateMutex.RUnlock()
|
|
return server.webirc
|
|
}
|
|
|
|
func (server *Server) DefaultChannelModes() modes.Modes {
|
|
server.configurableStateMutex.RLock()
|
|
defer server.configurableStateMutex.RUnlock()
|
|
return server.defaultChannelModes
|
|
}
|
|
|
|
func (server *Server) ChannelRegistrationEnabled() bool {
|
|
server.configurableStateMutex.RLock()
|
|
defer server.configurableStateMutex.RUnlock()
|
|
return server.channelRegistrationEnabled
|
|
}
|
|
|
|
func (client *Client) Nick() string {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.nick
|
|
}
|
|
|
|
func (client *Client) NickMaskString() string {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.nickMaskString
|
|
}
|
|
|
|
func (client *Client) NickCasefolded() string {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.nickCasefolded
|
|
}
|
|
|
|
func (client *Client) Username() string {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.username
|
|
}
|
|
|
|
func (client *Client) Hostname() string {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.hostname
|
|
}
|
|
|
|
func (client *Client) Realname() string {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.realname
|
|
}
|
|
|
|
func (client *Client) Registered() bool {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.registered
|
|
}
|
|
|
|
func (client *Client) Destroyed() bool {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.isDestroyed
|
|
}
|
|
|
|
func (client *Client) AccountName() string {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.account.Name
|
|
}
|
|
|
|
func (client *Client) HasMode(mode modes.Mode) bool {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
return client.flags[mode]
|
|
}
|
|
|
|
func (client *Client) Channels() (result []*Channel) {
|
|
client.stateMutex.RLock()
|
|
defer client.stateMutex.RUnlock()
|
|
length := len(client.channels)
|
|
result = make([]*Channel, length)
|
|
i := 0
|
|
for channel := range client.channels {
|
|
result[i] = channel
|
|
i++
|
|
}
|
|
return
|
|
}
|
|
|
|
func (channel *Channel) Name() string {
|
|
channel.stateMutex.RLock()
|
|
defer channel.stateMutex.RUnlock()
|
|
return channel.name
|
|
}
|
|
|
|
func (channel *Channel) setName(name string) {
|
|
channel.stateMutex.Lock()
|
|
defer channel.stateMutex.Unlock()
|
|
channel.name = name
|
|
}
|
|
|
|
func (channel *Channel) NameCasefolded() string {
|
|
channel.stateMutex.RLock()
|
|
defer channel.stateMutex.RUnlock()
|
|
return channel.nameCasefolded
|
|
}
|
|
|
|
func (channel *Channel) setNameCasefolded(nameCasefolded string) {
|
|
channel.stateMutex.Lock()
|
|
defer channel.stateMutex.Unlock()
|
|
channel.nameCasefolded = nameCasefolded
|
|
}
|
|
|
|
func (channel *Channel) Members() (result []*Client) {
|
|
channel.stateMutex.RLock()
|
|
defer channel.stateMutex.RUnlock()
|
|
return channel.membersCache
|
|
}
|
|
|
|
func (channel *Channel) UserLimit() uint64 {
|
|
channel.stateMutex.RLock()
|
|
defer channel.stateMutex.RUnlock()
|
|
return channel.userLimit
|
|
}
|
|
|
|
func (channel *Channel) setUserLimit(limit uint64) {
|
|
channel.stateMutex.Lock()
|
|
channel.userLimit = limit
|
|
channel.stateMutex.Unlock()
|
|
}
|
|
|
|
func (channel *Channel) Key() string {
|
|
channel.stateMutex.RLock()
|
|
defer channel.stateMutex.RUnlock()
|
|
return channel.key
|
|
}
|
|
|
|
func (channel *Channel) setKey(key string) {
|
|
channel.stateMutex.Lock()
|
|
channel.key = key
|
|
channel.stateMutex.Unlock()
|
|
}
|
|
|
|
func (channel *Channel) HasMode(mode modes.Mode) bool {
|
|
channel.stateMutex.RLock()
|
|
defer channel.stateMutex.RUnlock()
|
|
return channel.flags[mode]
|
|
}
|
|
|
|
func (channel *Channel) Founder() string {
|
|
channel.stateMutex.RLock()
|
|
defer channel.stateMutex.RUnlock()
|
|
return channel.registeredFounder
|
|
}
|
|
|
|
// set a channel mode, return whether it was already set
|
|
func (channel *Channel) setMode(mode modes.Mode, enable bool) (already bool) {
|
|
channel.stateMutex.Lock()
|
|
already = (channel.flags[mode] == enable)
|
|
if !already {
|
|
if enable {
|
|
channel.flags[mode] = true
|
|
} else {
|
|
delete(channel.flags, mode)
|
|
}
|
|
}
|
|
channel.stateMutex.Unlock()
|
|
return
|
|
}
|