proxy

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewPacketCapturer func() *Handler

Functions

func DecodePacket

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

Types

type Context

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

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

func New

func New(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

	ProxyReference   func(c *Context)
	GameDataModifier func(gameData *minecraft.GameData)
	OnAddressAndName func(address, hostname string) error

	PacketRaw      func(header packet.Header, payload []byte, src, dst net.Addr)
	PacketCallback func(pk packet.Packet, toServer bool, timeReceived time.Time, preLogin bool) (packet.Packet, error)

	OnClientConnect func()
	OnServerConnect func() (cancel bool, err error)
	OnConnect       func() (cancel bool)

	OnSessionEnd func()
	OnProxyEnd   func()
}

func NewDebugLogger

func NewDebugLogger(extraVerbose bool) *Handler

type PacketFunc

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

type Pcap2Reader added in v1.39.0

type Pcap2Reader struct {
	Version uint32

	ResourcePacks *replayCache

	CurrentPacket int

	PacketFunc PacketFunc
	// contains filtered or unexported fields
}

func NewPcap2Reader added in v1.39.0

func NewPcap2Reader(f *os.File) (*Pcap2Reader, error)

func (*Pcap2Reader) ReadBack added in v1.39.0

func (r *Pcap2Reader) ReadBack() (pk packet.Packet, toServer bool, receivedTime time.Time, err error)

func (*Pcap2Reader) ReadPacket added in v1.39.0

func (r *Pcap2Reader) ReadPacket(skip bool) (pk packet.Packet, toServer bool, receivedTime time.Time, err error)

func (*Pcap2Reader) Seek added in v1.39.0

func (r *Pcap2Reader) Seek(packet int) error

type Player

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

type ReplayConnector added in v1.39.0

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

func CreateReplayConnector

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

func (*ReplayConnector) Authenticated added in v1.39.0

func (r *ReplayConnector) Authenticated() bool

func (*ReplayConnector) ChunkRadius added in v1.39.0

func (r *ReplayConnector) ChunkRadius() int

func (*ReplayConnector) ClientCacheEnabled added in v1.39.0

func (r *ReplayConnector) ClientCacheEnabled() bool

func (*ReplayConnector) ClientData added in v1.39.0

func (r *ReplayConnector) ClientData() login.ClientData

func (*ReplayConnector) Close added in v1.39.0

func (r *ReplayConnector) Close() error

func (*ReplayConnector) DoSpawn added in v1.39.0

func (r *ReplayConnector) DoSpawn() error

func (*ReplayConnector) DoSpawnContext added in v1.39.0

func (r *ReplayConnector) DoSpawnContext(ctx context.Context) error

func (*ReplayConnector) DoSpawnTimeout added in v1.39.0

func (r *ReplayConnector) DoSpawnTimeout(timeout time.Duration) error

func (*ReplayConnector) Expect added in v1.39.0

func (r *ReplayConnector) Expect(...uint32)

func (*ReplayConnector) Flush added in v1.39.0

func (r *ReplayConnector) Flush() error

func (*ReplayConnector) GameData added in v1.39.0

func (r *ReplayConnector) GameData() minecraft.GameData

func (*ReplayConnector) IdentityData added in v1.39.0

func (r *ReplayConnector) IdentityData() login.IdentityData

func (*ReplayConnector) Latency added in v1.39.0

func (r *ReplayConnector) Latency() time.Duration

func (*ReplayConnector) LocalAddr added in v1.39.0

func (r *ReplayConnector) LocalAddr() net.Addr

func (*ReplayConnector) OnDisconnect added in v1.39.0

func (r *ReplayConnector) OnDisconnect() <-chan struct{}

func (*ReplayConnector) Read added in v1.39.0

func (r *ReplayConnector) Read(b []byte) (n int, err error)

func (*ReplayConnector) ReadPacket added in v1.39.0

func (r *ReplayConnector) ReadPacket() (pk packet.Packet, err error)

func (*ReplayConnector) ReadPacketWithTime added in v1.39.0

func (r *ReplayConnector) ReadPacketWithTime() (pk packet.Packet, receivedAt time.Time, err error)

func (*ReplayConnector) ReadUntilLogin added in v1.39.0

func (r *ReplayConnector) ReadUntilLogin() error

func (*ReplayConnector) RemoteAddr added in v1.39.0

func (r *ReplayConnector) RemoteAddr() net.Addr

func (*ReplayConnector) ResourcePacks added in v1.39.0

func (r *ReplayConnector) ResourcePacks() []resource.Pack

func (*ReplayConnector) SetDeadline added in v1.39.0

func (r *ReplayConnector) SetDeadline(t time.Time) error

func (*ReplayConnector) SetGameData added in v1.39.0

func (r *ReplayConnector) SetGameData(data minecraft.GameData)

func (*ReplayConnector) SetLoggedIn added in v1.39.0

func (r *ReplayConnector) SetLoggedIn()

func (*ReplayConnector) SetReadDeadline added in v1.39.0

func (r *ReplayConnector) SetReadDeadline(t time.Time) error

func (*ReplayConnector) SetWriteDeadline added in v1.39.0

func (r *ReplayConnector) SetWriteDeadline(time.Time) error

func (*ReplayConnector) ShieldID added in v1.39.0

func (r *ReplayConnector) ShieldID() int32

func (*ReplayConnector) StartGame added in v1.39.0

func (r *ReplayConnector) StartGame(data minecraft.GameData) error

func (*ReplayConnector) StartGameContext added in v1.39.0

func (r *ReplayConnector) StartGameContext(ctx context.Context, data minecraft.GameData) error

func (*ReplayConnector) StartGameTimeout added in v1.39.0

func (r *ReplayConnector) StartGameTimeout(data minecraft.GameData, timeout time.Duration) error

func (*ReplayConnector) Write added in v1.39.0

func (r *ReplayConnector) Write(b []byte) (n int, err error)

func (*ReplayConnector) WritePacket added in v1.39.0

func (r *ReplayConnector) WritePacket(pk packet.Packet) error

Jump to

Keyboard shortcuts

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