config

package
v0.42.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Bind:                          "0.0.0.0:25565",
	OnlineMode:                    true,
	Auth:                          Auth{},
	OnlineModeKickExistingPlayers: false,
	Forwarding: Forwarding{
		Mode:           LegacyForwardingMode,
		VelocitySecret: "",
	},
	Status: Status{
		ShowMaxPlayers: 1000,
		Motd:           defaultMotd(),

		Favicon:         "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5AgJCgs6JBZy0AAAB+lJREFUeNrtmGuMXVUZht/LOvcz7diWklbJaKGCWKXFUiiBQjAEhRSLSCEqIKAiogRTmiriBeSiUUhjMCZe2qQxNE0EUZSCidAgYMBSLBJCDC1taAg4xaq1cz/788feZzqgocCoP2Q/f87JOXvvfOtd73dZGygpKSkpKSkpKSkpKSkpKSkpKSkpKXnzwNd7w+ULD0NEBtmQBFqQBNuICFRYwzc3bf7/E+Cyo+cgAIiEbESWJdl1WSQ5VGvWRwnk/0XgpnvfmAhrv3h+HhgFFeJCBCLw8Wt//B8XIB3ogs8umJMHAOCQvtnYtfP5eRGxVNaxMmdKgqzdWSfbIuuuocHBLa2ednx16WJcd9fvXn9EAQSQyGgBwUCMMbAvAvHfcIAOaBHnl0REY9fO56+itFHSjbI/JHuxrMWyl8r6mq27m+3WKpJ1kvjG2UtevyUtyDqK0t2UNklaLalu63+fAp9bNBdZFogsq0j6OsVVkix7L8WNkh6VLVuLlXyapKbsMUkrR4aGV9caNbRnTkWKPC0kgdpv7e7n2GgH7ant8WgiYomoX8uqUXoIwKm1Rn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C0wOC0wOVQxMDoxMTo0MyswMDowMN6nNEYAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjAtMDgtMDlUMTA6MTE6NDMrMDA6MDCv+oz6AAAAAElFTkSuQmCC",
		LogPingRequests: false,
	},
	Query: Query{
		Enabled:     false,
		Port:        25577,
		ShowPlugins: false,
	},
	AnnounceForge:                        false,
	Servers:                              map[string]string{},
	Try:                                  []string{},
	ForcedHosts:                          map[string][]string{},
	FailoverOnUnexpectedServerDisconnect: true,
	ConnectionTimeout:                    configutil.Duration(5000 * time.Millisecond),
	ReadTimeout:                          configutil.Duration(30000 * time.Millisecond),
	Quota: Quota{
		Connections: QuotaSettings{
			Enabled:    true,
			OPS:        5,
			Burst:      10,
			MaxEntries: 1000,
		},
		Logins: QuotaSettings{
			Enabled:    true,
			OPS:        0.4,
			Burst:      3,
			MaxEntries: 1000,
		},
	},
	Compression: Compression{
		Threshold: 256,
		Level:     -1,
	},
	ProxyProtocol:                       false,
	ProxyProtocolBackend:                false,
	ShouldPreventClientProxyConnections: false,
	BungeePluginChannelEnabled:          true,
	BuiltinCommands:                     true,
	RequireBuiltinCommandPermissions:    false,
	AnnounceProxyCommands:               true,
	Debug:                               false,
	ShutdownReason:                      defaultShutdownReason(),
	ForceKeyAuthentication:              true,
	Lite:                                liteconfig.DefaultConfig,
}

DefaultConfig is a default Config.

Functions

This section is empty.

Types

type Auth added in v0.34.0

type Auth struct {
	// SessionServerURL is the base URL for the Mojang session server to authenticate online mode players.
	// Defaults to https://sessionserver.mojang.com/session/minecraft/hasJoined
	SessionServerURL *configutil.URL `yaml:"sessionServerUrl"` // TODO support multiple urls configutil.SingleOrMulti[URL]
}

Auth is the config for authentication.

type Compression

type Compression struct {
	Threshold int `yaml:"threshold"`
	Level     int `yaml:"level"`
}

type Config

