A Go port of The Forgotten Server — a free, open-source MMORPG server emulator for the Tibia protocol. The original project is a ~50 000-line C++23 codebase; this rewrite targets Go to leverage native goroutine concurrency, simpler cross-platform deployment, and modern tooling, while maintaining 100% binary wire-protocol compatibility with existing Tibia and OTClient game clients (same XTEA encryption, RSA key exchange, Adler32/sequence checksums, and binary packet opcodes — no client changes required).
| Tool | Version | Purpose |
|---|---|---|
| Go | 1.26+ | Compiler and toolchain |
| golangci-lint | 2.x | Static analysis |
| gofumpt | latest | Strict formatter |
| govulncheck | latest | Vulnerability scanner |
| gotestsum | latest | Readable test output |
Download and install Go 1.26+ from the official site:
# macOS (Homebrew)
brew install go
# Linux — download the tarball from https://go.dev/dl/ then:
tar -C /usr/local -xzf go1.26.0.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
source ~/.profileVerify:
go version
# go version go1.26.0 darwin/arm64# golangci-lint (macOS)
brew install golangci-lint
# golangci-lint (Linux/Windows — see https://golangci-lint.run/welcome/install/)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
# Other tools via go install
go install mvdan.cc/gofumpt@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
go install gotest.tools/gotestsum@latestMake sure $(go env GOPATH)/bin is on your $PATH:
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.profile
source ~/.profilegit clone https://github.com/MutterPedro/otserver.git
cd otserver
go mod downloadCopy the example below to config.toml in the project root and adjust as needed:
[server]
address = "0.0.0.0:7172"
max_connections = 1000
[database]
dsn = "root:password@tcp(localhost:3306)/otserver"
[log]
level = "info" # debug | info | warn | errormake build
./server --config config.tomlmake build # compile binary → ./server
make test # run all tests with verbose output
make test-race # run all tests with the race detector (required before merging)
make test-acc # run acceptance tests only (prefix: TestAcceptance_)
make bench # run benchmarks with memory allocation stats
make lint # golangci-lint with strict config
make fmt # format all Go files with gofumpt
make vuln # scan dependencies for known CVEs via govulncheck# Full suite + race detector
go test -race ./...
# A specific package
go test -v ./internal/network/...
# Acceptance tests only
go test -run ^TestAcceptance ./...
# Benchmarks
go test -bench . -benchmem ./internal/crypto/...
# Fuzz testing (runs until cancelled or a panic is found)
go test -fuzz FuzzPacketDecoder ./internal/network/...otserver/
├── cmd/
│ └── server/
│ └── main.go # Entry point: flags, DI wiring, OS signal handling
├── internal/
│ ├── config/ # TOML config loading and validation
│ ├── crypto/ # XTEA, RSA, Adler32 — pure, stateless functions
│ ├── network/ # TCP Server, Connection, packet framing
│ ├── protocol/ # Tibia packet encode/decode (opcodes, checksums)
│ ├── core/
│ │ ├── entity/ # Thing, Item, Creature, Player, Monster, NPC
│ │ ├── combat/ # Damage formulas, conditions, resolution
│ │ └── world/ # Map, Tile, Quadtree, pathfinding
│ ├── engine/ # Game loop, goroutine orchestration, dispatchers
│ ├── scripting/ # Lua 5.1 embedding via gopher-lua
│ ├── storage/ # database/sql wrappers, async persistence queue
│ └── iomap/ # OTBM map loader
├── pkg/
│ └── otb/ # OTB item-format parser (importable as a library)
├── data/ # Lua scripts, XML configs, map files (reused from TFS)
├── go.mod
├── go.sum
├── Makefile
├── .golangci.yml # Strict linter config
└── .github/workflows/ci.yml # GitHub Actions: test-race + lint on every push/PR
- Package names: lowercase, single-word (e.g.
protocol, notProtocolGame) - No stuttering:
game.Server, notgame.GameServer - Interfaces defined at the point of use (consumer-owned), not at the implementation
- All exported symbols must have doc comments (
reviveenforces this) - Every error return must be handled or explicitly discarded with
_(errcheckenforces this)
GitHub Actions runs on every push and pull request to main:
go vet ./...go test -race -coverprofile=coverage.out ./...golangci-lint run ./...govulncheck ./...
The image is built in two stages: a golang:1.26-bookworm builder compiles a fully-static binary (CGO_ENABLED=0), which is then copied into a Google distroless runtime image (distroless/static-debian12). The final image contains only the binary, CA certificates, and timezone data — no shell, no package manager.
docker build -t otserver:latest .Mount your config.toml into the container and expose the game port:
docker run --rm \
-p 7172:7172 \
-v $(pwd)/config.toml:/etc/otserver/config.toml:ro \
otserver:latestPass a different config path with --config:
docker run --rm \
-p 7172:7172 \
-v /srv/otserver/config.toml:/srv/config.toml:ro \
otserver:latest --config /srv/config.tomlUse Docker Buildx to produce images for linux/amd64 and linux/arm64 in one step:
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t otserver:latest \
--push .The server speaks the same binary protocol as the original C++ TFS, meaning any standard Tibia client or OTClient build connects without modification. Key compatibility components:
| Component | Description |
|---|---|
| XTEA | Symmetric stream cipher for in-game packet encryption |
| RSA | Asymmetric key exchange during login handshake |
| Adler32 | Checksum on each outbound packet |
| Sequence numbers | Per-connection counter to detect packet loss/reorder |
| Opcode table | Binary opcode map identical to the original TFS |
We welcome community contributions! Please review our Contributing Guidelines for details on our code conventions, development workflow, and PR process.
Before opening a pull request, please make sure your changes pass the race detector and linters:
make test-race
make lintLicensed under the GNU General Public License v2.0 — see LICENSE.md for details.