proxy

package
v1.41.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: GPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewPacketCapturer func() (*Handler, func([]protocol.CacheBlob))

Functions

func DecodePacket

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

func NewPacketLogger added in v1.40.0

func NewPacketLogger(verbose, clientSide bool) (*packetLogger, error)

Types

type Blobcache added in v1.40.0

type Blobcache struct {
	OnHitBlobs func(blobs []protocol.CacheBlob)
	// contains filtered or unexported fields
}

func NewBlobCache added in v1.40.0

func NewBlobCache(session *Session) (*Blobcache, error)

func (*Blobcache) Close added in v1.40.0

func (b *Blobcache) Close() error

func (*Blobcache) HandleClientCacheBlobStatus added in v1.40.0

func (b *Blobcache) HandleClientCacheBlobStatus(pk *packet.ClientCacheBlobStatus) error

func (*Blobcache) HandleClientCacheMissResponse added in v1.40.0

func (b *Blobcache) HandleClientCacheMissResponse(pk *packet.ClientCacheMissResponse, timeReceived time.Time, preLogin bool) error

func (*Blobcache) HandleLevelChunk added in v1.40.0

func (b *Blobcache) HandleLevelChunk(pk *packet.LevelChunk, timeReceived time.Time, preLogin bool) (pkForward packet.Packet, err error)

func (*Blobcache) HandleSubChunk added in v1.40.0

func (b *Blobcache) HandleSubChunk(pk *packet.SubChunk, timeReceived time.Time, preLogin bool) (pkForward packet.Packet, err error)

type Context

type Context struct {
	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) AddHandler

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

AddHandler adds a handler to the proxy

func (*Context) Run

func (p *Context) Run(ctx context.Context, connect *utils.ConnectInfo) (err error)

type Handler

type Handler struct {
	Name string

	SessionStart       func(s *Session, serverName string) error
	GameDataModifier   func(gameData *minecraft.GameData)
	FilterResourcePack func(id string) bool
	OnFinishedPack     func(pack resource.Pack) error

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

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

	OnSessionEnd func()
	OnProxyEnd   func()
}

type Handlers added in v1.39.1

type Handlers []*Handler

func (*Handlers) FilterResourcePack added in v1.39.1

func (h *Handlers) FilterResourcePack(id string) bool

func (*Handlers) GameDataModifier added in v1.39.1

func (h *Handlers) GameDataModifier(gameData *minecraft.GameData)

func (*Handlers) OnConnect added in v1.39.1

func (h *Handlers) OnConnect() (cancel bool)

func (*Handlers) OnFinishedPack added in v1.39.1

func (h *Handlers) OnFinishedPack(pack resource.Pack) error

func (*Handlers) OnProxyEnd added in v1.39.1

func (h *Handlers) OnProxyEnd()

func (*Handlers) OnServerConnect added in v1.39.1

func (h *Handlers) OnServerConnect() (cancel bool, err error)

func (*Handlers) OnSessionEnd added in v1.39.1

func (h *Handlers) OnSessionEnd()

func (*Handlers) PacketCallback added in v1.39.1

func (h *Handlers) PacketCallback(pk packet.Packet, toServer bool, timeReceived time.Time, preLogin bool) (packet.Packet, error)

func (*Handlers) PacketRaw added in v1.39.1

func (h *Handlers) PacketRaw(header packet.Header, payload []byte, src, dst net.Addr, timeReceived time.Time)

func (*Handlers) SessionStart added in v1.39.1

func (h *Handlers) SessionStart(s *Session, serverName string) error

type PacketFunc

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

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, resourcePackHandler *rpHandler) (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(ids ...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

type Session added in v1.39.1

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

	Player Player

	OnHitBlobs func(hitBlobs []protocol.CacheBlob)
	// contains filtered or unexported fields
}

func NewSession added in v1.39.1

func NewSession() *Session

func (*Session) AddCommand added in v1.39.1

func (s *Session) AddCommand(exec func([]string) bool, cmd protocol.Command)

AddCommand adds a command to the command handler

func (*Session) ClientWritePacket added in v1.39.1

func (s *Session) ClientWritePacket(pk packet.Packet) error

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

func (*Session) Disconnect added in v1.39.1

func (s *Session) Disconnect()

Disconnect disconnects both the client and server

func (*Session) DisconnectClient added in v1.39.1

func (s *Session) DisconnectClient()

Disconnect disconnects the client

func (*Session) DisconnectServer added in v1.39.1

func (s *Session) DisconnectServer()

Disconnect disconnects from the server

func (*Session) IsClient added in v1.39.1

func (s *Session) IsClient(addr net.Addr) bool

func (*Session) Run added in v1.39.1

func (s *Session) Run(ctx context.Context, connect *utils.ConnectInfo) error

func (*Session) SendMessage added in v1.39.1

func (s *Session) SendMessage(text string)

SendMessage sends a chat message to the client

func (*Session) SendPopup added in v1.39.1

func (s *Session) SendPopup(text string)

SendPopup sends a toolbar popup to the client

Jump to

Keyboard shortcuts

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