utils

package
v1.24.10 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: GPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const SERVER_ADDRESS_HELP = `accepted server address formats:
  123.234.123.234
  123.234.123.234:19132
  realm:<Realmname>
  realm:<Realmname>:<Id>

`
View Source
const TOKEN_FILE = "token.json"

Variables

View Source
var (
	G_debug         bool
	G_preload_packs bool
	G_exit          []func() = []func(){}
)
View Source
var Client_addr net.Addr
View Source
var ExtraVerbose []string
View Source
var G_disconnect_reason = "Connection lost"
View Source
var G_realms_api *realms.Client
View Source
var G_token_src oauth2.TokenSource
View Source
var MutedPackets = []string{
	"packet.UpdateBlock",
	"packet.MoveActorAbsolute",
	"packet.SetActorMotion",
	"packet.SetTime",
	"packet.RemoveActor",
	"packet.AddActor",
	"packet.UpdateAttributes",
	"packet.Interact",
	"packet.LevelEvent",
	"packet.SetActorData",
	"packet.MoveActorDelta",
	"packet.MovePlayer",
	"packet.BlockActorData",
	"packet.PlayerAuthInput",
	"packet.LevelChunk",
	"packet.LevelSoundEvent",
	"packet.ActorEvent",
	"packet.NetworkChunkPublisherUpdate",
	"packet.UpdateSubChunkBlocks",
	"packet.SubChunk",
	"packet.SubChunkRequest",
	"packet.Animate",
	"packet.NetworkStackLatency",
	"packet.InventoryTransaction",
	"packet.PlaySound",
}
View Source
var Pool = packet.NewPool()
View Source
var PrivateIPNetworks = []net.IPNet{
	{
		IP:   net.ParseIP("10.0.0.0"),
		Mask: net.CIDRMask(8, 32),
	},
	{
		IP:   net.ParseIP("172.16.0.0"),
		Mask: net.CIDRMask(12, 32),
	},
	{
		IP:   net.ParseIP("192.168.0.0"),
		Mask: net.CIDRMask(16, 32),
	},
}
View Source
var Updater = &selfupdate.Updater{
	CurrentVersion: Version,
	ApiURL:         updateServer,
	BinURL:         updateServer,
	Dir:            "update/",
	CmdName:        "bedrocktool",
}
View Source
var ValidCMDs = make(map[string]string, 0)
View Source
var Version string

Functions

func BlendColors

func BlendColors(c1, c2 color.RGBA) (ret color.RGBA)

func Clamp

func Clamp(a, b int) int

func CleanupName

func CleanupName(name string) string

cleans name so it can be used as a filename

func ConnectServer

func ConnectServer(ctx context.Context, address string, ClientData *login.ClientData, want_packs bool, packetFunc PacketFunc) (serverConn *minecraft.Conn, err error)

func GetLocalIP

func GetLocalIP() string

GetLocalIP returns the non loopback local IP of the host

func GetPacks

func GetPacks(server *minecraft.Conn) (packs map[string]*resource.Pack, err error)

func GetRealmsApi

func GetRealmsApi() *realms.Client

func GetTokenSource

func GetTokenSource() oauth2.TokenSource

func IPPrivate

func IPPrivate(ip net.IP) bool

check if ip is private

func Img2rgba

func Img2rgba(img *image.RGBA) []color.RGBA

func InitDNS

func InitDNS()

func LERP

func LERP(p1, p2, alpha float64) float64

LERP is a linear interpolation function

func MarginLines

func MarginLines(lines []string) string

make text centered

func PacketLogger

func PacketLogger(header packet.Header, payload []byte, src, dst net.Addr)

func RegisterCommand

func RegisterCommand(sub subcommands.Command)

func ServerInput

func ServerInput(server string) (address, name string, err error)

func SetUnexportedField

func SetUnexportedField(field reflect.Value, value interface{})

func SplitExt

func SplitExt(filename string) (name, ext string)

SplitExt splits path to filename and extension

func UnpackZip

func UnpackZip(r io.ReaderAt, size int64, unpack_folder string)

func ZipFolder

func ZipFolder(filename, folder string) error

Types

type ConnectCallback

type ConnectCallback func(proxy *ProxyContext)

type DNSServer

type DNSServer struct{}

type IngameCommand

type IngameCommand struct {
	Exec func(cmdline []string) bool
	Cmd  protocol.Command
}

type PacketCallback

type PacketCallback func(pk packet.Packet, proxy *ProxyContext, toServer bool) (packet.Packet, error)

type PacketFunc

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

type ProxyContext

type ProxyContext struct {
	Server   *minecraft.Conn
	Client   *minecraft.Conn
	Listener *minecraft.Listener

	// called for every packet
	PacketFunc PacketFunc
	// called after game started
	ConnectCB ConnectCallback
	// called on every packet after login
	PacketCB PacketCallback
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(log *logrus.Logger) *ProxyContext

func (*ProxyContext) AddCommand

func (p *ProxyContext) AddCommand(cmd IngameCommand)

func (*ProxyContext) CommandHandlerPacketCB

func (p *ProxyContext) CommandHandlerPacketCB(pk packet.Packet, proxy *ProxyContext, toServer bool) (packet.Packet, error)

func (*ProxyContext) Run

func (p *ProxyContext) Run(ctx context.Context, server_address string) (err error)

func (*ProxyContext) SendMessage

func (p *ProxyContext) SendMessage(text string)

func (*ProxyContext) SendPopup

func (p *ProxyContext) SendPopup(text string)

type RealmListCMD

type RealmListCMD struct{}

func (*RealmListCMD) Execute

func (c *RealmListCMD) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus

func (*RealmListCMD) Name

func (*RealmListCMD) Name() string

func (*RealmListCMD) SetFlags

func (c *RealmListCMD) SetFlags(f *flag.FlagSet)

func (*RealmListCMD) Synopsis

func (*RealmListCMD) Synopsis() string

func (*RealmListCMD) Usage

func (c *RealmListCMD) Usage() string

Jump to

Keyboard shortcuts

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