config

package
v1.0.0-beta.7 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MIT Imports: 16 Imported by: 13

Documentation

Index

Constants

View Source
const DefaultLocation = "/etc/pterodactyl/config.yml"

Variables

Functions

func GetJwtAlgorithm

func GetJwtAlgorithm() *jwt.HMACSHA

Returns the in-memory JWT algorithm.

func Set

func Set(c *Configuration)

Set the global configuration instance. This is a blocking operation such that anything trying to set a different configuration value, or read the configuration will be paused until it is complete.

func SetDebugViaFlag

func SetDebugViaFlag(d bool)

Types

type ApiConfiguration

type ApiConfiguration struct {
	// The interface that the internal webserver should bind to.
	Host string `default:"0.0.0.0" yaml:"host"`

	// The port that the internal webserver should bind to.
	Port int `default:"8080" yaml:"port"`

	// SSL configuration for the daemon.
	Ssl struct {
		Enabled         bool   `default:"false"`
		CertificateFile string `json:"cert" yaml:"cert"`
		KeyFile         string `json:"key" yaml:"key"`
	}

	// The maximum size for files uploaded through the Panel in bytes.
	UploadLimit int `default:"100" json:"upload_limit" yaml:"upload_limit"`
}

Defines the configuration for the internal API that is exposed by the daemon webserver.

type Configuration

type Configuration struct {
	sync.RWMutex `json:"-" yaml:"-"`

	// Determines if wings should be running in debug mode. This value is ignored
	// if the debug flag is passed through the command line arguments.
	Debug bool

	// A unique identifier for this node in the Panel.
	Uuid string

	// An identifier for the token which must be included in any requests to the panel
	// so that the token can be looked up correctly.
	AuthenticationTokenId string `json:"token_id" yaml:"token_id"`

	// The token used when performing operations. Requests to this instance must
	// validate against it.
	AuthenticationToken string `json:"token" yaml:"token"`

	Api    ApiConfiguration    `json:"api" yaml:"api"`
	System SystemConfiguration `json:"system" yaml:"system"`
	Docker DockerConfiguration `json:"docker" yaml:"docker"`

	// The amount of time in seconds that should elapse between disk usage checks
	// run by the daemon. Setting a higher number can result in better IO performance
	// at an increased risk of a malicious user creating a process that goes over
	// the assigned disk limits.
	DiskCheckTimeout int `yaml:"disk_check_timeout"`

	// Defines internal throttling configurations for server processes to prevent
	// someone from running an endless loop that spams data to logs.
	Throttles struct {
		// The number of data overage warnings (inclusive) that can accumulate
		// before a process is terminated.
		KillAtCount int `default:"5" yaml:"kill_at_count"`

		// The number of seconds that must elapse before the internal counter
		// begins decrementing warnings assigned to a process that is outputting
		// too much data.
		DecaySeconds int `default:"10" json:"decay" yaml:"decay"`

		// The total number of bytes allowed to be output by a server process
		// per interval.
		BytesPerInterval int `default:"4096" json:"bytes" yaml:"bytes"`

		// The amount of time that should lapse between data output throttle
		// checks. This should be defined in milliseconds.
		CheckInterval int `default:"100" yaml:"check_interval"`
	}

	// The location where the panel is running that this daemon should connect to
	// to collect data and send events.
	PanelLocation string `json:"remote" yaml:"remote"`
	// contains filtered or unexported fields
}

func Get

func Get() *Configuration

Get the global configuration instance. This is a read-safe operation that will block if the configuration is presently being modified.

func NewFromPath

func NewFromPath(path string) (*Configuration, error)

Create a new struct and set the path where it should be stored.

func ReadConfiguration

func ReadConfiguration(path string) (*Configuration, error)

Reads the configuration from the provided file and returns the configuration object that can then be used.

func (*Configuration) EnsureFilePermissions

func (c *Configuration) EnsureFilePermissions() error

Ensures that the configured data directory has the correct permissions assigned to all of the files and folders within.

func (*Configuration) EnsurePterodactylUser

func (c *Configuration) EnsurePterodactylUser() (*user.User, error)

Ensures that the Pterodactyl core user exists on the system. This user will be the owner of all data in the root data directory and is used as the user within containers.

If files are not owned by this user there will be issues with permissions on Docker mount points.

func (*Configuration) GetPath

func (c *Configuration) GetPath() string

Returns the path for this configuration file.

func (*Configuration) WriteToDisk

func (c *Configuration) WriteToDisk() error

Writes the configuration to the disk as a blocking operation by obtaining an exclusive lock on the file. This prevents something else from writing at the exact same time and leading to bad data conditions.

type DockerConfiguration

