server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfServerCorrect

func CheckIfServerCorrect(server *Server) error

func CheckServerPorts

func CheckServerPorts(server *Server) error

CheckServerPorts validates the port numbers within a Server struct. It ensures that all port numbers are within the valid range (greater than 0 and less than or equal to 65535) and that there are no duplicate port numbers.

func CopyAndMakeOld added in v0.1.0

func CopyAndMakeOld(path string) error

func GetProcessPid added in v0.1.1

func GetProcessPid(processPath string) (uint32, error)

func IsProcessRunningWithPath added in v0.1.1

func IsProcessRunningWithPath(processPath string) (bool, error)

func KillProcessUsingPid added in v0.1.1

func KillProcessUsingPid(pid uint32) error

Types

type Server

type Server struct {
	Command *exec.Cmd `json:"-"`

	DisableUpdateOnStart  bool   `json:"disableUpdateOnStart"`
	RestartOnServerQuit   bool   `json:"restartOnServerQuit"`
	UseIniConfig          bool   `json:"useIniConfig"`
	DiscordWebHook        string `json:"discordWebHook"`
	DiscordWebHookEnabled bool   `json:"discordWebHookEnabled"`
	UseAsaAPI             bool   `json:"useAsaAPI"`

	ExtraDashArgs              string `json:"extraDashArgs"`
	ExtraQuestionmarkArguments string `json:"extraQuestionmarkArguments"`
	KickIdlePlayers            bool   `json:"kickIdlePlayers"`

	Mods string `json:"mods"`

	// Id is the id of the server
	Id int `json:"id"`

	// ServerAlias is the name of the config (an alias for the server)
	ServerAlias string `json:"serverAlias"`

	// ServerPath is the path where the server is installed/should be.
	ServerPath string `json:"serverPath"`

	//Server Name and Passwords
	ServerName string `json:"serverName"`

	ServerPassword    string `json:"serverPassword"`
	AdminPassword     string `json:"adminPassword"`
	SpectatorPassword string `json:"spectatorPassword"`

	//Server Networking
	IpAddress  string `json:"ipAddress"`
	ServerPort int    `json:"serverPort"`
	PeerPort   int    `json:"peerPort"` //TODO: find out if used
	QueryPort  int    `json:"queryPort"`
	RCONPort   int    `json:"rconPort"`

	ServerMap  string `json:"serverMap"`
	MaxPlayers int    `json:"maxPlayers"`

	StartWithApplication bool `json:"startWithApplication"`
	// contains filtered or unexported fields
}

func (*Server) CheckAsaAPI added in v0.1.2

func (s *Server) CheckAsaAPI() error

func (*Server) CreateArguments

func (s *Server) CreateArguments() []string

returns questionamrk arguments for the server and dash arguments for the server

func (*Server) CreateServerCmd added in v0.0.6

func (s *Server) CreateServerCmd() *exec.Cmd

CreateServerCmd returns the command to start the server

func (*Server) ForceStop

func (s *Server) ForceStop() error

ForceStop forces the server to stop "quitting/killing the process"

func (*Server) GetServerPlayerCount added in v0.1.0

func (s *Server) GetServerPlayerCount() (int, error)

func (*Server) Init added in v0.2.0

func (s *Server) Init()

Init runs the code that needs to be run when the server is created/loaded like watching the config files

func (*Server) IsServerRunning

func (s *Server) IsServerRunning() bool

GetServerStatus returns the status of the server.

func (*Server) SaveWorld added in v0.1.0

func (s *Server) SaveWorld() error

save the world

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop added in v0.1.0

func (s *Server) Stop() error

func (*Server) UpdateConfig

func (s *Server) UpdateConfig() error

UpdateConfig updates the configuration files for the server e.g.: GameUserSettings.ini

type ServerController

type ServerController struct {
	Servers map[int]*Server
	// contains filtered or unexported fields
}

ServerController struct

func NewServerController

func NewServerController(hc *helpers.HelpersController) *ServerController

NewServerController creates a new ServerController application struct

func (*ServerController) CheckServerInstalled

func (c *ServerController) CheckServerInstalled(id int) (bool, error)

CheckServerInstalled Checks if the server dir exists.

func (*ServerController) CreateServer

func (c *ServerController) CreateServer(saveToConfig bool) (Server, error)

CreateServer Creates a new server, returns it and adds it to the map. If it fails it returns an error which is catch-able in the Frontend.

func (*ServerController) DeleteProfile added in v0.0.3

