Documentation
¶
Index ¶
- Constants
- type AntiCheatInfo
- type Client
- type Context
- type NopProcessor
- func (NopProcessor) ProcessClient(_ *Context, _ *packet.Packet)
- func (NopProcessor) ProcessClientEncoded(_ *Context, _ *[]byte)
- func (NopProcessor) ProcessDisconnection(_ *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) Client() *minecraft.Conn
- func (s *Session) Close() (err error)
- 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) Opts() util.Opts
- func (s *Session) Processor() Processor
- func (s *Session) Server() *server.Conn
- func (s *Session) SetAnimation(animation animation.Animation)
- func (s *Session) SetOpts(opts util.Opts)
- 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 ¶
const ( ClientPacket = 0x01 // Identifier for client packets ServerPacket = 0x02 // Identifier for server packets ACPacket = 0x03 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AntiCheatInfo ¶
type AntiCheatInfo struct {
Identity string `json:"identity"`
DeviceOs int `json:"device_os"`
TitleId string `json:"title_id"`
DisplayName string `json:"display_name"`
EntityRuntimeId uint64 `json:"entity_runtime_id"`
EntityUniqueId int64 `json:"entity_unique_id"`
PlayerPosition mgl32.Vec3 `json:"player_position"`
Pitch float32 `json:"pitch"`
Yaw float32 `json:"yaw"`
GameMode int32 `json:"game_mode"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a persistent connection to the server.
func (*Client) SendClient ¶
SendClient sends data to the server, marking it as a client packet.
type Context ¶
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 ¶
type NopProcessor struct{}
NopProcessor is a no-operation implementation of the Processor interface.
func (NopProcessor) ProcessClient ¶
func (NopProcessor) ProcessClient(_ *Context, _ *packet.Packet)
func (NopProcessor) ProcessClientEncoded ¶
func (NopProcessor) ProcessClientEncoded(_ *Context, _ *[]byte)
func (NopProcessor) ProcessDisconnection ¶
func (NopProcessor) ProcessDisconnection(_ *Context)
func (NopProcessor) ProcessPostTransfer ¶
func (NopProcessor) ProcessPostTransfer(_ *Context, _ *string, _ *string)
func (NopProcessor) ProcessPreTransfer ¶
func (NopProcessor) ProcessPreTransfer(_ *Context, _ *string, _ *string)
func (NopProcessor) ProcessServer ¶
func (NopProcessor) ProcessServer(_ *Context, _ *packet.Packet)
func (NopProcessor) ProcessServerEncoded ¶
func (NopProcessor) ProcessServerEncoded(_ *Context, _ *[]byte)
func (NopProcessor) ProcessStartGame ¶
func (NopProcessor) ProcessStartGame(_ *Context, _ *minecraft.GameData)
func (NopProcessor) ProcessTransferFailure ¶
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)
// 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)
// ProcessDisconnection is called when the player disconnects from the proxy.
ProcessDisconnection(ctx *Context)
}
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(clientConn *minecraft.Conn, logger *slog.Logger, registry *Registry, discovery server.Discovery, opts util.Opts, transport transport.Transport, client *Client) *Session
NewSession creates a new Session instance using the provided minecraft.Conn.
func (*Session) Animation ¶
Animation returns the animation set to be played during server transfers.
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) LoginContext ¶
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 ¶
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 ¶
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.