type DockerConfiguration struct {
	// Network configuration that should be used when creating a new network
	// for containers run through the daemon.
	Network DockerNetworkConfiguration `json:"network" yaml:"network"`

	// If true, container images will be updated when a server starts if there
	// is an update available. If false the daemon will not attempt updates and will
	// defer to the host system to manage image updates.
	UpdateImages bool `default:"true" json:"update_images" yaml:"update_images"`

	// The location of the Docker socket.
	Socket string `default:"/var/run/docker.sock" json:"socket" yaml:"socket"`

	// Defines the location of the timezone file on the host system that should
	// be mounted into the created containers so that they all use the same time.
	TimezonePath string `default:"/etc/timezone" json:"timezone_path" yaml:"timezone_path"`
}

Defines the docker configuration used by the daemon when interacting with containers and networks on the system.

type DockerNetworkConfiguration

type DockerNetworkConfiguration struct {
	// The interface that should be used to create the network. Must not conflict
	// with any other interfaces in use by Docker or on the system.
	Interface string `default:"172.18.0.1" json:"interface" yaml:"interface"`

	// The DNS settings for containers.
	Dns []string `default:"[\"1.1.1.1\", \"1.0.0.1\"]"`

	// The name of the network to use. If this network already exists it will not
	// be created. If it is not found, a new network will be created using the interface
	// defined.
	Name       string                  `default:"pterodactyl_nw"`
	ISPN       bool                    `default:"false" yaml:"ispn"`
	Driver     string                  `default:"bridge"`
	Mode       string                  `default:"pterodactyl_nw" yaml:"network_mode"`
	IsInternal bool                    `default:"false" yaml:"is_internal"`
	EnableICC  bool                    `default:"true" yaml:"enable_icc"`
	Interfaces dockerNetworkInterfaces `yaml:"interfaces"`
}

type SftpConfiguration

type SftpConfiguration struct {
	// If set to true disk checking will not be performed. This will prevent the SFTP
	// server from checking the total size of a directory when uploading files.
	DisableDiskChecking bool `default:"false" yaml:"disable_disk_checking"`
	// The bind address of the SFTP server.
	Address string `default:"0.0.0.0" json:"bind_address" yaml:"bind_address"`
	// The bind port of the SFTP server.
	Port int `default:"2022" json:"bind_port" yaml:"bind_port"`
	// If set to true, no write actions will be allowed on the SFTP server.
	ReadOnly bool `default:"false" yaml:"read_only"`
}

Defines the configuration of the internal SFTP server.

type SystemConfiguration

type SystemConfiguration struct {
	// The root directory where all of the pterodactyl data is stored at.
	RootDirectory string `default:"/var/lib/pterodactyl" yaml:"root_directory"`

	// Directory where logs for server installations and other wings events are logged.
	LogDirectory string `default:"/var/log/pterodactyl" yaml:"log_directory"`

	// Directory where the server data is stored at.
	Data string `default:"/var/lib/pterodactyl/volumes" yaml:"data"`

	// Directory where server archives for transferring will be stored.
	ArchiveDirectory string `default:"/var/lib/pterodactyl/archives" yaml:"archive_directory"`

	// Directory where local backups will be stored on the machine.
	BackupDirectory string `default:"/var/lib/pterodactyl/backups" yaml:"backup_directory"`

	// The user that should own all of the server files, and be used for containers.
	Username string `default:"pterodactyl" yaml:"username"`

	// Definitions for the user that gets created to ensure that we can quickly access
	// this information without constantly having to do a system lookup.
	User struct {
		Uid int
		Gid int
	}

	// Determines if permissions for a server should be set automatically on
	// daemon boot. This can take a long time on systems with many servers, or on
	// systems with servers containing thousands of files.
	//
	// Setting this to true by default helps us avoid a lot of support requests
	// from people that keep trying to move files around as a root user leading
	// to server permission issues.
	//
	// In production and heavy use environments where boot speed is essential,
	// this should be set to false as servers will self-correct permissions on
	// boot anyways.
	SetPermissionsOnBoot bool `default:"true" yaml:"set_permissions_on_boot"`

	// Determines if Wings should detect a server that stops with a normal exit code of
	// "0" as being crashed if the process stopped without any Wings interaction. E.g.
	// the user did not press the stop button, but the process stopped cleanly.
	DetectCleanExitAsCrash bool `default:"true" yaml:"detect_clean_exit_as_crash"`

	Sftp SftpConfiguration `yaml:"sftp"`
}

Defines basic system configuration settings.

func (*SystemConfiguration) ConfigureDirectories

func (sc *SystemConfiguration) ConfigureDirectories() error

Ensures that all of the system directories exist on the system. These directories are created so that only the owner can read the data, and no other users.

func (*SystemConfiguration) GetInstallLogPath

func (sc *SystemConfiguration) GetInstallLogPath() string

Returns the location of the JSON file that tracks server states.

func (*SystemConfiguration) GetStatesPath

func (sc *SystemConfiguration) GetStatesPath() string

Returns the location of the JSON file that tracks server states.

Jump to

Keyboard shortcuts

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