Skip to content

Installation

MEMOxiiii edited this page Sep 17, 2026 · 1 revision

Installation

Requirements

  • A working Dragonfly server (main.go using github.com/df-mc/dragonfly/server).
  • A running Portal proxy, with network.communication.secret set — see Portal's Configuration wiki page.

Get the library

go get github.com/MEMOxiiii/PortalDF

Quick Start — Enable

Enable connects to the proxy, registers /transfer, /server and /servers, and wires up stale-session cleanup, all in a single call:

package main

import (
	"github.com/MEMOxiiii/PortalDF"
	"github.com/df-mc/dragonfly/server"
)

func main() {
	// ... set up dragonfly server config ...
	srv := conf.New()
	srv.CloseOnProgramEnd()
	srv.Listen()

	portaldf.Enable(srv, portaldf.Config{
		ProxyAddress:  "127.0.0.1",
		SocketPort:    19131,
		Secret:        "your-secret",
		ServerName:    "Hub1",
		ServerAddress: "127.0.0.1:19132",
	})

	for p := range srv.Accept() {
		// handle players...
	}
}

Enable returns the *Portal client, so you can still call any of its methods (TransferPlayer, SetLatencyHandler, SetDraining, etc. — see API Usage) on the result if you need more than the built-in commands. Use EnableWithLogger instead of Enable to log through your own *slog.Logger.

Every Config field is documented in Configuration — the four above are the minimum you need; if this server should run over NetherNet instead of RakNet, read Transport Setup before changing ServerAddress's format.

Manual setup

If you'd rather manage the connection and command registration yourself (for example, to skip the built-in commands), wire them up individually instead of calling Enable:

package main

import (
	"log/slog"

	"github.com/MEMOxiiii/PortalDF"
	portalcmd "github.com/MEMOxiiii/PortalDF/command"
	"github.com/df-mc/dragonfly/server"
)

func main() {
	// ... set up dragonfly server config ...
	srv := conf.New()
	srv.CloseOnProgramEnd()

	portal := portaldf.New(portaldf.Config{
		ProxyAddress:  "127.0.0.1",
		SocketPort:    19131,
		Secret:        "your-secret",
		ServerName:    "Hub1",
		ServerAddress: "127.0.0.1:19132",
	}, slog.Default())

	go portal.Connect()

	// Register /transfer, /server, /servers commands.
	portalcmd.Register(portal, srv)

	srv.Listen()
	for p := range srv.Accept() {
		// handle players...
	}
}

See Commands for what portalcmd.Register gives you, and API Usage for everything callable on the *Portal client either path returns.

Clone this wiki locally