Documentation
ΒΆ
Index ΒΆ
- Variables
- func RegisterCommands(p *proxy.Proxy, mgr *Manager)
- type ListConfig
- type ListState
- type Manager
- func (m *Manager) AddWhitelist(rawTarget string) (TargetType, string, bool, error)
- func (m *Manager) IsWhitelisted(username string, id uuid.UUID, remoteAddr net.Addr) (bool, c.Component)
- func (m *Manager) Load() error
- func (m *Manager) RemoveWhitelist(rawTarget string) (TargetType, string, bool, error)
- func (m *Manager) SetWhitelistEnabled(enabled bool) error
- func (m *Manager) WhitelistState() *ListState
- type SuggestionFunc
- type TargetType
Constants ΒΆ
This section is empty.
Variables ΒΆ
var Plugin = proxy.Plugin{ Name: "SimpleWhitelist", Init: func(ctx context.Context, p *proxy.Proxy) error { log := logr.FromContextOrDiscard(ctx) mgr := NewManager("config") if err := mgr.Load(); err != nil { log.Error(err, "Failed to load simple whitelist configuration") return err } event.Subscribe(p.Event(), 0, func(e *proxy.LoginEvent) { if !e.Allowed() { return } pl := e.Player() if !pl.HasPermission("simplewhitelist.bypass") { if whitelisted, reason := mgr.IsWhitelisted(pl.Username(), pl.ID(), pl.RemoteAddr()); !whitelisted { e.Deny(reason) return } } }) RegisterCommands(p, mgr) log.Info("SimpleWhitelist loaded (nicks, uuids, ips, in-game management active)") return nil }, }
Plugin is the ultra-lightweight, zero-fluff simple whitelist plugin for Gate proxy.
Functions ΒΆ
func RegisterCommands ΒΆ
RegisterCommands registers /whitelist, /simplewhitelist, and /swl command trees into Gate.
Types ΒΆ
type ListConfig ΒΆ
type ListConfig struct {
Enabled bool `toml:"enabled"`
KickMessage string `toml:"kick_message"`
Nicks []string `toml:"nicks"`
UUIDs []string `toml:"uuids"`
IPs []string `toml:"ips"`
}
ListConfig represents the TOML file structure for whitelist.
type ListState ΒΆ
type ListState struct {
Enabled bool
KickMessage string
Nicks map[string]struct{}
UUIDs map[string]struct{}
IPs []net.IP
IPNets []*net.IPNet
RawNicks []string
RawUUIDs []string
RawIPs []string
KickReason c.Component
}
ListState holds parsed, fast O(1) in-memory structures for login evaluations.
type Manager ΒΆ
type Manager struct {
// contains filtered or unexported fields
}
Manager handles concurrent in-memory caching and persistent TOML storage for whitelist.
func NewManager ΒΆ
NewManager initializes a Manager instance.
func (*Manager) AddWhitelist ΒΆ
AddWhitelist adds an entry to the whitelist and persists to disk.
func (*Manager) IsWhitelisted ΒΆ
func (m *Manager) IsWhitelisted(username string, id uuid.UUID, remoteAddr net.Addr) (bool, c.Component)
IsWhitelisted checks if a player is allowed by the whitelist.
func (*Manager) RemoveWhitelist ΒΆ
RemoveWhitelist removes an entry from the whitelist and persists to disk.
func (*Manager) SetWhitelistEnabled ΒΆ
SetWhitelistEnabled enables or disables the whitelist and saves to disk.
func (*Manager) WhitelistState ΒΆ
WhitelistState returns the current active whitelist state.
type SuggestionFunc ΒΆ
type SuggestionFunc func(ctx *brigodier.CommandContext, builder *brigodier.SuggestionsBuilder) *brigodier.Suggestions
SuggestionFunc adapts a function into a brigodier.SuggestionProvider.
func (SuggestionFunc) Suggestions ΒΆ
func (f SuggestionFunc) Suggestions(ctx *brigodier.CommandContext, builder *brigodier.SuggestionsBuilder) *brigodier.Suggestions
Suggestions implements brigodier.SuggestionProvider.
type TargetType ΒΆ
type TargetType string
TargetType identifies the kind of entity added or removed.
const ( TargetNick TargetType = "Nick" TargetUUID TargetType = "UUID" TargetIP TargetType = "IP" TargetCIDR TargetType = "CIDR" )
func DetectTargetType ΒΆ
func DetectTargetType(input string) (TargetType, string)
DetectTargetType classifies an input string into IP, CIDR, UUID, or Nick.