Documentation
¶
Overview ¶
Package proxy is a minetest reverse proxy for multiple servers. It also provides an API for plugins.
Index ¶
- Variables
- func AddServer(name string, s Server) bool
- func BuildPlugin() error
- func ChatCmdExists(name string) bool
- func ChatCmds() map[string]ChatCmd
- func Clts() map[*ClientConn]struct{}
- func Colorize(text, color string) string
- func DecodeVerifierAndSalt(encodedPasswd string) ([]byte, []byte, error)
- func EncodeVerifierAndSalt(salt, verifier []byte) string
- func FormspecEscape(formspec string) string
- func LoadConfig() error
- func LoadPlugins()
- func Path(path ...string) string
- func Players() map[string]struct{}
- func RegisterAuthBackend(name string, ab AuthBackend) error
- func RegisterChatCmd(cmd ChatCmd) bool
- func RegisterInteractionHandler(handler InteractionHandler)
- func RegisterOnChatMsg(handler func(*ClientConn, string) string)
- func RegisterOnCltModChanMsg(handler func(string, *ClientConn, string) bool)
- func RegisterOnInvAction(handler func(*ClientConn, string) string)
- func RegisterOnJoin(handler func(*ClientConn) string)
- func RegisterOnLeave(handler func(*ClientConn))
- func RegisterOnPlayerReceiveFields(formname string, handler func(*ClientConn, []mt.Field))
- func RegisterOnSrvModChanMsg(handler func(*ClientConn, string, string, string) bool)
- func RegisterSrvSelector(name string, sel func(*ClientConn) (string, Server)) error
- func ReplaceAllStringSubmatchFunc(re *regexp.Regexp, str string, repl func([]string) string) string
- func RmServer(name string) bool
- func Run()
- func SendModChanMsg(channel, msg string)
- func TDodEisK() error
- func Uptime() time.Duration
- func Version() (string, error)
- type AuthBackend
- type AuthFiles
- func (a AuthFiles) Ban(addr, name string) error
- func (a AuthFiles) Banned(addr, name string) bool
- func (a AuthFiles) Exists(name string) bool
- func (a AuthFiles) Export() ([]User, error)
- func (a AuthFiles) ExportBans() ([]Ban, error)
- func (a AuthFiles) Import(in []User) error
- func (a AuthFiles) ImportBans(in []Ban) error
- func (a AuthFiles) LastSrv(name string) (string, error)
- func (a AuthFiles) Passwd(name string) (salt, verifier []byte, err error)
- func (a AuthFiles) RecordFail(addr, name string, sudo bool) error
- func (a AuthFiles) SetLastSrv(name, srv string) error
- func (a AuthFiles) SetPasswd(name string, salt, verifier []byte) error
- func (a AuthFiles) Timestamp(name string) (time.Time, error)
- func (a AuthFiles) Unban(id string) error
- type AuthMTPostgreSQL
- func (a *AuthMTPostgreSQL) Ban(addr, name string) error
- func (a *AuthMTPostgreSQL) Banned(addr, name string) bool
- func (a *AuthMTPostgreSQL) Close() error
- func (a *AuthMTPostgreSQL) Exists(name string) bool
- func (a *AuthMTPostgreSQL) Export() ([]User, error)
- func (a *AuthMTPostgreSQL) ExportBans() ([]Ban, error)
- func (a *AuthMTPostgreSQL) Import(in []User) error
- func (a *AuthMTPostgreSQL) ImportBans(in []Ban) error
- func (a *AuthMTPostgreSQL) LastSrv(_ string) (string, error)
- func (a *AuthMTPostgreSQL) Passwd(name string) (salt, verifier []byte, err error)
- func (a *AuthMTPostgreSQL) RecordFail(addr, name string, sudo bool) error
- func (a *AuthMTPostgreSQL) SetLastSrv(_, _ string) error
- func (a *AuthMTPostgreSQL) SetPasswd(name string, salt, verifier []byte) error
- func (a *AuthMTPostgreSQL) Timestamp(name string) (time.Time, error)
- func (a *AuthMTPostgreSQL) Unban(id string) error
- type AuthMTSQLite3
- func (a *AuthMTSQLite3) Ban(addr, name string) error
- func (a *AuthMTSQLite3) Banned(addr, name string) bool
- func (a *AuthMTSQLite3) Close() error
- func (a *AuthMTSQLite3) Exists(name string) bool
- func (a *AuthMTSQLite3) Export() ([]User, error)
- func (a *AuthMTSQLite3) ExportBans() ([]Ban, error)
- func (a *AuthMTSQLite3) Import(in []User) error
- func (a *AuthMTSQLite3) ImportBans(in []Ban) error
- func (a *AuthMTSQLite3) LastSrv(_ string) (string, error)
- func (a *AuthMTSQLite3) Passwd(name string) (salt, verifier []byte, err error)
- func (a *AuthMTSQLite3) RecordFail(addr, name string, sudo bool) error
- func (a *AuthMTSQLite3) SetLastSrv(_, _ string) error
- func (a *AuthMTSQLite3) SetPasswd(name string, salt, verifier []byte) error
- func (a *AuthMTSQLite3) Timestamp(name string) (time.Time, error)
- func (a *AuthMTSQLite3) Unban(id string) error
- type Ban
- type ChatCmd
- type ClientConn
- func (cc *ClientConn) Ban() error
- func (cc *ClientConn) DoChatMsg(msg string)
- func (cc *ClientConn) HasPerms(want ...string) bool
- func (cc *ClientConn) Hop(serverName string) (err error)
- func (cc *ClientConn) HopGroup(groupName string) error
- func (cc *ClientConn) HopRaw(serverName string) error
- func (cc *ClientConn) Init() <-chan struct{}
- func (cc *ClientConn) Inv() mt.Inv
- func (cc *ClientConn) IsModChanJoined(channel string) bool
- func (cc *ClientConn) IsNew() bool
- func (cc *ClientConn) JoinModChan(channel string) <-chan bool
- func (cc *ClientConn) Kick(reason string)
- func (cc *ClientConn) LeaveModChan(channel string) <-chan bool
- func (cc *ClientConn) Log(dir string, v ...interface{})
- func (cc *ClientConn) Name() string
- func (cc *ClientConn) Perms() []string
- func (cc *ClientConn) SendChatMsg(msg ...any)
- func (cc *ClientConn) SendModChanMsg(channel, msg string) bool
- func (cc *ClientConn) ServerName() string
- func (cc *ClientConn) ShowFormspec(formname string, formspec string)
- func (cc *ClientConn) ToSrvCltInfo() *mt.ToSrvCltInfo
- type Config
- func (cnf Config) DefaultServer() Server
- func (cnf Config) DefaultServerInfo() (string, Server)
- func (cnf Config) DefaultServerName() string
- func (cnf Config) Pools() map[string]map[string]Server
- func (cnf Config) RandomGroupServer(search string) (string, bool)
- func (cnf Config) ServerGroups() map[string]map[string]Server
- type Interaction
- type InteractionHandler
- type LogWriter
- type Server
- type ServerConn
- type User
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuthBackendExists = errors.New("auth backend already set") ErrInvalidSRPHeader = errors.New("encoded password is not SRP") ErrLastSrvNotSupported = errors.New("auth backend does not support server information") )
var ( ErrNoServerConn = errors.New("no server connection") ErrNoSuchServer = errors.New("inexistent server") ErrNewMediaPool = errors.New("media pool unknown to client") )
var ( ErrEmptyAuthBackendName = errors.New("auth backend name is empty") ErrNilAuthBackend = errors.New("auth backend is nil") ErrBuiltinAuthBackend = errors.New("auth backend name collision with builtin") )
var ChatCmdTimeout = 10 * time.Second
ChatCmdTimeout is the time needed until a user is warned about a chat command that's taking long to execute.
var (
ErrEmptySrvSelectorName = errors.New("server selector name is empty")
)
var ErrNoBuildInfo = errors.New("unable to retrieve proxy version: no build info")
Functions ¶
func AddServer ¶
AddServer dynamically configures a new Server at runtime. Servers added in this way are ephemeral and will be lost when the proxy shuts down. The server must be part of a media pool with at least one other member. At least one of the other members always needs to be reachable. WARNING: Reloading the config will not overwrite servers added using this function. The server definition from the configuration file will silently be ignored.
func BuildPlugin ¶
func BuildPlugin() error
func ChatCmdExists ¶
ChatCmdExists reports if a ChatCmd exists.
func Clts ¶
func Clts() map[*ClientConn]struct{}
Clts returns all ClientConns currently connected to the proxy.
func DecodeVerifierAndSalt ¶
func EncodeVerifierAndSalt ¶
func FormspecEscape ¶
FormspecEscape escapes characters that cannot be used in formspecs.
func LoadConfig ¶
func LoadConfig() error
LoadConfig attempts to parse the configuration file. It leaves the config unchanged if there is an error and returns the error.
func LoadPlugins ¶
func LoadPlugins()
LoadPlugins loads all plugins. Further calls are no-ops. This function is not intended to be called by plugins. It is meant for tools such as mt-auth-convert.
func Path ¶
Path prepends the directory the executable is in to the given path. It follows symlinks to the executable.
func Players ¶
func Players() map[string]struct{}
Players returns the names of all players that are currently connected to the proxy.
func RegisterAuthBackend ¶
func RegisterAuthBackend(name string, ab AuthBackend) error
RegisterAuthBackend registers a new authentication backend implementation. The name must be unique, non-empty and must not collide with a builtin authentication backend. The authentication backend must be non-nil. Registered backends can be enabled by specifying their name in the AuthBackend config option. Backend-specific configuration is handled by the calling plugin's configuration mechanism at initialization time. Backends must be registered at initialization time (before the init functions return). Backends registered after initialization time will not be available to the user.
func RegisterChatCmd ¶
RegisterChatCmd adds a new ChatCmd. It returns true on success and false if a command with the same name already exists.
func RegisterInteractionHandler ¶
func RegisterInteractionHandler(handler InteractionHandler)
RegisterInteractionHandler adds a new InteractionHandler.
func RegisterOnChatMsg ¶
func RegisterOnChatMsg(handler func(*ClientConn, string) string)
RegisterOnChatMsg registers a handler that is called when a client sends a chat message that is not a proxy command. The returned string overrides the original message. Later handlers will receive the modified message. Handlers are called in registration order. If the final message is empty, it is not forwarded to the upstream server.
func RegisterOnCltModChanMsg ¶
func RegisterOnCltModChanMsg(handler func(string, *ClientConn, string) bool)
RegisterOnCltModChanMsg registers a handler that is called when a client sends a message on a modchannel. If any handler returns true, the message is not forwarded to the upstream server.
func RegisterOnInvAction ¶
func RegisterOnInvAction(handler func(*ClientConn, string) string)
RegisterOnInvAction registers a handler that is called when a client attempts to perform an inventory action. The returned string overrides the original action. Later handlers will receive the modified action. Handlers are called in registration order. If the final action string is empty, the action is not forwarded to the upstream server. You may use the mt package to interact with the action strings.
func RegisterOnJoin ¶
func RegisterOnJoin(handler func(*ClientConn) string)
RegisterOnJoin registers a handler that is called when a client finishes connecting to the proxy (TOSERVER_CLIENT_READY packet) but before it is connected to an upstream server. If any handler returns a non-empty string, the client is kicked with that message. Handlers are run sequentially and block the client's connection and packet handling procedure.
func RegisterOnLeave ¶
func RegisterOnLeave(handler func(*ClientConn))
RegisterOnLeave registers a handler that is called when a client disconnects for any reason after reaching the ready stage. Handlers are run sequentially.
func RegisterOnPlayerReceiveFields ¶
func RegisterOnPlayerReceiveFields(formname string, handler func(*ClientConn, []mt.Field))
RegisterOnPlayerReceiveFields registers a callback that is called when a client submits a specific formspec. Events triggering this callback include a button being pressed, Enter being pressed while a text field is focused, a checkbox being toggled, an item being selected in a dropdown list, selecting a new tab, changing the selection in a textlist or table, selecting an entry in a textlist or table, a scrollbar being moved or the form actively being closed by the player.
func RegisterOnSrvModChanMsg ¶
func RegisterOnSrvModChanMsg(handler func(*ClientConn, string, string, string) bool)
RegisterOnSrvModChanMsg registers a handler that is called when another client of the current upstream server or a server mod sends a message on a modchannel. If any handler returns true, the message is not forwarded to the client.
func RegisterSrvSelector ¶
func RegisterSrvSelector(name string, sel func(*ClientConn) (string, Server)) error
RegisterSrvSelector registers a server selection handler which can be enabled using the `SrvSelector` config option. Empty names are an error. If the handler returns an empty server name, the regular server selection procedure is used. Only one server selector can be active at a time.
func RmServer ¶
RmServer deletes a Server from the Config at runtime. Only servers added using AddServer can be deleted at runtime. Returns true on success or if the server doesn't exist.
func Run ¶
func Run()
Run initializes the proxy and starts the main listener loop. It blocks forever.
func SendModChanMsg ¶
func SendModChanMsg(channel, msg string)
Types ¶
type AuthBackend ¶
type AuthBackend interface { // Exists reports whether a user with the specified name exists. // The result is false if an error is encountered. Exists(name string) bool // Passwd returns the SRP verifier and salt of the user // with the specified name or an error. Passwd(name string) (salt, verifier []byte, err error) // SetPasswd sets the SRP verifier and salt of the user // with the specified name. SetPasswd(name string, salt, verifier []byte) error // LastSrv returns the name of the last server the user // with the specified name intentionally connected to or an error. // This method should return an error if this feature is unsupported. // Errors are handled gracefully (by connecting the user // to the default server or group) and aren't logged. LastSrv(name string) (string, error) // SetLastSrv sets the name of the last server the user // with the specified name intentionally connected to. // This method should not return an error if this feature is unsupported. // Errors will make server hopping fail. SetLastSrv(name, srv string) error // Timestamp returns the last time the user with the specified name // connected to the proxy or an error. Timestamp(name string) (time.Time, error) // Import adds or modifies authentication entries in bulk. Import(in []User) error // Export returns all authentication entries or an error. Export() ([]User, error) // Ban adds a ban entry for a network address and an associated name. // Only the specified network address is banned from connecting. // Existing connections are not kicked. Ban(addr, name string) error // Unban deletes a ban entry by network address or username. Unban(id string) error // Banned reports whether a network address or username is banned. // The result is true if either identifier is banned // or if an error is encountered. Banned(addr, name string) bool // RecordFail records an authentication failure regarding a certain // network address and username. The implementation is not required // to process this event in any way, but the intent is to allow // rate limiting / brute-force protection to be implemented by plugins. RecordFail(addr, name string, sudo bool) error // ImportBans adds or modifies ban entries in bulk. ImportBans(in []Ban) error // Export returns all ban entries or an error. ExportBans() ([]Ban, error) }
An AuthBackend provides authentication and moderation functionality. This typically includes persistent storage. It does not handle authorization, i.e. permission checks. All methods are safe for concurrent use.
func Auth ¶
func Auth(name string) (AuthBackend, bool)
Auth returns an authentication backend by name or false if it doesn't exist.
func DefaultAuth ¶
func DefaultAuth() AuthBackend
DefaultAuth returns the authentication backend that is currently in use or nil during initialization time.
type AuthFiles ¶
type AuthFiles struct{}
func (AuthFiles) Banned ¶
Banned reports whether a network address is banned. Error cases count as banned.
func (AuthFiles) Exists ¶
Exists reports whether a user is registered. Error cases count as inexistent.
func (AuthFiles) ExportBans ¶
ExportBans returns data that can be processed by ImportBans or an error,
func (AuthFiles) ImportBans ¶
ImportBans deletes all ban entries and adds the passed entries.
func (AuthFiles) RecordFail ¶
RecordFail is a no-op.
func (AuthFiles) SetLastSrv ¶
SetLastSrv sets the last server a user was on.
func (AuthFiles) SetPasswd ¶
SetPasswd creates a password entry if necessary and sets the password of a user.
type AuthMTPostgreSQL ¶
type AuthMTPostgreSQL struct {
// contains filtered or unexported fields
}
A handle to a PostgreSQL authentication database. The upstream Minetest schema is used.
Table info:
Table "public.auth" Column | Type | Collation | Nullable | Default
------------+---------+-----------+----------+------------------------------------
id | integer | | not null | nextval('auth_id_seq'::regclass) name | text | | | password | text | | | last_login | integer | | not null | 0
Indexes:
"auth_pkey" PRIMARY KEY, btree (id) "auth_name_key" UNIQUE CONSTRAINT, btree (name)
Sequence info:
Sequence "public.auth_id_seq" Type | Start | Minimum | Maximum | Increment | Cycles? | Cache
---------+-------+---------+------------+-----------+---------+-------
integer | 1 | 1 | 2147483647 | 1 | no | 1
Owned by: public.auth.id
func NewAuthMTPostgreSQL ¶
func NewAuthMTPostgreSQL(conn string) (*AuthMTPostgreSQL, error)
NewAuthMTPostgreSQL opens the PostgreSQL authentication database at the specified connection string.
func (*AuthMTPostgreSQL) Ban ¶
func (a *AuthMTPostgreSQL) Ban(addr, name string) error
Ban adds a ban entry for a network address and an associated name.
func (*AuthMTPostgreSQL) Banned ¶
func (a *AuthMTPostgreSQL) Banned(addr, name string) bool
Banned reports whether a network address is banned. Error cases count as banned.
func (*AuthMTPostgreSQL) Close ¶
func (a *AuthMTPostgreSQL) Close() error
Close closes the underlying PostgreSQL database handle.
func (*AuthMTPostgreSQL) Exists ¶
func (a *AuthMTPostgreSQL) Exists(name string) bool
Exists reports whether a user is registered. Error cases count as inexistent.
func (*AuthMTPostgreSQL) Export ¶
func (a *AuthMTPostgreSQL) Export() ([]User, error)
Export returns data that can be processed by Import or an error.
func (*AuthMTPostgreSQL) ExportBans ¶
func (a *AuthMTPostgreSQL) ExportBans() ([]Ban, error)
ExportBans returns data that can be processed by ImportBans or an error.
func (*AuthMTPostgreSQL) Import ¶
func (a *AuthMTPostgreSQL) Import(in []User) error
Import adds the passed users.
func (*AuthMTPostgreSQL) ImportBans ¶
func (a *AuthMTPostgreSQL) ImportBans(in []Ban) error
ImportBans adds the passed entries.
func (*AuthMTPostgreSQL) LastSrv ¶
func (a *AuthMTPostgreSQL) LastSrv(_ string) (string, error)
LastSrv always returns an error since the Minetest database schema cannot store this information.
func (*AuthMTPostgreSQL) Passwd ¶
func (a *AuthMTPostgreSQL) Passwd(name string) (salt, verifier []byte, err error)
Passwd returns the SRP salt and verifier of a user or an error.
func (*AuthMTPostgreSQL) RecordFail ¶
func (a *AuthMTPostgreSQL) RecordFail(addr, name string, sudo bool) error
RecordFail is a no-op.
func (*AuthMTPostgreSQL) SetLastSrv ¶
func (a *AuthMTPostgreSQL) SetLastSrv(_, _ string) error
SetLastSrv is a no-op since the Minetest database schema cannot store this information.
func (*AuthMTPostgreSQL) SetPasswd ¶
func (a *AuthMTPostgreSQL) SetPasswd(name string, salt, verifier []byte) error
SetPasswd creates a password entry if necessary and sets the password of a user.
func (*AuthMTPostgreSQL) Timestamp ¶
func (a *AuthMTPostgreSQL) Timestamp(name string) (time.Time, error)
Timestamp returns the last time an authentication entry was accessed or an error.
func (*AuthMTPostgreSQL) Unban ¶
func (a *AuthMTPostgreSQL) Unban(id string) error
Unban deletes a ban entry. It accepts bot network addresses and player names.
type AuthMTSQLite3 ¶
type AuthMTSQLite3 struct {
// contains filtered or unexported fields
}
A handle to a SQLite3 authentication database. The upstream Minetest schema is used.
Table info:
0|id|INTEGER|0||1 1|name|VARCHAR(32)|0||0 2|password|VARCHAR(512)|0||0 3|last_login|INTEGER|0||0
func NewAuthMTSQLite3 ¶
func NewAuthMTSQLite3() (*AuthMTSQLite3, error)
NewAuthMTSQLite3 opens the SQLite3 authentication database at auth.sqlite.
func (*AuthMTSQLite3) Ban ¶
func (a *AuthMTSQLite3) Ban(addr, name string) error
Ban adds a ban entry for a network address and an associated name.
func (*AuthMTSQLite3) Banned ¶
func (a *AuthMTSQLite3) Banned(addr, name string) bool
Banned reports whether a network address is banned. Error cases count as banned.
func (*AuthMTSQLite3) Close ¶
func (a *AuthMTSQLite3) Close() error
Close closes the underlying SQLite3 database handle.
func (*AuthMTSQLite3) Exists ¶
func (a *AuthMTSQLite3) Exists(name string) bool
Exists reports whether a user is registered. Error cases count as inexistent.
func (*AuthMTSQLite3) Export ¶
func (a *AuthMTSQLite3) Export() ([]User, error)
Export returns data that can be processed by Import or an error.
func (*AuthMTSQLite3) ExportBans ¶
func (a *AuthMTSQLite3) ExportBans() ([]Ban, error)
ExportBans returns data that can be processed by ImportBans or an error.
func (*AuthMTSQLite3) Import ¶
func (a *AuthMTSQLite3) Import(in []User) error
Import adds the passed users.
func (*AuthMTSQLite3) ImportBans ¶
func (a *AuthMTSQLite3) ImportBans(in []Ban) error
ImportBans adds the passed entries.
func (*AuthMTSQLite3) LastSrv ¶
func (a *AuthMTSQLite3) LastSrv(_ string) (string, error)
LastSrv always returns an error since the Minetest database schema cannot store this information.
func (*AuthMTSQLite3) Passwd ¶
func (a *AuthMTSQLite3) Passwd(name string) (salt, verifier []byte, err error)
Passwd returns the SRP salt and verifier of a user or an error.
func (*AuthMTSQLite3) RecordFail ¶
func (a *AuthMTSQLite3) RecordFail(addr, name string, sudo bool) error
RecordFail is a no-op.
func (*AuthMTSQLite3) SetLastSrv ¶
func (a *AuthMTSQLite3) SetLastSrv(_, _ string) error
SetLastSrv is a no-op since the Minetest database schema cannot store this information.
func (*AuthMTSQLite3) SetPasswd ¶
func (a *AuthMTSQLite3) SetPasswd(name string, salt, verifier []byte) error
SetPasswd creates a password entry if necessary and sets the password of a user.
func (*AuthMTSQLite3) Timestamp ¶
func (a *AuthMTSQLite3) Timestamp(name string) (time.Time, error)
Timestamp returns the last time an authentication entry was accessed or an error.
func (*AuthMTSQLite3) Unban ¶
func (a *AuthMTSQLite3) Unban(id string) error
Unban deletes a ban entry. It accepts bot network addresses and player names.
type ChatCmd ¶
type ChatCmd struct { Name string Perm string Help string Usage string Handler func(*ClientConn, ...string) string }
A ChatCmd holds information on how to handle a chat command.
type ClientConn ¶
A ClientConn is a connection to a minetest client.
func Find ¶
func Find(name string) *ClientConn
Find returns the ClientConn that has the specified player name. If no ClientConn is found, nil is returned.
func (*ClientConn) Ban ¶
func (cc *ClientConn) Ban() error
Ban disconnects the ClientConn and prevents the underlying network address from connecting again.
func (*ClientConn) DoChatMsg ¶
func (cc *ClientConn) DoChatMsg(msg string)
DoChatMsg handles a chat message string as if it was sent by the ClientConn.
func (*ClientConn) HasPerms ¶
func (cc *ClientConn) HasPerms(want ...string) bool
HasPerms returns true if the ClientConn has all of the specified permissions. Otherwise it returns false. This method matches wildcards, but they may only be used at the end of a raw permission. Asterisks in other places will be treated as regular characters.
func (*ClientConn) Hop ¶
func (cc *ClientConn) Hop(serverName string) (err error)
Hop connects the ClientConn to the specified upstream server or the first working fallback server, saving the player's last server unless `ForceDefaultSrv` is enabled. If all attempts fail the client stays connected to the current server with the potential for inconsistent state. At the moment the ClientConn is NOT fixed if an error occurs so the player may have to reconnect.
func (*ClientConn) HopGroup ¶
func (cc *ClientConn) HopGroup(groupName string) error
HopGroup connects the ClientConn to the specified server group or the first working fallback server, saving the player's last server unless `ForceDefaultSrv` is enabled. See the documentation on `Server.Groups` in `doc/config.md` for details on how a specific game server is selected from the group name. If all attempts fail the client stays connected to the current server with the potential for inconsistent state. At the moment the ClientConn is NOT fixed if an error occurs so the player may have to reconnect.
func (*ClientConn) HopRaw ¶
func (cc *ClientConn) HopRaw(serverName string) error
HopRaw connects the ClientConn to the specified upstream server. At the moment the ClientConn is NOT fixed if an error occurs so the player may have to reconnect.
This method ignores fallback servers and doesn't save the player's last server. You may use the `Hop` wrapper for these purposes.
func (*ClientConn) Init ¶
func (cc *ClientConn) Init() <-chan struct{}
Init returns a channel that is closed when the ClientConn enters the csActive state.
func (*ClientConn) Inv ¶
func (cc *ClientConn) Inv() mt.Inv
Inv returns a copy of the current server-provided inventory of the client or nil if the client is not connected to a server.
func (*ClientConn) IsModChanJoined ¶
func (cc *ClientConn) IsModChanJoined(channel string) bool
IsModChanJoined returns whether this client is currently subscribed to the specified modchannel. This is mainly useful for tracking success across server hops.
func (*ClientConn) IsNew ¶
func (cc *ClientConn) IsNew() bool
IsNew reports whether a new account was registered for the ClientConn.
func (*ClientConn) JoinModChan ¶
func (cc *ClientConn) JoinModChan(channel string) <-chan bool
JoinModChan attempts to subscribe to a modchannel, returning a channel that yields a boolean indicating success. The proxy will try to rejoin the channel after switching servers, but this is not guaranteed to succeed and errors will not be reported to the caller. This condition can be checked against using the IsModChanJoined method. This method may block indefinitely if the client switches servers before a response is received. If this cannot be controlled, using a select statement with a timeout is recommended.
func (*ClientConn) Kick ¶
func (cc *ClientConn) Kick(reason string)
Kick sends mt.ToCltKick with the specified custom reason and closes the ClientConn.
func (*ClientConn) LeaveModChan ¶
func (cc *ClientConn) LeaveModChan(channel string) <-chan bool
LeaveModChan attempts to unscribe from a modchannel, returning a channel yielding a boolean indicating success.
func (*ClientConn) Log ¶
func (cc *ClientConn) Log(dir string, v ...interface{})
Log logs an interaction with the ClientConn. dir indicates the direction of the interaction.
func (*ClientConn) Name ¶
func (cc *ClientConn) Name() string
Name returns the player name of the ClientConn.
func (*ClientConn) Perms ¶
func (cc *ClientConn) Perms() []string
Perms returns the raw permissions of the ClientConn.
func (*ClientConn) SendChatMsg ¶
func (cc *ClientConn) SendChatMsg(msg ...any)
SendChatMsg sends a chat message to the ClientConn.
func (*ClientConn) SendModChanMsg ¶
func (cc *ClientConn) SendModChanMsg(channel, msg string) bool
SendModChanMsg sends a message to the current upstream server and all subscribed clients connected to it on a modchannel.
func (*ClientConn) ServerName ¶
func (cc *ClientConn) ServerName() string
ServerName returns the name of the current upstream server of the ClientConn. It is empty if there is no upstream connection.
func (*ClientConn) ShowFormspec ¶
func (cc *ClientConn) ShowFormspec(formname string, formspec string)
ShowFormspec opens a formspec on the client. The form name should follow the standard minetest naming convention, i.e. "pluginname:formname". If formname is empty, it reshows the inventory formspec without updating it for future opens. If formspec is empty, the formspec is closed. If formname is empty at the same time, any formspec is closed regardless of its name.
func (*ClientConn) ToSrvCltInfo ¶
func (cc *ClientConn) ToSrvCltInfo() *mt.ToSrvCltInfo
CltInfo returns the ToSrvCltInfo known about the client.
type Config ¶
type Config struct { NoPlugins bool NoAutoPlugins bool CmdPrefix string RequirePasswd bool SendInterval float32 UserLimit int AuthBackend string AuthPostgresConn string NoTelnet bool TelnetAddr string BindAddr string DefaultSrv string SrvSelector string Servers map[string]Server ForceDefaultSrv bool KickOnNewPool bool CSMRF struct { NoCSMs bool ChatMsgs bool ItemDefs bool NodeDefs bool NoLimitMapRange bool PlayerList bool } MapRange uint32 DropCSMRF bool Groups map[string][]string UserGroups map[string]string List struct { Enable bool Addr string Interval int Name string Desc string URL string Creative bool Dmg bool PvP bool Game string FarNames bool Mods []string } }
A Config contains information from the configuration file that affects the way the proxy works.
func Conf ¶
func Conf() Config
Conf returns a copy of the Config used by the proxy. Any modifications will not affect the original Config.
func (Config) DefaultServer ¶
DefaultServer returns information about the default server. If no servers exist the returned struct will be uninitialized. This is a faster shortcut for Config.Servers[Config.DefaultServerName()]. You should thus only use this method or the DefaultServerInfo method.
func (Config) DefaultServerInfo ¶
DefaultServerInfo returns both the name of the default server and information about it. The return values are uninitialized if no servers exist.
func (Config) DefaultServerName ¶
DefaultServerName returns the name of the default server. If no servers exist it returns an empty string.
func (Config) RandomGroupServer ¶
RandomGroupServer returns the name of a random member of a server group or the input string if it is a valid, existent server name. It also returns a boolean indicating success. The returned string is blank if there is a failure, i.e. if the input string is neither a server nor a group.
type Interaction ¶
type Interaction uint8
const ( Dig Interaction = iota StopDigging Dug Place Use Activate AnyInteraction = 255 )
type InteractionHandler ¶
type InteractionHandler struct { Type Interaction Handler func(*ClientConn, *mt.ToSrvInteract) bool }
A InteractionHandler holds information on how to handle a Minetest Interaction.
type ServerConn ¶
A ServerConn is a connection to a minetest server.
func (*ServerConn) Init ¶
func (sc *ServerConn) Init() <-chan struct{}
Init returns a channel that is closed when the ServerConn enters the csActive state.
func (*ServerConn) Log ¶
func (sc *ServerConn) Log(dir string, v ...interface{})
Log logs an interaction with the ServerConn. dir indicates the direction of the interaction.
Source Files
¶
- activeobject.go
- auth.go
- auth_files.go
- auth_mtpostgresql.go
- auth_mtsqlite3.go
- chat.go
- client_conn.go
- config.go
- connect.go
- content.go
- fallback.go
- formspec.go
- hop.go
- list.go
- listen.go
- log.go
- mediacache.go
- moderation.go
- perms.go
- players.go
- plugin.go
- plugin_auth.go
- plugin_chat.go
- plugin_chatcmd.go
- plugin_formspec.go
- plugin_interact.go
- plugin_inv.go
- plugin_join_leave.go
- plugin_modchan.go
- plugin_srvselect.go
- process.go
- proxy.go
- run.go
- server_conn.go
- uptime.go
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
mt-auth-convert
mt-auth-convert converts between authentication backends.
|
mt-auth-convert converts between authentication backends. |
mt-build-plugin
mt-build-plugin builds a plugin using the proxy version the tool was built for.
|
mt-build-plugin builds a plugin using the proxy version the tool was built for. |
mt-multiserver-proxy
mt-multiserver-proxy starts the reverse proxy.
|
mt-multiserver-proxy starts the reverse proxy. |