proxy

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2021 License: Apache-2.0 Imports: 52 Imported by: 47

Documentation

Overview

Package proxy contains Gate's Minecraft Java edition proxy implementation.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoBackendConnection = errors.New("player has no backend server connection yet")
	ErrTooLongChatMessage  = errors.New("server bound chat message can not exceed 256 characters")
)
View Source
var ErrClosedConn = errors.New("connection is closed")

Indicates a connection is already closed.

View Source
var ErrProxyAlreadyRun = errors.New("proxy was already run, create a new one")

Returned by Proxy.Run if the proxy instance was already run.

View Source
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.

View Source
var (

	// Indicates that the connection is a 1.8-1.12 Forge connection.
	LegacyForge connectionType = &legacyForgeConnType{
		connType: &connType{
			initialClientPhase_:  notStartedLegacyForgeHandshakeClientPhase,
			initialBackendPhase_: notStartedLegacyForgeHandshakeBackendPhase,
		},
	}
)
View Source
var Plugins []Plugin

Plugins is used to register plugins with the proxy. The plugin's init hook is run after the proxy is initialized and before serving any connections.

If one init hook errors, the proxy cancels the boot and shuts down; will fire the ShutdownEvent so other plugins can gracefully de-initialize.

Functions

This section is empty.

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

type Command interface {
	Invoke(*Context)
}

Command is an invokable command.

type CommandExecuteEvent

type CommandExecuteEvent struct {
	// contains filtered or unexported fields
}

CommandExecuteEvent is fired when someone wants to execute a command.

func (*CommandExecuteEvent) Allowed

func (c *CommandExecuteEvent) Allowed() bool

Allowed returns true when the command is allowed to be executed.

func (*CommandExecuteEvent) Command

func (c *CommandExecuteEvent) Command() string

Command returns the whole commandline without the leading "/".

func (*CommandExecuteEvent) SetAllowed

func (c *CommandExecuteEvent) SetAllowed(allowed bool)

SetAllowed sets whether the command is allowed to be executed.

func (*CommandExecuteEvent) Source

func (c *CommandExecuteEvent) Source() CommandSource

Source returns the command source that wants to run the command.

type CommandFunc

type CommandFunc func(*Context)

CommandFunc is a shorthand type that implements the Command interface.

func (CommandFunc) Invoke

func (f CommandFunc) Invoke(c *Context)

Invoke implements Command.

type CommandManager

type CommandManager struct {
	// contains filtered or unexported fields
}

CommandManager stores commands.

func (*CommandManager) Has

func (m *CommandManager) Has(command string) bool

Has return true if the command is registered.

func (*CommandManager) Invoke

func (m *CommandManager) Invoke(ctx *Context, command string) (found bool, err error)

Invoke invokes a registered command.

func (*CommandManager) Register

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

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

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

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 canceled, 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

type Context struct {
	context.Context               // The context to propagate to subprocesses of the command invocation.
	Source          CommandSource // The one executing the command.
	Args            []string      // The command arguments (without the "/<command>" part)
}

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

type DisconnectPlayerKickResult struct {
	Reason component.Component
}

DisconnectPlayerKickResult is a ServerKickResult and tells the proxy to disconnect the player with the specified reason.

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

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 to know when the connection was closed.
	// (e.g. for canceling work in an event handler)
	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

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

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

type NotifyKickResult struct {
	Message component.Component
}

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 Options

type Options struct {
	// Config requires configuration
	// validated by config.Validate.
	Config *config.Config
	// The event manager to use.
	// If none is set, no events are sent.
	EventMgr event.Manager
	// Logger is the logger to be used by the Proxy.
	// If none is set, does no logging at all.
	Logger logr.Logger
	// Authenticator to authenticate users in online mode.
	// If not set, creates a default one.
	Authenticator auth.Authenticator
}

Options are the options for a new Java edition Proxy.

type PermissionsSetupEvent

type PermissionsSetupEvent struct {
	// contains filtered or unexported fields
}

PermissionsSetupEvent is fired once a permission.Subject's permissions are being initialized.

func (*PermissionsSetupEvent) Func

Func returns the permission.Func used for the subject.

func (*PermissionsSetupEvent) SetFunc

func (p *PermissionsSetupEvent) SetFunc(fn permission.Func)

SetFunc sets the permission.Func usec for the subject. If fn is nil, the default Func fill be used.

func (*PermissionsSetupEvent) Subject

Subject returns the subject the permissions are setup for.

type PingEvent

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

func (p *PingEvent) Connection() Inbound

Connection returns the inbound connection.

func (*PingEvent) Ping

func (p *PingEvent) Ping() *ping.ServerPing

Ping returns the used ping. (pre-initialized by the proxy)

func (*PingEvent) SetPing

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 ID 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

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

func (c *PlayerChatEvent) Allowed() bool

Allowed returns true when the chat message is allowed.

func (*PlayerChatEvent) Message

func (c *PlayerChatEvent) Message() string

Message returns the message the player sent.

func (*PlayerChatEvent) Player

func (c *PlayerChatEvent) Player() Player

Player returns the player that sent the message.

func (*PlayerChatEvent) SetAllowed

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

