mcping

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: MIT Imports: 13 Imported by: 1

README

mcping

Ping your mincraft server with a simple command! This program can also download favicon.

$ mcping play.miaoscraft.cn
MCPING (play.miaoscraft.cn:25565):
server: Spigot 1.15.2
protocol: 578
description: 
Miaoscraft!
delay: 42.200607ms
list: 2/18
- [defevt] 30e0098b-20a7-4067-b552-73517ad146dc
- [Wizard_BOSS] 664b582d-8838-4761-b011-c3852004f47d

install

$ go version # installed golang
go version go1.13.4 darwin/amd64
$ go get github.com/go-mc/mcping/mcping # install

Please ensure $GOPATH/bin or $GOBIN is in your $PATH.Because mcping will be installed in $(go env GOPATH)/bin.

Or you can go build and move the executable to your $PATH. Or run it directly.

usage

mcping host:port			# ping specific server
mcping host					# ping default port (25565)
mcping -p 404 host	        # specific protocol version
mcping -f icon.png host		# save server's favicon
mcping -f="/path with spaces/icon.png" host

mcping will lookup SRV record if port is 25565 (include default set) as same as Minecraft itself.

programming

import "github.com/go-mc/mcping"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IconAbsentErr = errors.New("icon not present")
View Source
var IconFormatErr = errors.New("data format error")

Functions

This section is empty.

Types

type Icon

type Icon string

Icon should be a PNG image that is Base64 encoded (without newlines: \n, new lines no longer work since 1.13) and prepended with data:image/png;base64,.

func (Icon) ToPNG added in v1.1.0

func (i Icon) ToPNG() ([]byte, error)

ToPNG decode base64-icon, return a PNG image Take care of there is not safety check, image may contain malicious code .

type Status

type Status struct {
	Description chat.Message
	Players     struct {
		Max    int
		Online int
		Sample []struct {
			ID   uuid.UUID
			Name string
		}
	}
	Version struct {
		Name     string
		Protocol int
	}
	Favicon Icon
}

func PingAndList

func PingAndList(addr string, protocol int) (*Status, time.Duration, error)

PingAndList check server status and list online player. Returns server status and delay. The addr has the form "host:port". The port are required.

func PingAndListConn

func PingAndListConn(conn net.Conn, protocol int) (*Status, time.Duration, error)

PingAndListConn is the version of PingAndList using a exist connection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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