mcpingserver

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

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

Go to latest
Published: Jul 20, 2022 License: GPL-3.0 Imports: 11 Imported by: 3

README

MCPingServer - Golang minecraft stand-in server

MCPingServer is a minimalistic Minecraft server which only responds to ping requests and kicks any clients which attempt to join the server. All facets of the server are configurable: favicon location, MOTD, player count, player cap, as well as kick message. All messages are colored and formatted with the correct formatting (>=1.7 json style, <= 1.6 section color character).

Installation

MCPingServer is a Golang based program, which means it can (and is!) distributed in a variety of compiled varieties. There should be a build available for your operating system/architecture. However, if there is not, you are still able to build MCPingServer from source (outlined below).

Building From Source

Building from source requires go to be installed on the machine designated for building MCPingServer. Once go is installed, building MCPingServer can be achieved by running the following set of commands:

git clone https://github.com/Ichbinjoe/MCPingServer.git
cd MCPingServer
go build cmd/main.go -o mcpingserver

This results in an executable to be created within the current directory.

Using MCPingServer

MCPingServer is a simple command line executable. The behavior of MCPingServer is mutated by a set of command line flags that all can be optionally supplied to MCPingServer.

Flags:

  • -bindAddr Ip:Port Ip:Port combination for MCPingServer to bind to (default "0.0.0.0:25565")
  • -cap players Reported max player count for the server (default 20)
  • -players players Reported current player count for the server (default 0)
  • -favicon faviconLocation Location to read the favicon from. Favicon should be a 64px by 64px png (default "favicon.png")
  • -kickMsg msg Message to send to players who attempt to join the server. Supports & color codes (default: "&4This is not a joinable server!")
  • -motd motd Message to set the MOTD to. Supports & colors as well as /n as the newline seperator (default "A Golang inplace server")
  • -serverVersionName name Sets the name of the version of Minecraft to respond as (default "1.12.2")
  • -serverVersionNumber number Sets the protocol version of Minecraft to respond as (default 340)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var COLOR_MAP = map[rune]string{
	'0': "black",
	'1': "dark_blue",
	'2': "dark_green",
	'3': "dark_aqua",
	'4': "dark_red",
	'5': "dark_purple",
	'6': "gold",
	'7': "gray",
	'8': "dark_gray",
	'9': "blue",
	'a': "green",
	'b': "aqua",
	'c': "red",
	'd': "light_purple",
	'e': "yellow",
	'f': "white",
}

Functions

func TranslateColorCodes

func TranslateColorCodes(input string) string

Types

type Handshake

type Handshake struct {
	ProtocolVersion uint64
	ServerAddress   string
	ServerPort      uint16
	SourceIP        net.Addr
}

type LegacyPingResponse

type LegacyPingResponse struct {
	PlayerCount, PlayerMax, ProtocolVersion int
	ServerVersion, Motd                     string
}

type PingResponse

type PingResponse struct {
	Version     VersionEntry `json:"version"`
	Players     PlayersEntry `json:"players"`
	Description interface{}  `json:"description"`
	Faviconb64  string       `json:"favicon,omitempty"`
}

type PingServer

type PingServer struct {
	Responder Responder // only responderhook can be hotswapped
	// contains filtered or unexported fields
}

func CreatePingServer

func CreatePingServer(bindAddr string, hook Responder) *PingServer

func (*PingServer) AcceptConnection

func (ps *PingServer) AcceptConnection(handler PingServerErrorHandler) error

func (*PingServer) AcceptConnections

func (ps *PingServer) AcceptConnections(handler PingServerErrorHandler) (err error)

func (*PingServer) Bind

func (ps *PingServer) Bind() (err error)

func (*PingServer) Close

func (ps *PingServer) Close() error

func (*PingServer) SetResponseTimeout

func (ps *PingServer) SetResponseTimeout(timeout int)

type PingServerErrorHandler

type PingServerErrorHandler func(error)

type PlayerConn

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

type PlayerEntry

type PlayerEntry struct {
	Name string `json:"name"`
	Uuid string `json:"id"`
}

type PlayersEntry

type PlayersEntry struct {
	MaxPlayers    int           `json:"max"`
	OnlinePlayers int           `json:"online"`
	Sample        []PlayerEntry `json:"sample,omitempty"`
}

type Responder

type Responder interface {
	OnConnect(net.Addr) error
	RespondPing(*Handshake) (*PingResponse, error)
	RespondJoin(*Handshake, string) (interface{}, error)
	RespondLegacyPing(*Handshake) (*LegacyPingResponse, error)
}

func CreateSimpleResponder

func CreateSimpleResponder(response *PingResponse, kickResponse interface{}, legacyResponse *LegacyPingResponse) Responder

type SimpleResponder

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

func (SimpleResponder) OnConnect

func (s SimpleResponder) OnConnect(a net.Addr) error

func (SimpleResponder) RespondJoin

func (s SimpleResponder) RespondJoin(h *Handshake, u string) (interface{}, error)

func (SimpleResponder) RespondLegacyPing

func (s SimpleResponder) RespondLegacyPing(h *Handshake) (*LegacyPingResponse, error)

func (SimpleResponder) RespondPing

func (s SimpleResponder) RespondPing(h *Handshake) (*PingResponse, error)

type TextSelection

type TextSelection struct {
	Text          string        `json:"text"`
	Bold          bool          `json:"bold,omitempty"`
	Italic        bool          `json:"italic,omitempty"`
	Underlined    bool          `json:"underlined,omitempty"`
	Strikethrough bool          `json:"strikethrough,omitempty"`
	Obfuscated    bool          `json:"obfuscated,omitempty"`
	Color         string        `json:"color,omitempty"`
	Extra         []interface{} `json:"extra,omitempty"`
}

func ConvertMCChat

func ConvertMCChat(input string) *TextSelection

type VersionEntry

type VersionEntry struct {
	Name     string `json:"name"`
	Protocol uint   `json:"protocol"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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