proxy

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewPacketCapturer func() *Handler

Functions

func CreateReplayConnector

func CreateReplayConnector(ctx context.Context, filename string, packetFunc PacketFunc, onResourcePackInfo func(), OnFinishedPack func(*resource.Pack)) (r *replayConnector, err error)

func DecodePacket

func DecodePacket(header packet.Header, payload []byte) (pk packet.Packet, ok bool)

Types

type Context

type Context struct {
	Server minecraft.IConn
	Client minecraft.IConn

	Player       Player
	ExtraDebug   bool
	PlayerMoveCB []func()
	// contains filtered or unexported fields
}

func New

func New(uiHandler messages.Handler, withClient bool) (*Context, error)

New creates a new proxy context

func (*Context) AddCommand

func (p *Context) AddCommand(exec func([]string) bool, cmd protocol.Command)

AddCommand adds a command to the command handler

func (*Context) AddHandler

func (p *Context) AddHandler(handler *Handler)

AddHandler adds a handler to the proxy

func (*Context) ClientWritePacket

func (p *Context) ClientWritePacket(pk packet.Packet) error

ClientWritePacket sends a packet to the client, nop if no client connected

func (*Context) Disconnect

func (p *Context) Disconnect()

Disconnect disconnects both the client and server

func (*Context) DisconnectClient

func (p *Context) DisconnectClient()

Disconnect disconnects the client

func (*Context) DisconnectServer

func (p *Context) DisconnectServer()

Disconnect disconnects from the server

func (*Context) IsClient

func (p *Context) IsClient(addr net.Addr) bool

func (*Context) Run

func (p *Context) Run(ctx context.Context, connectString string) (err error)

func (*Context) SendMessage

func (p *Context) SendMessage(text string)

SendMessage sends a chat message to the client

func (*Context) SendPopup

func (p *Context) SendPopup(text string)

SendPopup sends a toolbar popup to the client

type Handler

type Handler struct {
	Name     string
	ProxyRef func(pc *Context)
	//
	AddressAndName func(address, hostname string) error

	// called to change game data
	ToClientGameDataModifier func(gd *minecraft.GameData)

	// Called with raw packet data
	PacketRaw func(header packet.Header, payload []byte, src, dst net.Addr)

	// called on every packet after login
	PacketCB func(pk packet.Packet, toServer bool, timeReceived time.Time, preLogin bool) (packet.Packet, error)

	// called after client connected
	OnClientConnect func(conn minecraft.IConn)

	// called after server connected & downloaded resource packs
	OnServerConnect func() (cancel bool, err error)
	// called after game started
	ConnectCB func() bool

	// called when the proxy session stops or is reconnected
	OnEnd func()
	// called when the proxy ends
	Deferred func()
}

func NewDebugLogger

func NewDebugLogger(extraVerbose bool) *Handler

type PacketFunc

type PacketFunc func(header packet.Header, payload []byte, src, dst net.Addr)

type Player

type Player struct {
	RuntimeID           uint64
	Position            mgl32.Vec3
	Pitch, Yaw, HeadYaw float32
}

Jump to

Keyboard shortcuts

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