Documentation ¶
Index ¶
- Variables
- func RandomUint64() uint64
- type ChannelRegistrar
- type Command
- type CommandExecuteEvent
- type CommandManager
- type CommandSource
- type ConnectionHandshakeEvent
- type ConnectionRequest
- type ConnectionResult
- type ConnectionStatus
- type Context
- type DisconnectEvent
- type DisconnectPlayerKickResult
- type Func
- type GameProfileRequestEvent
- func (e *GameProfileRequestEvent) Conn() Inbound
- func (e *GameProfileRequestEvent) GameProfile() profile.GameProfile
- func (e *GameProfileRequestEvent) OnlineMode() bool
- func (e *GameProfileRequestEvent) Original() profile.GameProfile
- func (e *GameProfileRequestEvent) SetGameProfile(p profile.GameProfile)
- type Inbound
- type KickedFromServerEvent
- func (e *KickedFromServerEvent) KickedDuringServerConnect() bool
- func (e *KickedFromServerEvent) OriginalReason() component.Component
- func (e *KickedFromServerEvent) Player() Player
- func (e *KickedFromServerEvent) Result() ServerKickResult
- func (e *KickedFromServerEvent) Server() RegisteredServer
- func (e *KickedFromServerEvent) SetResult(result ServerKickResult)
- type LoginEvent
- type LoginStatus
- type NotifyKickResult
- type PermissionsSetupEvent
- type PingEvent
- type Player
- type PlayerChatEvent
- type PlayerChooseInitialServerEvent
- type PlayerModInfoEvent
- type PlayerSettingsChangedEvent
- type Players
- type PluginMessageEvent
- func (p *PluginMessageEvent) Allowed() bool
- func (p *PluginMessageEvent) Data() []byte
- func (p *PluginMessageEvent) Identifier() message.ChannelIdentifier
- func (p *PluginMessageEvent) SetForward(forward bool)
- func (p *PluginMessageEvent) Source() message.ChannelMessageSource
- func (p *PluginMessageEvent) Target() message.ChannelMessageSink
- type PluginMessageForwardResult
- type PostLoginEvent
- type PreLoginEvent
- func (e *PreLoginEvent) Allow()
- func (e *PreLoginEvent) Conn() Inbound
- func (e *PreLoginEvent) Deny(reason component.Component)
- func (e *PreLoginEvent) ForceOfflineMode()
- func (e *PreLoginEvent) ForceOnlineMode()
- func (e *PreLoginEvent) Reason() component.Component
- func (e *PreLoginEvent) Result() PreLoginResult
- func (e *PreLoginEvent) Username() string
- type PreLoginResult
- type Proxy
- func (p *Proxy) ChannelRegistrar() *ChannelRegistrar
- func (p *Proxy) Command() *CommandManager
- func (p *Proxy) Config() config.Config
- func (c Proxy) DisconnectAll(reason component.Component)
- func (p *Proxy) Event() *event.Manager
- func (c Proxy) PlayerCount() int
- func (p *Proxy) Register(info ServerInfo) (RegisteredServer, bool)
- func (p *Proxy) Run() (err error)
- func (p *Proxy) Server(name string) RegisteredServer
- func (p *Proxy) Servers() []RegisteredServer
- func (p *Proxy) Shutdown(reason component.Component)
- func (p *Proxy) Unregister(info ServerInfo) bool
- type RedirectPlayerKickResult
- type RegisteredServer
- type ServerConnectedEvent
- type ServerConnection
- type ServerInfo
- type ServerKickResult
- type ServerPostConnectEvent
- type ServerPreConnectEvent
- func (e *ServerPreConnectEvent) Allow(server RegisteredServer)
- func (e *ServerPreConnectEvent) Allowed() bool
- func (e *ServerPreConnectEvent) Deny()
- func (e *ServerPreConnectEvent) OriginalServer() RegisteredServer
- func (e *ServerPreConnectEvent) Player() Player
- func (e *ServerPreConnectEvent) Server() RegisteredServer
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoBackendConnection = errors.New("player has no backend server connection yet") ErrTooLongChatMessage = errors.New("server bound chat message can not exceed 256 characters") )
Indicates a connection is already closed.
var ErrServerOnlineMode = errors.New("backend server is online mode, but should be offline")
An error in a ConnectionRequest when the backend server is in online mode.
var (
// Indicates that the connection is a 1.8-1.12 Forge connection.
LegacyForge connectionType = &legacyForgeConnType{
connType: &connType{
initialClientPhase_: notStartedLegacyForgeHandshakeClientPhase,
initialBackendPhase_: notStartedLegacyForgeHandshakeBackendPhase,
},
}
)
Functions ¶
Types ¶
type ChannelRegistrar ¶
type ChannelRegistrar struct {
// contains filtered or unexported fields
}
func NewChannelRegistrar ¶
func NewChannelRegistrar() *ChannelRegistrar
func (*ChannelRegistrar) ChannelsForProtocol ¶
func (r *ChannelRegistrar) ChannelsForProtocol(protocol proto.Protocol) sets.String
ChannelsForProtocol returns all the channel names to register depending on the Minecraft protocol version.
func (*ChannelRegistrar) FromId ¶
func (r *ChannelRegistrar) FromId(channel string) (message.ChannelIdentifier, bool)
func (*ChannelRegistrar) LegacyChannelIds ¶
func (r *ChannelRegistrar) LegacyChannelIds() sets.String
LegacyChannelIds returns all legacy channel IDs.
func (*ChannelRegistrar) ModernChannelIds ¶
func (r *ChannelRegistrar) ModernChannelIds() sets.String
ModernChannelIds returns all channel IDs (as strings) for use with Minecraft 1.13 and above.
type Command ¶ added in v0.3.0
type Command interface {
Invoke(*Context)
}
Command is an invokable command.
type CommandExecuteEvent ¶ added in v0.3.0
type CommandExecuteEvent struct {
// contains filtered or unexported fields
}
CommandExecuteEvent is fired when someone wants to execute a command.
func (*CommandExecuteEvent) Allowed ¶ added in v0.3.0
func (c *CommandExecuteEvent) Allowed() bool
Allowed returns true when the command is allowed to be executed.
func (*CommandExecuteEvent) Command ¶ added in v0.3.0
func (c *CommandExecuteEvent) Command() string
Command returns the whole commandline without the leading "/".
func (*CommandExecuteEvent) SetAllowed ¶ added in v0.3.0
func (c *CommandExecuteEvent) SetAllowed(allowed bool)
SetAllowed sets whether the command is allowed to be executed.
func (*CommandExecuteEvent) Source ¶ added in v0.3.0
func (c *CommandExecuteEvent) Source() CommandSource
Source returns the command source that wants to run the command.
type CommandManager ¶ added in v0.3.0
type CommandManager struct {
// contains filtered or unexported fields
}
func (*CommandManager) Has ¶ added in v0.3.0
func (m *CommandManager) Has(command string) bool
Has return true if the command is registered.
func (*CommandManager) Invoke ¶ added in v0.3.0
func (m *CommandManager) Invoke(ctx *Context, command string) (found bool, err error)
Invoke invokes a registered command.
func (*CommandManager) Register ¶ added in v0.3.0
func (m *CommandManager) Register(cmd Command, name string, aliases ...string)
Register registers (and overrides) a command with the root literal name and optional aliases.
func (*CommandManager) Unregister ¶ added in v0.3.0
func (m *CommandManager) Unregister(name string)
Unregister unregisters a command with its aliases.
type CommandSource ¶
type CommandSource interface { permission.Subject // Sends a message component to the invoker. SendMessage(msg component.Component) error }
CommandSource is the source that ran a command.
type ConnectionHandshakeEvent ¶ added in v0.1.0
type ConnectionHandshakeEvent struct {
// contains filtered or unexported fields
}
ConnectionHandshakeEvent is fired when a handshake is established between a client and the proxy.
func (*ConnectionHandshakeEvent) Connection ¶ added in v0.1.0
func (e *ConnectionHandshakeEvent) Connection() Inbound
Connection returns the inbound connection.
type ConnectionRequest ¶
type ConnectionRequest interface { // Returns the server that this connection request is for. Server() RegisteredServer // This method is blocking, initiates the connection to the // remote Server and returns a result after the user has logged on // or an error when an error occurred (e.g. could not net.Dial the Server, ctx was called, etc.). // // The given Context can be used to cancel the connection initiation, but // has no effect if the connection was already established or canceled. // // No messages will be communicated to the client: // You are responsible for all error handling. Connect(ctx context.Context) (ConnectionResult, error) // This method is the same as Connect, but the proxy's built-in // handling will be used to provide errors to the player and returns // true if the player was successfully connected. ConnectWithIndication(ctx context.Context) (successful bool) }
ConnectionRequest can send a connection request to another server on the proxy. A connection request is created using Player.CreateConnectionRequest(RegisteredServer).
type ConnectionResult ¶
type ConnectionResult interface { Status() ConnectionStatus // The connection result status. // May be nil! Reason() Component // Returns a reason for the failure to connect to the server. }
ConnectionResult is the result of a ConnectionRequest.
type ConnectionStatus ¶
type ConnectionStatus uint8
ConnectionStatus is the status for a ConnectionResult
const ( // The player was successfully connected to the server. SuccessConnectionStatus ConnectionStatus = iota // The player is already connected to this server. AlreadyConnectedConnectionStatus // A connection is already in progress. InProgressConnectionStatus // A plugin has cancelled this connection. CanceledConnectionStatus // The server disconnected the player. // A reason MAY be provided in the ConnectionResult.Reason(). ServerDisconnectedConnectionStatus )
func (ConnectionStatus) AlreadyConnected ¶
func (r ConnectionStatus) AlreadyConnected() bool
AlreadyConnected id true if the player is already connected to this server.
func (ConnectionStatus) Canceled ¶
func (r ConnectionStatus) Canceled() bool
Canceled is true if a plugin has cancelled this connection.
func (ConnectionStatus) ConnectionInProgress ¶
func (r ConnectionStatus) ConnectionInProgress() bool
ConnectionInProgress is true if a connection is already in progress.
func (ConnectionStatus) ServerDisconnected ¶
func (r ConnectionStatus) ServerDisconnected() bool
ServerDisconnected is true if the server disconnected the player. A reason MAY be provided in the ConnectionResult.Reason().
func (ConnectionStatus) Successful ¶
func (r ConnectionStatus) Successful() bool
Successful is true if the player was successfully connected to the server.
type Context ¶ added in v0.3.0
type Context struct { context.Context Source CommandSource Args []string }
Context is a command invocation context.
type DisconnectEvent ¶
type DisconnectEvent struct {
// contains filtered or unexported fields
}
func (*DisconnectEvent) LoginStatus ¶
func (e *DisconnectEvent) LoginStatus() LoginStatus
func (*DisconnectEvent) Player ¶
func (e *DisconnectEvent) Player() Player
type DisconnectPlayerKickResult ¶
DisconnectPlayerKickResult is a ServerKickResult and tells the proxy to disconnect the player with the specified reason.
type Func ¶ added in v0.3.0
type Func func(*Context)
Func is a shorthand type that implements the Command interface.
type GameProfileRequestEvent ¶
type GameProfileRequestEvent struct {
// contains filtered or unexported fields
}
GameProfileRequestEvent is fired after the PreLoginEvent in order to set up the game profile for the user. This can be used to configure a custom profile for a user, i.e. skin replacement.
func NewGameProfileRequestEvent ¶
func NewGameProfileRequestEvent( inbound Inbound, original profile.GameProfile, onlineMode bool, ) *GameProfileRequestEvent
func (*GameProfileRequestEvent) Conn ¶
func (e *GameProfileRequestEvent) Conn() Inbound
minecraftConn returns the inbound connection that is connecting to the proxy.
func (*GameProfileRequestEvent) GameProfile ¶
func (e *GameProfileRequestEvent) GameProfile() profile.GameProfile
GameProfile returns the game profile that will be used to initialize the connection with. Should no profile be set, the original profile (given by the proxy) will be used.
func (*GameProfileRequestEvent) OnlineMode ¶
func (e *GameProfileRequestEvent) OnlineMode() bool
OnlineMode specifies whether the user connected in online/offline mode.
func (*GameProfileRequestEvent) Original ¶
func (e *GameProfileRequestEvent) Original() profile.GameProfile
OriginalServer returns the by the proxy created offline or online (Mojang authenticated) game profile.
func (*GameProfileRequestEvent) SetGameProfile ¶
func (e *GameProfileRequestEvent) SetGameProfile(p profile.GameProfile)
SetGameProfile sets the profile to use for this connection.
type Inbound ¶
type Inbound interface { Protocol() proto.Protocol // The current protocol version the connection uses. VirtualHost() net.Addr // The hostname, the client sent us, to join the server, if applicable. RemoteAddr() net.Addr // The player's IP address. Active() bool // Whether or not connection remains active. // Closed returns a receive only channel that can be used know when the connection was closed. // (e.g. for canceling work in an event subscriber) Closed() <-chan struct{} }
Inbound is an incoming connection to the proxy.
type KickedFromServerEvent ¶
type KickedFromServerEvent struct {
// contains filtered or unexported fields
}
Fired when a player is kicked from a server. You may either allow the proxy to kick the player (with an optional reason override) or redirect the player to a separate server. By default, the proxy will notify the user (if they are already connected to a server) or disconnect them (if they are not on a server and no other servers are available).
func (*KickedFromServerEvent) KickedDuringServerConnect ¶
func (e *KickedFromServerEvent) KickedDuringServerConnect() bool
KickedDuringServerConnect returns true if the player got kicked while connecting to another server.
func (*KickedFromServerEvent) OriginalReason ¶
func (e *KickedFromServerEvent) OriginalReason() component.Component
OriginalReason returns the reason the server kicked the player from the server. May return nil!
func (*KickedFromServerEvent) Player ¶
func (e *KickedFromServerEvent) Player() Player
Player returns the player that got kicked.
func (*KickedFromServerEvent) Result ¶
func (e *KickedFromServerEvent) Result() ServerKickResult
KickedDuringServerConnect returns current kick result. The proxy sets a default non-nil result but an event handler may has set it nil when handling the event.
func (*KickedFromServerEvent) Server ¶
func (e *KickedFromServerEvent) Server() RegisteredServer
Server returns the server the player got kicked from.
func (*KickedFromServerEvent) SetResult ¶
func (e *KickedFromServerEvent) SetResult(result ServerKickResult)
KickedDuringServerConnect sets the kick result.
type LoginEvent ¶
type LoginEvent struct {
// contains filtered or unexported fields
}
func (*LoginEvent) Allow ¶
func (e *LoginEvent) Allow()
func (*LoginEvent) Allowed ¶
func (e *LoginEvent) Allowed() bool
func (*LoginEvent) Deny ¶
func (e *LoginEvent) Deny(reason component.Component)
func (*LoginEvent) Player ¶
func (e *LoginEvent) Player() Player
func (*LoginEvent) Reason ¶
func (e *LoginEvent) Reason() component.Component
Is nil if Allowed() returns true
type LoginStatus ¶
type LoginStatus uint8
const ( SuccessfulLoginStatus LoginStatus = iota ConflictingLoginStatus CanceledByUserLoginStatus CanceledByProxyLoginStatus CanceledByUserBeforeCompleteLoginStatus )
type NotifyKickResult ¶
NotifyKickResult is ServerKickResult and notifies the player with the specified message but does nothing else. This is only a valid result to use if the player was trying to connect to a different server, otherwise it is treated like a DisconnectPlayerKickResult result.
type PermissionsSetupEvent ¶ added in v0.0.2
type PermissionsSetupEvent struct {
// contains filtered or unexported fields
}
PermissionsSetupEvent is fired once a permission.Subject's permissions are being initialized.
func (*PermissionsSetupEvent) Func ¶ added in v0.0.2
func (p *PermissionsSetupEvent) Func() permission.Func
Func returns the permission.Func used for the subject.
func (*PermissionsSetupEvent) SetFunc ¶ added in v0.0.2
func (p *PermissionsSetupEvent) SetFunc(fn permission.Func)
SetFunc sets the permission.Func use for the subject. If fn is nil, the default Func fill be used.
func (*PermissionsSetupEvent) Subject ¶ added in v0.0.2
func (p *PermissionsSetupEvent) Subject() permission.Subject
Subject returns the subject the permissions are setup for.
type PingEvent ¶ added in v0.3.0
type PingEvent struct {
// contains filtered or unexported fields
}
PingEvent is fired when a server list ping request is sent by a remote client.
func (*PingEvent) Connection ¶ added in v0.3.0
Connection returns the inbound connection.
func (*PingEvent) Ping ¶ added in v0.3.0
func (p *PingEvent) Ping() *ping.ServerPing
Ping returns the used ping. (pre-initialized by the proxy)
func (*PingEvent) SetPing ¶ added in v0.3.0
func (p *PingEvent) SetPing(ping *ping.ServerPing)
SetPing sets the ping response to use.
type Player ¶
type Player interface { Inbound CommandSource message.ChannelMessageSource message.ChannelMessageSink Username() string // The username of the player. Id() uuid.UUID // The Minecraft UUID of the player. // May be nil, if no backend server connection! CurrentServer() ServerConnection // Returns the current server connection of the player. Ping() time.Duration // The player's ping or -1 if currently unknown. OnlineMode() bool // Whether the player was authenticated with Mojang's session servers. // Creates a connection request to begin switching the backend server. CreateConnectionRequest(target RegisteredServer) ConnectionRequest GameProfile() profile.GameProfile // Returns the player's game profile. Settings() player.Settings // The players client settings. Returns player.DefaultSettings if not yet unknown. // Disconnects the player with a reason. // Once called, further interface calls to this player become undefined. Disconnect(reason component.Component) // Sends chats input onto the player's current server as if // they typed it into the client chat box. SpoofChatInput(input string) error // Sends the specified resource pack from url to the user. If at all possible, send the // resource pack with a sha1 hash using SendResourcePackWithHash. To monitor the status of the // sent resource pack, subscribe to PlayerResourcePackStatusEvent. SendResourcePack(url string) error // Sends the specified resource pack from url to the user, using the specified 20-byte // SHA-1 hash of the resource pack file. To monitor the status of the sent resource pack, // subscribe to PlayerResourcePackStatusEvent. SendResourcePackWithHash(url string, sha1Hash []byte) error }
Player is a connected Minecraft player.
type PlayerChatEvent ¶ added in v0.1.0
type PlayerChatEvent struct {
// contains filtered or unexported fields
}
PlayerChatEvent is fired when a player sends a chat message. Note that messages with a leading "/" do not trigger this event, but instead CommandExecuteEvent.
func (*PlayerChatEvent) Allowed ¶ added in v0.1.0
func (c *PlayerChatEvent) Allowed() bool
Allowed returns true when the chat message is allowed.
func (*PlayerChatEvent) Message ¶ added in v0.1.0
func (c *PlayerChatEvent) Message() string
Message returns the message the player sent.
func (*PlayerChatEvent) Player ¶ added in v0.1.0
func (c *PlayerChatEvent) Player() Player
Player returns the player that sent the message.
func (*PlayerChatEvent) SetAllowed ¶ added in v0.1.0
func (c *PlayerChatEvent) SetAllowed(allowed bool)
SetAllowed sets whether the chat message is allowed.
type PlayerChooseInitialServerEvent ¶
type PlayerChooseInitialServerEvent struct {
// contains filtered or unexported fields
}
PlayerChooseInitialServerEvent is fired when a player has finished connecting to the proxy and we need to choose the first server to connect to.
func (*PlayerChooseInitialServerEvent) InitialServer ¶
func (e *PlayerChooseInitialServerEvent) InitialServer() RegisteredServer
InitialServer returns the initial server or nil if no server is configured.
func (*PlayerChooseInitialServerEvent) Player ¶
func (e *PlayerChooseInitialServerEvent) Player() Player
Player returns the player to find the initial server for.
func (*PlayerChooseInitialServerEvent) SetInitialServer ¶ added in v0.1.0
func (e *PlayerChooseInitialServerEvent) SetInitialServer(server RegisteredServer)
SetInitialServer sets the initial server for the player.
type PlayerModInfoEvent ¶ added in v0.1.0
type PlayerModInfoEvent struct {
// contains filtered or unexported fields
}
PlayerModInfoEvent is fired when a Forge client sends its mods to the proxy while connecting to a server.
func (*PlayerModInfoEvent) ModInfo ¶ added in v0.1.0
func (e *PlayerModInfoEvent) ModInfo() modinfo.ModInfo
ModInfo is the mod info received by the player.
func (*PlayerModInfoEvent) Player ¶ added in v0.1.0
func (e *PlayerModInfoEvent) Player() Player
Player returns the player who sent the mod info.
type PlayerSettingsChangedEvent ¶
type PlayerSettingsChangedEvent struct {
// contains filtered or unexported fields
}
func (*PlayerSettingsChangedEvent) Player ¶
func (s *PlayerSettingsChangedEvent) Player() Player
Player returns the player who's settings where updates/initialized.
func (*PlayerSettingsChangedEvent) Settings ¶
func (s *PlayerSettingsChangedEvent) Settings() player.Settings
Settings returns player's new settings.
type Players ¶
type Players interface { Len() int // Returns the size of the player list. Range(func(p Player) bool) // Loops through the players, breaks if func returns false. }
Players is a list of players safe for concurrent use.
type PluginMessageEvent ¶
type PluginMessageEvent struct {
// contains filtered or unexported fields
}
PluginMessageEvent is fired when a plugin message is sent to the proxy, either from a player or a server backend server.
func (*PluginMessageEvent) Allowed ¶
func (p *PluginMessageEvent) Allowed() bool
func (*PluginMessageEvent) Data ¶
func (p *PluginMessageEvent) Data() []byte
func (*PluginMessageEvent) Identifier ¶
func (p *PluginMessageEvent) Identifier() message.ChannelIdentifier
func (*PluginMessageEvent) SetForward ¶
func (p *PluginMessageEvent) SetForward(forward bool)
func (*PluginMessageEvent) Source ¶
func (p *PluginMessageEvent) Source() message.ChannelMessageSource
func (*PluginMessageEvent) Target ¶
func (p *PluginMessageEvent) Target() message.ChannelMessageSink
type PluginMessageForwardResult ¶
type PluginMessageForwardResult struct { }
type PostLoginEvent ¶
type PostLoginEvent struct {
// contains filtered or unexported fields
}
func (*PostLoginEvent) Player ¶
func (e *PostLoginEvent) Player() Player
type PreLoginEvent ¶
type PreLoginEvent struct {
// contains filtered or unexported fields
}
func (*PreLoginEvent) Allow ¶
func (e *PreLoginEvent) Allow()
func (*PreLoginEvent) Conn ¶
func (e *PreLoginEvent) Conn() Inbound
func (*PreLoginEvent) Deny ¶
func (e *PreLoginEvent) Deny(reason component.Component)
func (*PreLoginEvent) ForceOfflineMode ¶
func (e *PreLoginEvent) ForceOfflineMode()
func (*PreLoginEvent) ForceOnlineMode ¶
func (e *PreLoginEvent) ForceOnlineMode()
func (*PreLoginEvent) Reason ¶
func (e *PreLoginEvent) Reason() component.Component
Reason returns the deny reason to disconnect the connection. May be nil!
func (*PreLoginEvent) Result ¶
func (e *PreLoginEvent) Result() PreLoginResult
func (*PreLoginEvent) Username ¶
func (e *PreLoginEvent) Username() string
type PreLoginResult ¶
type PreLoginResult uint8
const ( AllowedPreLogin PreLoginResult = iota DeniedPreLogin ForceOnlineModePreLogin ForceOfflineModePreLogin )
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is the "Gate" for proxying and managing Minecraft connections in a network.
func New ¶ added in v0.2.0
New returns a new initialized Proxy.
func (*Proxy) ChannelRegistrar ¶
func (p *Proxy) ChannelRegistrar() *ChannelRegistrar
func (*Proxy) Command ¶ added in v0.3.0
func (p *Proxy) Command() *CommandManager
Command returns the Proxy's command manager.
func (*Proxy) Config ¶
Config returns the config used by the Proxy.
func (Proxy) DisconnectAll ¶ added in v0.3.0
func (*Proxy) Event ¶
Event returns the Proxy's event manager.
func (Proxy) PlayerCount ¶ added in v0.3.0
func (c Proxy) PlayerCount() int
PlayerCount returns the number of players on the proxy.
func (*Proxy) Register ¶
func (p *Proxy) Register(info ServerInfo) (RegisteredServer, bool)
Register registers a server with the proxy.
Returns the new registered server and true on success.
On failure either:
- if name already exists, returns the already registered server and false
- if the name or address specified in the info is invalid, returns nil and false.
func (*Proxy) Run ¶
Run runs the proxy and blocks until Shutdown is called or an error occurred. Run can only be called once per Proxy instance.
func (*Proxy) Server ¶
func (p *Proxy) Server(name string) RegisteredServer
Server gets a backend server registered with the proxy by name. Returns nil if not found.
func (*Proxy) Servers ¶
func (p *Proxy) Servers() []RegisteredServer
Servers gets all registered servers.
func (*Proxy) Shutdown ¶
Shutdown shuts down the Proxy and blocks until finished.
It first stops listening for new connections, disconnects all existing connections with the given reason (if nil stands for no reason) and waits for all event subscribers to finish.
func (*Proxy) Unregister ¶
func (p *Proxy) Unregister(info ServerInfo) bool
Unregister unregisters the server exactly matching the given ServerInfo and returns true if found.
type RedirectPlayerKickResult ¶
type RedirectPlayerKickResult struct { Server RegisteredServer // The new server to redirect the kicked player to. Message component.Component // Optional message to send to the kicked player. }
RedirectPlayerKickResult is a ServerKickResult and tells the proxy to redirect the player to another server. No messages will be sent from the proxy when this result is used.
type RegisteredServer ¶
type RegisteredServer interface { ServerInfo() ServerInfo Players() Players // The players connected to the server on THIS proxy. //TODO Ping() (*ServerPing, error) Equals(RegisteredServer) bool }
RegisteredServer is a backend server that has been registered with the proxy.
type ServerConnectedEvent ¶
type ServerConnectedEvent struct {
// contains filtered or unexported fields
}
ServerConnectedEvent is fired once the player has successfully connected to the target server and the connection to the previous server has been de-established (if any).
func (*ServerConnectedEvent) Player ¶
func (s *ServerConnectedEvent) Player() Player
Player returns the associated player.
func (*ServerConnectedEvent) PreviousServer ¶
func (s *ServerConnectedEvent) PreviousServer() RegisteredServer
PreviousServer returns the server the player was previously connected to. May return nil if there was none!
func (*ServerConnectedEvent) Server ¶
func (s *ServerConnectedEvent) Server() RegisteredServer
Server returns the server the player connected to.
type ServerConnection ¶
type ServerConnection interface { message.ChannelMessageSink message.ChannelMessageSource Server() RegisteredServer // Returns the server that this connection is connected to. Player() Player // Returns the player that this connection is associated with. }
ServerConnection is a connection to a backend server from the proxy for a client.
type ServerInfo ¶
type ServerInfo interface { Name() string // Returns the server name. Addr() net.Addr // Returns the server address. Equals(ServerInfo) bool }
ServerInfo is the info of a backend server.
func NewServerInfo ¶
func NewServerInfo(name string, addr net.Addr) ServerInfo
type ServerKickResult ¶
type ServerKickResult interface {
// contains filtered or unexported methods
}
ServerKickResult is the result of a KickedFromServerEvent and is implemented by
DisconnectPlayerKickResult ¶
RedirectPlayerKickResult ¶
NotifyKickResult
type ServerPostConnectEvent ¶
type ServerPostConnectEvent struct {
// contains filtered or unexported fields
}
Fired after the player has connected to a server. The server the player is now connected to is available in Player().CurrentServer().
func (*ServerPostConnectEvent) Player ¶
func (s *ServerPostConnectEvent) Player() Player
Player returns the associated player.
func (*ServerPostConnectEvent) PreviousServer ¶
func (s *ServerPostConnectEvent) PreviousServer() RegisteredServer
PreviousServer returns the server the player was previously connected to. May return nil if there was none!
type ServerPreConnectEvent ¶
type ServerPreConnectEvent struct {
// contains filtered or unexported fields
}
ServerPreConnectEvent is fired before the player connects to a server.
func (*ServerPreConnectEvent) Allow ¶
func (e *ServerPreConnectEvent) Allow(server RegisteredServer)
Allow the player to connect to the specified server.
func (*ServerPreConnectEvent) Allowed ¶
func (e *ServerPreConnectEvent) Allowed() bool
Allowed returns true whether the connection is allowed.
func (*ServerPreConnectEvent) Deny ¶
func (e *ServerPreConnectEvent) Deny()
Deny will cancel the player to connect to another server.
func (*ServerPreConnectEvent) OriginalServer ¶
func (e *ServerPreConnectEvent) OriginalServer() RegisteredServer
OriginalServer returns the server that the player originally tried to connect to. To get the server the player will connect to, see the Server() of this event. To get the server the player is currently on when this event is fired, use Player.getCurrentServer().
func (*ServerPreConnectEvent) Player ¶
func (e *ServerPreConnectEvent) Player() Player
Player returns the player that tries to connect to another server.
func (*ServerPreConnectEvent) Server ¶
func (e *ServerPreConnectEvent) Server() RegisteredServer
Server returns the server the player will connect to OR nil if Allowed() returns false.
Source Files ¶
- builtin_commands.go
- command.go
- connect.go
- connection.go
- connection_type.go
- events.go
- phases.go
- player.go
- proxy.go
- server.go
- session_backend_login.go
- session_backend_play.go
- session_backend_transition.go
- session_client_play.go
- session_handshake.go
- session_initial_connect.go
- session_login.go
- session_status.go
- switch.go