net

package
v1.16.5-pre2.0...-5b980bd Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package net pack network connection for Minecraft.

Index

Constants

View Source
const MaxRCONPackageSize = 4096

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Socket net.Conn
	io.Reader
	io.Writer
	// contains filtered or unexported fields
}

Conn is a minecraft Connection

func DialMC

func DialMC(addr string) (*Conn, error)

DialMC create a Minecraft connection

func DialMCTimeout

func DialMCTimeout(addr string, timeout time.Duration) (*Conn, error)

DialMCTimeout acts like DialMC but takes a timeout.

func WrapConn

func WrapConn(conn net.Conn) *Conn

WrapConn warp an net.Conn to MC-Conn Helps you modify the connection process (eg. using DialContext).

func (*Conn) Close

func (c *Conn) Close() error

Close close the connection

func (*Conn) ReadPacket

func (c *Conn) ReadPacket(p *pk.Packet) error

ReadPacket read a Packet from Conn.

func (*Conn) SetCipher

func (c *Conn) SetCipher(ecoStream, decoStream cipher.Stream)

SetCipher load the decode/encode stream to this Conn

func (*Conn) SetThreshold

func (c *Conn) SetThreshold(t int)

SetThreshold set threshold to Conn. The data packet with length longer then threshold will be compress when sending.

func (*Conn) WritePacket

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

WritePacket write a Packet to Conn.

type Listener

type Listener struct{ net.Listener }

A Listener is a minecraft Listener

func ListenMC

func ListenMC(addr string) (*Listener, error)

ListenMC listen as TCP but Accept a mc Conn

func (Listener) Accept

func (l Listener) Accept() (Conn, error)

Accept a minecraft Conn

type RCONClientConn

type RCONClientConn interface {
	Cmd(cmd string) error
	Resp() (resp string, err error)
	Close() error
}

func DialRCON

func DialRCON(addr string, password string) (client RCONClientConn, err error)

type RCONConn

type RCONConn struct {
	net.Conn
	ReqID int32
}

func (*RCONConn) AcceptCmd

func (r *RCONConn) AcceptCmd() (string, error)

func (*RCONConn) AcceptLogin

func (r *RCONConn) AcceptLogin(password string) error

func (*RCONConn) Cmd

func (r *RCONConn) Cmd(cmd string) error

func (*RCONConn) ReadPacket

func (r *RCONConn) ReadPacket() (RequestID, Type int32, Payload string, err error)

func (*RCONConn) Resp

func (r *RCONConn) Resp() (resp string, err error)

func (*RCONConn) RespCmd

func (r *RCONConn) RespCmd(resp string) error

func (*RCONConn) WritePacket

func (r *RCONConn) WritePacket(RequestID, Type int32, Payload string) error

type RCONListener

type RCONListener struct{ net.Listener }

func ListenRCON

func ListenRCON(addr string) (*RCONListener, error)

func (*RCONListener) Accept

func (r *RCONListener) Accept() (RCONServerConn, error)

type RCONServerConn

type RCONServerConn interface {
	AcceptLogin(password string) error
	AcceptCmd() (cmd string, err error)
	RespCmd(resp string) error
	Close() error
}

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

type Reader

type Reader interface {
	ReadPacket() (pk.Packet, error)
}

type Writer

type Writer interface {
	WritePacket(p pk.Packet) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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