Documentation
¶
Index ¶
- type Context
- type NopProcessor
- func (NopProcessor) ProcessCache(_ *Context, _ *[]byte)
- func (NopProcessor) ProcessClient(_ *Context, _ *packet.Packet)
- func (NopProcessor) ProcessClientEncoded(_ *Context, _ *[]byte)
- func (NopProcessor) ProcessDisconnection(_ *Context, _ *string)
- func (NopProcessor) ProcessFlush(_ *Context)
- func (NopProcessor) ProcessPostTransfer(_ *Context, _ *string, _ *string)
- func (NopProcessor) ProcessPreTransfer(_ *Context, _ *string, _ *string)
- func (NopProcessor) ProcessServer(_ *Context, _ *packet.Packet)
- func (NopProcessor) ProcessServerEncoded(_ *Context, _ *[]byte)
- func (NopProcessor) ProcessStartGame(_ *Context, _ *minecraft.GameData)
- func (NopProcessor) ProcessTransferFailure(_ *Context, _ *string, _ *string)
- type Processor
- type Registry
- type Session
- func (s *Session) Animation() animation.Animation
- func (s *Session) Cache() []byte
- func (s *Session) Client() *minecraft.Conn
- func (s *Session) Close() (err error)
- func (s *Session) CloseWithError(err error)
- func (s *Session) Context() context.Context
- func (s *Session) Disconnect(message string)
- func (s *Session) Latency() int64
- func (s *Session) Login() (err error)
- func (s *Session) LoginContext(ctx context.Context) (err error)
- func (s *Session) LoginTimeout(duration time.Duration) (err error)
- func (s *Session) Processor() Processor
- func (s *Session) Server() *server.Conn
- func (s *Session) SetAnimation(animation animation.Animation)
- func (s *Session) SetCache(cache []byte)
- func (s *Session) SetProcessor(processor Processor)
- func (s *Session) Transfer(addr string) (err error)
- func (s *Session) TransferContext(ctx context.Context, addr string) (err error)
- func (s *Session) TransferTimeout(addr string, duration time.Duration) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶ added in v0.0.23
type Context struct {
// contains filtered or unexported fields
}
Context represents the context of an action. It holds the state of whether the action has been canceled.
type NopProcessor ¶ added in v0.0.23
type NopProcessor struct{}
NopProcessor is a no-operation implementation of the Processor interface.
func (NopProcessor) ProcessCache ¶ added in v0.0.38
func (NopProcessor) ProcessCache(_ *Context, _ *[]byte)
func (NopProcessor) ProcessClient ¶ added in v0.0.23
func (NopProcessor) ProcessClient(_ *Context, _ *packet.Packet)
func (NopProcessor) ProcessClientEncoded ¶ added in v0.0.26
func (NopProcessor) ProcessClientEncoded(_ *Context, _ *[]byte)
func (NopProcessor) ProcessDisconnection ¶ added in v0.0.23
func (NopProcessor) ProcessDisconnection(_ *Context, _ *string)
func (NopProcessor) ProcessFlush ¶ added in v0.0.38
func (NopProcessor) ProcessFlush(_ *Context)
func (NopProcessor) ProcessPostTransfer ¶ added in v0.0.23
func (NopProcessor) ProcessPostTransfer(_ *Context, _ *string, _ *string)
func (NopProcessor) ProcessPreTransfer ¶ added in v0.0.23
func (NopProcessor) ProcessPreTransfer(_ *Context, _ *string, _ *string)
func (NopProcessor) ProcessServer ¶ added in v0.0.23
func (NopProcessor) ProcessServer(_ *Context, _ *packet.Packet)
func (NopProcessor) ProcessServerEncoded ¶ added in v0.0.26
func (NopProcessor) ProcessServerEncoded(_ *Context, _ *[]byte)
func (NopProcessor) ProcessStartGame ¶ added in v0.0.23
func (NopProcessor) ProcessStartGame(_ *Context, _ *minecraft.GameData)
func (NopProcessor) ProcessTransferFailure ¶ added in v0.0.35
func (NopProcessor) ProcessTransferFailure(_ *Context, _ *string, _ *string)
type Processor ¶
type Processor interface { // ProcessStartGame is called only once during the login sequence. ProcessStartGame(ctx *Context, data *minecraft.GameData) // ProcessServer is called before forwarding the server-sent packets to the client. ProcessServer(ctx *Context, pk *packet.Packet) // ProcessServerEncoded is called before forwarding the server-sent packets to the client. ProcessServerEncoded(ctx *Context, pk *[]byte) // ProcessClient is called before forwarding the client-sent packets to the server. ProcessClient(ctx *Context, pk *packet.Packet) // ProcessClientEncoded is called before forwarding the client-sent packets to the server. ProcessClientEncoded(ctx *Context, pk *[]byte) // ProcessFlush is called before flushing the player's minecraft.Conn buffer in response to a downstream server request. ProcessFlush(ctx *Context) // ProcessPreTransfer is called before transferring the player to a different server. ProcessPreTransfer(ctx *Context, origin *string, target *string) // ProcessTransferFailure is called when the player transfer to a different server fails. ProcessTransferFailure(ctx *Context, origin *string, target *string) // ProcessPostTransfer is called after transferring the player to a different server. ProcessPostTransfer(ctx *Context, origin *string, target *string) // ProcessCache is called before updating the session's cache. ProcessCache(ctx *Context, new *[]byte) // ProcessDisconnection is called when the player disconnects from the proxy. ProcessDisconnection(ctx *Context, message *string) }
Processor defines methods for processing various actions within a proxy session.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) AddSession ¶
func (*Registry) GetSession ¶
func (*Registry) GetSessionByUsername ¶
func (*Registry) GetSessions ¶
func (*Registry) RemoveSession ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a player session within the proxy, managing client and server interactions, including transfers, fallbacks, and tracking various session states.
func NewSession ¶
func NewSession(client *minecraft.Conn, logger *slog.Logger, registry *Registry, discovery server.Discovery, opts util.Opts, transport transport.Transport) *Session
NewSession creates a new Session instance using the provided minecraft.Conn.
func (*Session) Animation ¶ added in v0.0.4
Animation returns the animation set to be played during server transfers.
func (*Session) CloseWithError ¶ added in v0.0.37
func (*Session) Context ¶ added in v0.0.37
Context returns the connection's context. The context is canceled when the session is closed, allowing for cancellation of operations that are tied to the lifecycle of the session.
func (*Session) Disconnect ¶
Disconnect sends a packet.Disconnect to the client and closes the session.
func (*Session) Latency ¶
Latency returns the total latency experienced by the session, combining client and server latencies. The client's latency is derived from half of RakNet's round-trip time (RTT). To calculate the total latency, we multiply this value by 2.
func (*Session) Login ¶ added in v0.0.18
Login initiates the login sequence with a default timeout of 1 minute.
func (*Session) LoginContext ¶ added in v0.0.23
LoginContext initiates the login sequence for the session, including server discovery, establishing a connection, and spawning the player in the game. The process is performed using the provided context for cancellation.
func (*Session) LoginTimeout ¶ added in v0.0.23
LoginTimeout initiates the login sequence with the specified timeout duration.
func (*Session) SetAnimation ¶
SetAnimation sets the animation to be played during server transfers.
func (*Session) SetProcessor ¶
SetProcessor sets a new processor for the session.
func (*Session) Transfer ¶
Transfer initiates a transfer to a different server using the specified address. It sets a default timeout of 1 minute for the transfer operation.
func (*Session) TransferContext ¶ added in v0.0.23
TransferContext initiates a transfer to a different server using the specified address. It ensures that only one transfer occurs at a time, returning an error if another transfer is already in progress. The process is performed using the provided context for cancellation.