importer

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package importer moves data from other panels into Ammonode: Pterodactyl (users, nodes, allocations, eggs, servers — following Calagopus' importer), and Paymenter or WHMCS (customers, products, services, invoices, payments, credit — following Paymenter's WHMCS importer). Everything is read first, problems are collected in a report, and the writes happen in one database transaction that a dry run rolls back.

Index

Constants

This section is empty.

Variables

View Source
var ErrAborted = errors.New("some rows cannot be imported (see the report); fix them in the source, or run with --on-invalid=skip")

ErrAborted means rows would be skipped and --on-invalid=abort is in effect.

Functions

func DecryptLaravel

func DecryptLaravel(key []byte, payload string) (string, error)

DecryptLaravel decrypts a value from Laravel's encrypter (AES-256-CBC, HMAC-SHA256 MAC), unwrapping PHP serialization of strings.

func LaravelKey

func LaravelKey(appKey string) ([]byte, error)

LaravelKey decodes APP_KEY ("base64:..." or raw).

func ParseEnv

func ParseEnv(path string) (map[string]string, error)

ParseEnv reads a Laravel .env file (KEY=value, quotes, comments, "export").

func ParseMoney

func ParseMoney(s string, zeroDecimal bool) (int64, error)

ParseMoney turns a decimal string ("12.50") into the smallest unit (cents), or whole units for zero-decimal currencies; it rounds half up.

Types

type Issue

type Issue struct {
	Entity   string `json:"entity"`    // user, node, egg, server, product, service, invoice, ...
	SourceID string `json:"source_id"` // the row's ID in the source panel
	Problem  string `json:"problem"`
	// Action: "skipped" (the row is not imported; fails the import with --on-invalid=abort),
	// "fixed" (imported with a change), or "note" (imported; something does not carry over).
	Action string `json:"action"`
}

Issue is one problem found in the source data.

type MySQL

type MySQL struct {
	Host, Port, User, Password, Database string
}

MySQL describes a source database.

func FromEnv

func FromEnv(env map[string]string) (MySQL, error)

FromEnv takes the database settings of a Laravel app (Pterodactyl, Paymenter).

func WHMCSConfig

func WHMCSConfig(path string) (MySQL, error)

WHMCSConfig reads the database settings from WHMCS's configuration.php.

func (MySQL) Open

func (m MySQL) Open() (*sql.DB, error)

Open connects to the source database (read-only use; times as UTC).

type Options

type Options struct {
	DryRun bool
	// OnInvalid: "abort" (default) refuses to write when any row must be skipped;
	// "skip" imports everything else.
	OnInvalid string
	// Force imports into a panel that already has data of the same kind.
	Force bool
	// UnlimitedMemoryMB replaces "unlimited" memory (0) of source servers (Ammonode needs a limit).
	UnlimitedMemoryMB int
}

Options control an import.

type Report

type Report struct {
	Source   string         `json:"source"`
	DryRun   bool           `json:"dry_run"`
	Started  time.Time      `json:"started"`
	Finished time.Time      `json:"finished"`
	Imported map[string]int `json:"imported"` // rows written per entity
	Linked   map[string]int `json:"linked"`   // rows matched to existing data (e.g. users by email)
	Issues   []Issue        `json:"issues"`
}

Report is the outcome of an import (also written as JSON with --report).

func Paymenter

func Paymenter(ctx context.Context, pool *pgxpool.Pool, envPath string, opts Options) (*Report, error)

Paymenter imports a Paymenter (v1) installation through its .env: users (passwords and 2FA keep working), credit, categories/products/plans, services, invoices and payments. Run the Pterodactyl import first to link services to their game servers.

func Pterodactyl

func Pterodactyl(ctx context.Context, pool *pgxpool.Pool, envPath string, opts Options) (*Report, error)

Pterodactyl imports a Pterodactyl panel through its .env (database + APP_KEY): users (password hashes and 2FA secrets keep working), nodes, allocations, nests/eggs (as blueprints), servers with their variables and limits, and mail settings. Server UUIDs are kept, so `ammonode-agent migrate-wings` can hand the files over on each node.

func WHMCS

func WHMCS(ctx context.Context, pool *pgxpool.Pool, cfg MySQL, opts Options) (*Report, error)

WHMCS imports clients (their WHMCS passwords keep working when stored as bcrypt), admins, credit, products with Pterodactyl module settings, services, invoices and transactions. Run the Pterodactyl import first to link services to their game servers.

func (*Report) Skipped

func (r *Report) Skipped() int

Skipped counts rows left out.

func (*Report) Summary

func (r *Report) Summary() string

Summary is a short human-readable overview.

func (*Report) WriteFile

func (r *Report) WriteFile(path string) error

WriteFile saves the report as JSON.

Jump to

Keyboard shortcuts

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