type Config struct {
	Bind string `yaml:"bind"` // The address to listen for connections.

	OnlineMode                    bool `yaml:"onlineMode,omitempty" json:"onlineMode,omitempty"`                                       // Whether to enable online mode.
	Auth                          Auth `yaml:"auth,omitempty" json:"auth,omitempty"`                                                   // Authentication settings.
	OnlineModeKickExistingPlayers bool `yaml:"onlineModeKickExistingPlayers,omitempty" json:"onlineModeKickExistingPlayers,omitempty"` // Kicks existing players when a premium player with the same name joins.

	Forwarding Forwarding `yaml:"forwarding,omitempty" json:"forwarding,omitempty"` // Player info forwarding settings.
	Status     Status     `yaml:"status,omitempty" json:"status,omitempty"`         // Status response settings.
	Query      Query      `yaml:"query,omitempty" json:"query,omitempty"`           // Query settings.
	// Whether the proxy should present itself as a
	// Forge/FML-compatible server. By default, this is disabled.
	AnnounceForge bool `yaml:"announceForge,omitempty" json:"announceForge,omitempty"`

	Servers                              map[string]string `yaml:"servers,omitempty" json:"servers,omitempty"` // name:address
	Try                                  []string          `yaml:"try,omitempty" json:"try,omitempty"`         // Try server names order
	ForcedHosts                          ForcedHosts       `yaml:"forcedHosts,omitempty" json:"forcedHosts,omitempty"`
	FailoverOnUnexpectedServerDisconnect bool              `yaml:"failoverOnUnexpectedServerDisconnect,omitempty" json:"failoverOnUnexpectedServerDisconnect,omitempty"`

	ConnectionTimeout configutil.Duration `yaml:"connectionTimeout,omitempty" json:"connectionTimeout,omitempty"` // Write timeout
	ReadTimeout       configutil.Duration `yaml:"readTimeout,omitempty" json:"readTimeout,omitempty"`             // Read timeout

	Quota                Quota       `yaml:"quota,omitempty" json:"quota,omitempty"` // Rate limiting settings
	Compression          Compression `yaml:"compression,omitempty" json:"compression,omitempty"`
	ProxyProtocol        bool        `yaml:"proxyProtocol,omitempty" json:"proxyProtocol,omitempty"`     // Enable HA-Proxy protocol mode
	ProxyProtocolBackend bool        `yaml:"proxyProtocolBackend" json:"proxyProtocolBackend,omitempty"` // Enable HA-Proxy protocol mode for backend servers

	ShouldPreventClientProxyConnections bool `yaml:"shouldPreventClientProxyConnections" json:"shouldPreventClientProxyConnections,omitempty"` // Sends player IP to Mojang on login

	AcceptTransfers                  bool `yaml:"acceptTransfers,omitempty" json:"acceptTransfers,omitempty"`                                   // Whether to accept transfers from other hosts via transfer packet
	BungeePluginChannelEnabled       bool `yaml:"bungeePluginChannelEnabled,omitempty" json:"bungeePluginChannelEnabled,omitempty"`             // Whether to enable BungeeCord plugin messaging
	BuiltinCommands                  bool `yaml:"builtinCommands,omitempty" json:"builtinCommands,omitempty"`                                   // Whether to enable builtin commands
	RequireBuiltinCommandPermissions bool `yaml:"requireBuiltinCommandPermissions,omitempty" json:"requireBuiltinCommandPermissions,omitempty"` // Whether builtin commands require player permissions
	AnnounceProxyCommands            bool `yaml:"announceProxyCommands,omitempty" json:"announceProxyCommands,omitempty"`                       // Whether to announce proxy commands to players
	ForceKeyAuthentication           bool `yaml:"forceKeyAuthentication,omitempty" json:"forceKeyAuthentication,omitempty"`                     // Added in 1.19

	Debug          bool                      `yaml:"debug,omitempty" json:"debug,omitempty"` // Enable debug mode
	ShutdownReason *configutil.TextComponent `yaml:"shutdownReason,omitempty" json:"shutdownReason,omitempty"`

	Lite liteconfig.Config `yaml:"lite,omitempty" json:"lite,omitempty"` // Lite mode settings
}

Config is the configuration of the proxy.

func (*Config) Validate

func (c *Config) Validate() (warns []error, errs []error)

Validate validates Config.

type ForcedHosts

type ForcedHosts map[string][]string // virtualhost:server names

type Forwarding

type Forwarding struct {
	Mode              ForwardingMode `yaml:"mode"`
	VelocitySecret    string         `yaml:"velocitySecret"`    // Used with "velocity" mode
	BungeeGuardSecret string         `yaml:"bungeeGuardSecret"` // Used with "bungeeguard" mode
}

type ForwardingMode

type ForwardingMode string

ForwardingMode is a player info forwarding mode.

const (
	NoneForwardingMode   ForwardingMode = "none"
	LegacyForwardingMode ForwardingMode = "legacy"
	// VelocityForwardingMode is a forwarding mode specified by the Velocity java proxy and
	// supported by PaperSpigot for versions starting at 1.13.
	VelocityForwardingMode ForwardingMode = "velocity"
	// BungeeGuardForwardingMode is a forwarding mode used by versions lower than 1.13
	BungeeGuardForwardingMode ForwardingMode = "bungeeguard"
)

type Query

type Query struct {
	Enabled     bool `yaml:"enabled"`
	Port        int  `yaml:"port"`
	ShowPlugins bool `yaml:"showPlugins"`
}

type Quota

type Quota struct {
	Connections QuotaSettings `yaml:"connections"` // Limits new connections per second, per IP block.
	Logins      QuotaSettings `yaml:"logins"`      // Limits logins per second, per IP block.

}

Quota is the config for rate limiting.

type QuotaSettings

type QuotaSettings struct {
	Enabled    bool    `yaml:"enabled"`    // If false, there is no such limiting.
	OPS        float32 `yaml:"ops"`        // Allowed operations/events per second, per IP block
	Burst      int     `yaml:"burst"`      // The maximum events per second, per block; the size of the token bucket
	MaxEntries int     `yaml:"maxEntries"` // Maximum number of IP blocks to keep track of in cache
}

type Status

type Status struct {
	ShowMaxPlayers  int                       `yaml:"showMaxPlayers"`
	Motd            *configutil.TextComponent `yaml:"motd"`
	Favicon         favicon.Favicon           `yaml:"favicon"`
	LogPingRequests bool                      `yaml:"logPingRequests"`
}

Jump to

Keyboard shortcuts

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