func (c *ServerController) DeleteProfile(id int) error

DeleteProfile deletes the profile with the given id. If it fails it returns an error which is catch-able

func (*ServerController) DeleteServerFiles added in v0.0.3

func (c *ServerController) DeleteServerFiles(id int) error

DeleteServerFiles deletes the server files from the server with the given id. If it fails it returns an error which is catch-able

func (*ServerController) ForceStopServer

func (c *ServerController) ForceStopServer(id int) error

func (*ServerController) GetAllServers

func (c *ServerController) GetAllServers() (map[int]Server, error)

GetAllServers gets all servers and saves them to ServerController.Servers and also returns them, if it fails it returns nil and error. If they already exist in the map it will just get that.

func (*ServerController) GetAllServersFromDir

func (c *ServerController) GetAllServersFromDir() (map[int]*Server, error)

GetAllServersFromDir gets all servers from dir and saves them to ServerController.Servers and also returns them, if it fails it returns nil and an error which is catch-able in the frontend. This will overwrite c.Servers!

func (*ServerController) GetConnectedPlayerCount added in v0.1.0

func (c *ServerController) GetConnectedPlayerCount(id int) (int, error)

GetConnectedPlayerCount returns the number of connected players

func (*ServerController) GetGusAsMap added in v0.2.0

func (c *ServerController) GetGusAsMap(id int) (map[string]map[string][]string, error)

func (*ServerController) GetNetworkInterfacesIp

func (c *ServerController) GetNetworkInterfacesIp() map[string]string

func (*ServerController) GetServer

func (c *ServerController) GetServer(id int) (Server, error)

GetServer returns the server with the given id if it does not exist it returns an empty server. This function checks the server dir too. If it does not exist in the map, and it does in the dir then it will add it to the map. It can error which is catch-able in the frontend

func (*ServerController) GetServerConfigFile added in v0.1.2

func (c *ServerController) GetServerConfigFile(id int) (string, error)

func (*ServerController) GetServerDir

func (c *ServerController) GetServerDir() string

GetServerDir returns the server directory

func (*ServerController) GetServerStartupCommand added in v0.0.6

func (c *ServerController) GetServerStartupCommand(id int) (string, error)

func (*ServerController) GetServerStatus

func (c *ServerController) GetServerStatus(id int) (bool, error)

func (*ServerController) GetValueFromGame added in v0.2.0

func (c *ServerController) GetValueFromGame(id int, sectionName string, keyName string) (string, error)

GetValueFromGame returns the value from the game with the given section and key name. If it fails it returns an error which is catch-able

func (*ServerController) GetValueFromGus added in v0.2.0

func (c *ServerController) GetValueFromGus(id int, sectionName string, keyName string) (string, error)

GetValueFromGus returns the value from the gus with the given section and key name. If it fails it returns an error which is catch-able

func (*ServerController) InitAllServers added in v0.2.0

func (c *ServerController) InitAllServers()

func (*ServerController) SaveGusFromMap added in v0.2.0

func (c *ServerController) SaveGusFromMap(id int, gusMap map[string]map[string][]string) error

func (*ServerController) SaveServer

func (c *ServerController) SaveServer(server Server) error

SaveServer saves the server with the given id, and returns bool if successful

func (*ServerController) SaveServerConfigFile added in v0.1.2

func (c *ServerController) SaveServerConfigFile(content string, id int) error

func (*ServerController) Shutdown added in v0.2.0

func (c *ServerController) Shutdown()

func (*ServerController) StartServer

func (c *ServerController) StartServer(id int) error

StartServer starts the server. It will only start a server that exists in the map

func (*ServerController) StartServersWithApplication added in v0.1.0

func (c *ServerController) StartServersWithApplication()

region Backend Functions

func (*ServerController) Startup

func (c *ServerController) Startup(ctx context.Context)

Startup is called when the app starts. The context is saved, so we can call the runtime methods

func (*ServerController) StopServer added in v0.1.0

func (c *ServerController) StopServer(id int) error

func (*ServerController) UpdateValueInGame added in v0.2.0

func (c *ServerController) UpdateValueInGame(id int, sectionName string, keyName string, value string) error

func (*ServerController) UpdateValueInGus added in v0.2.0

func (c *ServerController) UpdateValueInGus(id int, sectionName string, keyName string, value string) error

type Win32_Process added in v0.1.1

type Win32_Process struct {
	ProcessID      uint32
	ExecutablePath *string
}

Jump to

Keyboard shortcuts

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