proxy

package
v1.54.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 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 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 Context

type Context struct {
	OnPlayerMove []func()
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, settings ProxySettings) (*Context, error)

New creates a new proxy context

func (*Context) AddHandler

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

AddHandler adds a handler to the proxy

func (*Context) Context added in v1.45.1

func (p *Context) Context() context.Context

func (*Context) Run

func (p *Context) Run(ctx context.Context, withClient bool) (err error)

type Handler

type Handler struct {
	Name string

	SessionStart       func(s *Session, serverName string) error
	PlayerDataModifier func(s *Session, identity *login.IdentityData, data *login.ClientData)
	GameDataModifier   func(s *Session, gameData *minecraft.GameData)
	FilterResourcePack func(s *Session, id string) bool
	OnFinishedPack     func(s *Session, pack resource.Pack) error

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

	OnServerConnect func(s *Session) (cancel bool, err error)
	OnConnect       func(s *Session) (cancel bool)

	OnSessionEnd func(s *Session, wg *sync.WaitGroup)
	OnBlobs      func(s *Session, blobs []protocol.CacheBlob)

	OnPlayerMove func(s *Session)
}

type Handlers added in v1.39.1

type Handlers []*Handler

func (Handlers) FilterResourcePack added in v1.39.1

func (h Handlers) FilterResourcePack(s *Session, id string) bool

func (Handlers) GameDataModifier added in v1.39.1

func (h Handlers) GameDataModifier(s *Session, gameData *minecraft.GameData)

func (Handlers) OnBlobs added in v1.45.1

func (h Handlers) OnBlobs(s *Session, blobs []protocol.CacheBlob)

func (Handlers) OnConnect added in v1.39.1

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

func (Handlers) OnFinishedPack added in v1.39.1

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

func (Handlers) OnPlayerMove added in v1.51.0

func (h Handlers) OnPlayerMove(s *Session)

func (Handlers) OnServerConnect added in v1.39.1

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

func (Handlers) OnSessionEnd added in v1.39.1

func (h Handlers) OnSessionEnd(s *Session, wg *sync.WaitGroup)

func (Handlers) PacketCallback added in v1.39.1

func (h Handlers) PacketCallback(s *Session, 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(s *Session, header packet.Header, payload []byte, src, dst net.Addr, timeReceived time.Time)

func (Handlers) PlayerDataModifier added in v1.46.0

func (h Handlers) PlayerDataModifier(s *Session, identity *login.IdentityData, data *login.ClientData)

func (Handlers) SessionStart added in v1.39.1

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

type NetherNet added in v1.54.0

type NetherNet struct {
	Signaling nethernet.Signaling

	// Dialer specifies options for establishing a connection with DialContext.
	Dialer nethernet.Dialer
	// ListenConfig specifies options for listening for connections with Listen.
	ListenConfig nethernet.ListenConfig
}

NetherNet is an implementation of NetherNet network. Unlike RakNet, it needs to be registered manually with a Signaling.

func (NetherNet) DialContext added in v1.54.0

func (n NetherNet) DialContext(ctx context.Context, address string) (net.Conn, error)

DialContext ...

func (NetherNet) Listen added in v1.54.0

Listen ...

func (NetherNet) PingContext added in v1.54.0

func (n NetherNet) PingContext(context.Context, string) ([]byte, error)

PingContext ...

type PacketFunc

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

type Player

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

type ProxySettings added in v1.45.1

type ProxySettings struct {
	ConnectInfo *connectinfo.ConnectInfo `opt:"Address" flag:"address" desc:"locale.remote_address"`

	Debug         bool   `opt:"Debug" flag:"debug" desc:"locale.debug_mode"`
	ExtraDebug    bool   `opt:"Extra Debug" flag:"extra-debug" desc:"extra debug info (packet.log)"`
	Capture       bool   `opt:"Packet Capture" flag:"capture" desc:"Capture pcap2 file"`
	ClientCache   bool   `opt:"Client Cache" flag:"client-cache" default:"true" desc:"Enable Client Cache"`
	ListenAddress string `opt:"Listen Address" flag:"listen" default:"0.0.0.0:19132" desc:"example :19132 or 127.0.0.1:19132"`
}

type Session added in v1.39.1

type Session struct {
	Server minecraft.IConn
	Client minecraft.IConn
	Player Player
	// contains filtered or unexported fields
}

func NewSession added in v1.39.1

func NewSession(ctx context.Context, settings ProxySettings, addedPacks []resource.Pack, connectInfo *connectinfo.ConnectInfo, withClient bool) *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) Now added in v1.51.0

func (s *Session) Now() time.Time

func (*Session) Run added in v1.39.1

func (s *Session) Run() 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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