gophertunnel

command module
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 6 Imported by: 0

README

gophertunnel

A Minecraft library containing packages to create clients, servers, proxies and other tools, and a proxy implementation using them.

Module Documentation

telescope gopher

Overview

gophertunnel is composed of several packages that may be of use for creating Minecraft related tools.

package query: A package implementing the sending of queries to servers that implement the UT3/GameSpy Query Protocol.

package minecraft: A package implementing connecting to Minecraft Bedrock Edition servers and listening for Minecraft Bedrock Edition clients using a TCP style interface.

  • package minecraft/auth: A package implementing Microsoft, XBOX Live and Minecraft account authentication.

  • package minecraft/nbt: A package implementing the Minecraft NBT format. Three variants of the format are implemented: The Java Edition variant (Big Endian) and the Bedrock Edition variants (Little Endian, both with and without varints)

  • package minecraft/protocol: A package implementing the reading, writing and handling of packets found in the Minecraft Bedrock Edition protocol.

  • package minecraft/resource: A package handling the reading and compiling of Minecraft resource packs.

  • package minecraft/text: A package containing utility functions related to Minecraft text formatting.

Examples

Creating a Minecraft client that authenticates using an XBOX Live account and connects to a server:

package main

import (
	"github.com/sandertv/gophertunnel/minecraft"
	"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
)

func main() {
    conn, err := minecraft.Dialer{
        Email: "some@email.address",
        Password: "password",
    }.Dial("raknet", "mco.mineplex.com:19132")
    if err != nil {
        panic(err)
    }
    defer conn.Close()
    for {
    	pk, err := conn.ReadPacket()
    	if err != nil {
    		break
    	}
    	// Handle the incoming packet.
    	_ = pk
    	
    	// Send a packet to the server.
    	if err := conn.WritePacket(&packet.RequestChunkRadius{ChunkRadius: 32}); err != nil {
    		break
    	}
    }
}

Creating a Minecraft listener that can accept incoming clients and adapts the MOTD from another server:

package main

import (
	"fmt"
	"github.com/sandertv/gophertunnel/minecraft"
)

func main() {
	listener, err := minecraft.Listen("raknet", "0.0.0.0:19132")
	if err != nil {
		panic(err)
	}
	_ = listener.HijackPong("mco.mineplex.com:19132")

	for {
		conn, err := listener.Accept()
		if err != nil {
			return
		}
		go func() {
			// Process the connection on another goroutine as you would with TCP connections.
			defer conn.Close()
			for {
				// Read a packet from the client.
				if _, err := conn.(*minecraft.Conn).ReadPacket(); err != nil {
					return
				}
			}
		}()
	}
}

Proxy

A MITM proxy program is implemented in the main.go file. It uses the gophertunnel libraries to create a proxy that provides user authentication and proxying a connection to another server.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package minecraft implements Minecraft Bedrock Edition connections.
Package minecraft implements Minecraft Bedrock Edition connections.
auth
Package auth implements authentication to Microsoft accounts and XBOX Live accounts.
Package auth implements authentication to Microsoft accounts and XBOX Live accounts.
nbt
Package nbt implements the NBT formats used by Minecraft Bedrock Edition and Minecraft Java Edition.
Package nbt implements the NBT formats used by Minecraft Bedrock Edition and Minecraft Java Edition.
protocol
Package protocol implements structures and functions used to write or read data related to the Minecraft Bedrock Edition protocol.
Package protocol implements structures and functions used to write or read data related to the Minecraft Bedrock Edition protocol.
protocol/packet
Package packet implements every packet in the Minecraft Bedrock Edition protocol using the functions found in the minecraft/protocol package.
Package packet implements every packet in the Minecraft Bedrock Edition protocol using the functions found in the minecraft/protocol package.
resource
Package resource implements the compiling of resource packs found in files, directories or raw byte data.
Package resource implements the compiling of resource packs found in files, directories or raw byte data.
Package query implements the UT3 query protocol as described on http://wiki.unrealadmin.org/UT3_query_protocol.
Package query implements the UT3 query protocol as described on http://wiki.unrealadmin.org/UT3_query_protocol.

Jump to

Keyboard shortcuts

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