InitialServer returns the initial server or nil if no server is configured.

func (*PlayerChooseInitialServerEvent) Player

Player returns the player to find the initial server for.

func (*PlayerChooseInitialServerEvent) SetInitialServer

func (e *PlayerChooseInitialServerEvent) SetInitialServer(server RegisteredServer)

SetInitialServer sets the initial server for the player.

type PlayerModInfoEvent

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

func (e *PlayerModInfoEvent) ModInfo() modinfo.ModInfo

ModInfo is the mod info received by the player.

func (*PlayerModInfoEvent) Player

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

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 Plugin

type Plugin struct {
	Name string                   // The name identifying the plugin.
	Init func(proxy *Proxy) error // The hook to initialize the plugin.
}

Plugin provides the ability to extend Gate with external code.

Quick notes on Go's plugin system:

We don't support Go's plugin system as it is not a mature solution. They force your plugin implementation to be highly-coupled with Gate's build toolchain, the end-result would be very brittle, hard to maintain and the overhead would be much higher if the plugin author does not have any control over new versions of Gate.

Now with that made clear, here is how Gate can be customized!

Native Go:

	You can use Gate as a framework and compile your code with it.
 - Create your own Go project/module and `go get -u go.minekube.com/gate`
 - Within your main function
  - Add your Plugin to the Plugins
  - And call cmd/gate.Execute (blocking your main until shutdown).
 - Subscribe to proxy.ShutdownEvent for de-initializing your plugin.

By running cmd/gate.Execute, Gate will do the whole rest.

  • load the config (parse found file, flags and env vars)
  • make and run the proxy.Proxy that will call the Plugins init hooks.

Script languages:

  • Not yet supported.

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 (*PluginMessageEvent) SetForward

func (p *PluginMessageEvent) SetForward(forward bool)

func (*PluginMessageEvent) Source

func (*PluginMessageEvent) Target

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 PreShutdownEvent

type PreShutdownEvent struct {
	// contains filtered or unexported fields
}

PreShutdownEvent is fired before the proxy begins to shut down by stopping to accept new connections and disconnect all players.

func (*PreShutdownEvent) Reason

func (s *PreShutdownEvent) Reason() component.Component

Reason returns the shutdown reason used to disconnect players with. May be nil!

func (*PreShutdownEvent) SetReason

func (s *PreShutdownEvent) SetReason(reason component.Component)

Reason returns the shutdown reason used to disconnect players with.

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy is Gate's Java edition Minecraft proxy.

func New

func New(options Options) (p *Proxy, err error)

New returns a new Proxy ready to start.

func (*Proxy) ChannelRegistrar

func (p *Proxy) ChannelRegistrar() *ChannelRegistrar

func (*Proxy) Command

func (p *Proxy) Command() *CommandManager

Command returns the Proxy's command manager.

func (*Proxy) Config

func (p *Proxy) Config() config.Config

Config returns the config used by the Proxy.

func (*Proxy) DisconnectAll

func (p *Proxy) DisconnectAll(reason component.Component)

DisconnectAll disconnects all current connected players in parallel. It is done in parallel

func (*Proxy) Event

func (p *Proxy) Event() event.Manager

Event returns the Proxy's event manager.

func (*Proxy) Player

func (p *Proxy) Player(id uuid.UUID) Player

Player returns the online player by their Minecraft id. Returns nil if the player was not found.

func (*Proxy) PlayerByName

func (p *Proxy) PlayerByName(username string) Player

Player returns the online player by their Minecraft name (search is case-insensitive). Returns nil if the player was not found.

func (*Proxy) PlayerCount

func (p *Proxy) PlayerCount() int

PlayerCount returns the number of players on the proxy.

func (*Proxy) Players

func (p *Proxy) Players() []Player

Players returns all 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 specified ServerInfo is invalid, returns nil and false.

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

func (p *Proxy) Shutdown(reason component.Component)

Shutdown stops the Proxy and/or blocks until the Proxy has finished shutdown.

It first stops listening for new connections, disconnects all existing connections with the given reason (nil = blank reason) and waits for all event subscribers to finish.

func (*Proxy) Start

func (p *Proxy) Start(stop <-chan struct{}) error

Start runs the Java edition Proxy, blocks until the proxy is Shutdown or an error occurred while starting. The Proxy is already shutdown on method return. Another method of stopping the Proxy is to call Shutdown. A Proxy can only be run once or ErrProxyAlreadyRun is returned.

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 ReadyEvent

type ReadyEvent struct{}

ReadyEvent is fired once the proxy was successfully initialized and is ready to serve connections.

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 before the player completely transitions to the target server and the connection to the previous server has been de-established.

Use Server to get the target server since Player.CurrentServer is yet nil or listen for ServerPostConnectEvent instead.

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

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

Server returns the server the player will connect to OR nil if Allowed() returns false.

type ShutdownEvent

type ShutdownEvent struct{}

ShutdownEvent is fired by the proxy after the proxy has stopped accepting connections and PreShutdownEvent, but before the proxy process exits.

Subscribe to this event to gracefully stop any subtasks, such as plugin dependencies.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL