gtipc

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: MIT Imports: 25 Imported by: 0

README

gtipc

Golang library for communicating with pocketmine servers via pocketmine's raklib ipc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

func NewConn

func NewConn(log *slog.Logger, conn net.Conn, key string, handler IpcHandler) *Conn

NewConn returns a new conn. Call ReadLoop to start reading packets.

func (*Conn) Close

func (c *Conn) Close()

Close closes the unix conn and all raknet conns

func (*Conn) OpenSession

func (c *Conn) OpenSession(clientAddr string) (net.Conn, error)

OpenSession opens a new session on the PM server

func (*Conn) ReadLoop

func (c *Conn) ReadLoop()

Read loop

func (*Conn) ReadPacket

func (c *Conn) ReadPacket() (packets []ipcprotocol.Packet, err error)

ReadPacket reads an IPC packet from the conn

func (*Conn) WriteCustomPacket

func (c *Conn) WriteCustomPacket(b []byte)

WriteCustomPacket writes a custom packet (Encapsulated with session id set to -1)

func (*Conn) WritePacket

func (c *Conn) WritePacket(pk ipcprotocol.Packet) error

WritePacket writes an IPC packet to the conn

type IpcClient

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

IpcClient implements a client that connects to an ipc server in PM. This is not recommended for proxy usage.

func NewIpcClient

func NewIpcClient(opts *IpcOptions) *IpcClient

NewIpcClient returns a new IPC client

func (*IpcClient) BlockAddress

func (c *IpcClient) BlockAddress(addr net.IP, duration time.Duration)

BlockAddress blocks an IP address from accessing the server

func (*IpcClient) DialContext

func (c *IpcClient) DialContext(ctx context.Context, address string) (net.Conn, error)

func (*IpcClient) GetConn

func (c *IpcClient) GetConn(key string) (*Conn, bool)

func (*IpcClient) GetOrCreateConn

func (c *IpcClient) GetOrCreateConn(path string) (*Conn, error)

func (*IpcClient) Listen

func (c *IpcClient) Listen(address string) (minecraft.NetworkListener, error)

func (*IpcClient) PingContext

func (c *IpcClient) PingContext(ctx context.Context, address string) ([]byte, error)

func (*IpcClient) UnblockAddress

func (c *IpcClient) UnblockAddress(addr net.IP)

UnblockAddress allows a blocked IP address to access te server

type IpcHandler

type IpcHandler interface {
	minecraft.Network

	// BlockAddress blocks an IP address from accessing the server
	BlockAddress(addr net.IP, duration time.Duration)

	// UnblockAddress allows a blocked IP address to access te server
	UnblockAddress(addr net.IP)

	GetConn(key string) (*Conn, bool)
	// contains filtered or unexported methods
}

type IpcOptions

type IpcOptions struct {
	// Handler function for custom packets
	CustomPacketHandler func(b []byte, serverKey string)
	// Upstream handler for additional features intended for proxy usage
	Upstream *UpstreamHandler
	// Logger
	Log *slog.Logger
}

type IpcServer

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

IpcServer implements a server that PM clients connect to. This is recommended for proxy usage.

func NewIPCServer

func NewIPCServer(socketPath string, opts *IpcOptions) (*IpcServer, error)

NewIpcServer returns a new IPC server

func (*IpcServer) BlockAddress

func (l *IpcServer) BlockAddress(addr net.IP, duration time.Duration)

BlockAddress blocks an IP address from accessing the server

func (*IpcServer) Close

func (l *IpcServer) Close()

Close closes all conns and the unix socket

func (*IpcServer) DialContext

func (l *IpcServer) DialContext(ctx context.Context, address string) (net.Conn, error)

func (*IpcServer) GetConn

func (l *IpcServer) GetConn(key string) (*Conn, bool)

GetConn returns a conn with the key, or false if not found

func (*IpcServer) Listen

func (l *IpcServer) Listen(address string) (minecraft.NetworkListener, error)

func (*IpcServer) PingContext

func (l *IpcServer) PingContext(ctx context.Context, address string) (response []byte, err error)

func (*IpcServer) UnblockAddress

func (l *IpcServer) UnblockAddress(addr net.IP)

UnblockAddress allows a blocked IP address to access te server

type IpcStatusProvider

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

func NewIpcStatusProvider

func NewIpcStatusProvider(key string, handler IpcHandler) *IpcStatusProvider

func (*IpcStatusProvider) ServerStatus

func (i *IpcStatusProvider) ServerStatus(int, int) minecraft.ServerStatus

type RakNetUpstream

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

RakNet is an implementation of a RakNet v10 Network with an upstream handler.

func (RakNetUpstream) DialContext

func (r RakNetUpstream) DialContext(ctx context.Context, address string) (net.Conn, error)

DialContext ...

func (RakNetUpstream) Listen

func (r RakNetUpstream) Listen(address string) (minecraft.NetworkListener, error)

Listen ...

func (RakNetUpstream) PingContext

func (r RakNetUpstream) PingContext(ctx context.Context, address string) (response []byte, err error)

PingContext ...

type UpstreamHandler

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

func CreateGophertunnelUpstreamHandler

func CreateGophertunnelUpstreamHandler(name string) *UpstreamHandler

func NewUpstreamHandler

func NewUpstreamHandler(parent raknet.UpstreamPacketListener) *UpstreamHandler

NewUpstreamHandler returns an upstream packet listener with ip block and bandwidth monitoring

func (*UpstreamHandler) ListenPacket

func (q *UpstreamHandler) ListenPacket(network, address string) (conn net.PacketConn, err error)

Directories

Path Synopsis
example
client command
server command
io

Jump to

Keyboard shortcuts

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