net

package module
v0.0.0-...-4932711 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 16 Imported by: 0

README

JungleMC Net

Go library for networking with Minecraft Java Edition

Documentation

Index

Constants

View Source
const Version = "1.16.5"

Variables

This section is empty.

Functions

func WritePacket

func WritePacket(buf *bytes.Buffer, v reflect.Value, proto protocol.Protocol, compressed bool, compressionThreshold int)

Types

type Client

type Client struct {
	Connection          net.Conn
	Server              *Server
	Protocol            protocol.Protocol
	GameProtocolVersion int32

	Profile             auth.Profile
	ExpectedVerifyToken []byte
	EncryptionEnabled   bool

	CompressionEnabled bool
	// contains filtered or unexported fields
}

func (*Client) Disconnect

func (c *Client) Disconnect(reason string)

func (*Client) EnableEncryption

func (c *Client) EnableEncryption(sharedSecret []byte) (err error)

func (*Client) Send

func (c *Client) Send(pkt Packet) (err error)

type Packet

type Packet interface{}

func ReadPacket

func ReadPacket(buf *bytes.Buffer, proto protocol.Protocol, compressed bool) (Packet, error)

type Server

type Server struct {
	Address string
	Port    uint16

	OnlineMode           bool
	CompressionThreshold int
	Debug                bool
	Verbose              bool
	MaxOnlinePlayers     int32

	HandshakeHandlers map[reflect.Type]func(c *Client, pkt Packet) error
	StatusHandlers    map[reflect.Type]func(c *Client, pkt Packet) error
	LoginHandlers     map[reflect.Type]func(c *Client, pkt Packet) error
	PlayHandlers      map[reflect.Type]func(c *Client, pkt Packet) error

	DisconnectHandler func(c *Client, reason string)
	// contains filtered or unexported fields
}

func NewServer

func NewServer(address string, port uint16, onlineMode bool, compressionThreshold int, debug bool, verbose bool, handshake, status, login, play map[reflect.Type]func(c *Client, pkt Packet) error, disconnect func(c *Client, reason string)) *Server

func (*Server) GenerateKeys

func (s *Server) GenerateKeys()

func (*Server) Listen

func (s *Server) Listen() error

func (*Server) PrivateKey

func (s *Server) PrivateKey() *rsa.PrivateKey

func (*Server) PublicKey

func (s *Server) PublicKey() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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