Jump to content

ServerHostingGuide

From Logic World Wiki

This guide assumes: (meme™️)

  • You know how to install software, by searching the internet for how to do that.
  • You are able to read and filter the information relevant to you from this guide.
  • Your attention span being high enough to be able to actually collect & modify commands you need and not just copy paste some commands from somewhere. RIP Gen > 2010 😋
  • There is no one using Windows server for remote hosting (but only Linux).
  • Mac to behave pretty much like Linux in all regards when it comes to hosting your server.

This guide is inspired by:

Structure of this guide:

  • Types: Which server versions are there?
  • Obtain: How / Where do you get the server software/assets from?
  • Structure: Which files exist in a server? What do they do?
  • Launching: How to start the server & program arguments.
  • Saves: How to configure saves?
  • Configuration: The config files.
  • Console: How to use server console?
  • Networking: What is there to know?
  • Hosting on Linux: Run in backgound & Autostart & Symlinks

If you have any questions, ping Ecconia on the games Discord server.

Types (& terminology)

Currently the game is distributed via Itch and Steam. On both you can download Logic World and Logic World Dedicated Server.

The "game" Logic World comes with a "client" and an "internal server" (which the "game" spins up for Single Player [SP]). The "dedicated server" Logic World Dedicated Server has just that (used for hosting Multi Player [MP]).

In terms of server, there is not much of a difference between both types. And the dedicated server and the internal server are the exact same software. You get the same "server" from both installations.

The game & dedicated server are available for Windows, Linux and Mac. As the dedicated server is built with DotNet, many of the provided DLLs are interchangeable.

The difference between both types is how much GameData is distributed. The Logic World Dedicated Server comes with a smaller GameData directory. All assets which are client-only are not delivered with the dedicated server installation, this means smaller download/file size.

Important is: All means of installation give you the same software per OS. If you use the dedicated server, you will have a smaller GameData folder, but you can also use the full GameData folder from the game installation to host your server.

Obtaining server

To obtain the server, you have to purchase the game via Itch or Steam.

On Itch you can simply download a ZIP of game or dedicated server for Windows/Linux/Mac. As for Steam you can only install the game or dedicated server for your current OS. However, there is a tool SteamCMD, which let's you download the dedicated server for a machine without your Steam client.

Download directly:

Itch:

Link to games Itch website: https://mousehatgames.itch.io/logic-world

For your local machine, you can simply download the appropriate dedicated server via a browser. And extract it locally.

If you wish to download from Itch to a remote Linux machine. You can't simply copy the download link from the download button. You will have to start the download (and optionally cancel it). Once it exists in your browsers download manager, you can copy the full download URL with access tokens from there.

Download with

  • wget: Run wget '<URL here>' -O server.zip
  • curl: Run curl '<URL here>' --output server.zip

You have to replace <URL here> with the actual URL from your browser. If you forget to wrap the URL in quotation, your terminal might split it into multiple arguments and fail the download.

Finally just run unzip server.zip to get a folder with all server files.

Steam Client:

For your local machine, install the game or the dedicated server with your steam client.

The Logic World Dedicated Server is in the "Tools Category" in your Steam Library, which is generally hidden by default. You can make it visible by using the dropdown above your game list and select Tools. Find the dedicated server in the now bigger list of games, it has the same Logo but black icon on white background.

If you wish to use a downloaded version on a server, you will have to upload it to the server or use SteamCMD.

Steam CMD (Command):

Steam CMD is a command line Steam client without GUI. You can install it on Linux systems to download a dedicated server.

Installation and usage guide: SteamCMD Wiki

The command steamcmd +force_install_dir <path> +login <username> +app_update 1252670 -beta public-previews validate +quit will download the dedicated server for you (if you replace <path> and <username>).

SteamCMD is an interactive console. Once started you can run commands inside of it. But you can also pass the commands to run as arguments to the steamcmd command, by prefixing the commands with +. Each steam command can have arguments and options (starting with -), just like normal terminal commands.

Commands/Arguments explained:

  • +login <username> (Required): Provide your username, so that Steam can login as your user. This will interactively ask for your password and Steam guard code (sent via Email).
  • +app_update 1252670 (Required): Defines the game/tool to download. In this case the Logic World Dedicated Server.
    • -beta public-previews (Optional): You can supply this to enable Logic Worlds preview versions. If you are updating a game, leaving this argument away preserves the chosen beta. If you wish to switch the current beta you have to supply it again. To switch to the main server version, you have to choose -beta public.
    • validate (Optional): Validates files. SteamCMD wiki recommends to do this for the initial installation and when issues occur.
  • +force_install_dir <path> (Optional): Will install the game to a folder specified by you. If not supplied, it will install the game in TODO: Where exactly? You can still use it from there.
  • +quit: Exits the SteamCMD console.

If you did not provide a force_install_dir command to SteamCMD, you sometimes won't know where it exactly installed the dedicated server. Check if ~/Steam/steamapps/common/Logic World Dedicated Server/ exits. Else simply scan your whole disk for it: find / -name "Logic World Dedicated Server" -type d 2>/dev/null

A note on permissions. Steam will mark almost all DLLs and executables of the dedicated server as executable. The only file you have to execute is ./Server. You can fix this by running:

find . -type d -print0 | xargs -0 chmod 755
find . -type f -print0 | xargs -0 chmod 664
chmod +x ./Server/Server

for the downloaded steam folders.

Don't copy; use internal / dedicated server directly

You can also run the Steam installed internal or dedicated servers directly. The procedure is the exact same as if you would run a dedicated server which you created in some folder on some machine.

Pros:

  • Nice for quickly setting up a world to show it to others.
  • Nice for quickly testing something.

Cons:

  • If running internal server, there might be collision with config.jecs when playing single-player. The game might modify the config.jecs file.
  • If running internal server, you cannot/shouldn't open the world hosted by your server in single-player.
  • Starting the dedicated server via Steam won't give you a console.
  • Difficult to have multiple servers. Especially when they need different config files.
  • If you uninstall the game or the dedicated server, then Steam will delete their installation dirctories. These do contain your worlds, be careful (and pray that steam cloud saves them).

For longer play-sessions, use the dedicated server or copy the internal server into a dedicated folder.

Uploading local files:

In some cases, you cannot download the game files on the server directly for any reason. It is simply easier to just upload the game files you already have on your local machine.

Ofc this method only works, if the remote OS matches this servers OS (if downloaded via Steam, your local and remote system must use the same OS).

Dedicated server files:

The dedicated server consists of only two folders at installation time GameData and Server. It is sufficient to only upload these two. All other files you will encounter are generated by the server software.

Game files:

The normal game comes with an internal server, which is the same software as the dedicated software. You can simply upload the Server folder. But you must also upload GameData/MHG/ to the server.

The normal game GameData/MHG/ folder contains client assets, these are not required on the server. If you want to reduce memory usage, only upload components/, worldtypes/ and manifest.jecs from the GameData/MHG/ folder.

Server Structure

The server has a specific file system structure. It is good to know it, to verify that everything is in order and what you need to edit to configure it.

Minimal file requirements:

The dedicated server itself is only shipped with a few files. The internal server has the same minimal files, but it is shipped along many other client files.

ServerFolder/
	GameData/
		MHG/[...]
	Server/
		Server.exe (On Windows)
		Server (On Linux / Mac)
		[...] (Several DLLs and other files/folders)

The other files and folders will be generated when/while the server runs.

GameData/ contains all mods which the server might load. Each mod must contain a manifest.jecs file. GameData/MHG/ is the base mod of the game. It defines the vanilla components. You technically can start the server without it. However, that would be a weird gameplay experience. Server/ contains all files required to run the server software (except for the base mod). Server/Server.exe (Windows) or Server/Server (Linux/Mac) are the executable files, these have to be executed to start the server.

Full file structure:

A fully functional server has the following files and folders. All of these files will be generated once the server is started.

ServerFolder/
	GameData/
		MHG/
		[...]/
	Server/
		cache/
		[...]
	logs/
	licc-server/autoexec.lsf
	saves/<world-name>/
	backups/saves/<world-name>/<date-time>/ (Save backups)
	componentrestrictions.succ
	config.succ

Server/cache/ contains compiled mod DLLs (and in future more). You can delete this folder anytime, it will be regenerated. Sometimes deleting it helps fixing weird issues. The server will automatically delete this, once it detected a version change. This folder is created in the working directory of the server. When running the integrated server, be careful not to accidentally use the clients cache/ folder. Make sure you use Server/cache (see server launch section). logs/ contains the log files which contain text that gets printed via loggers to console. licc-server/autoexec.lsf this file contains console "commands" which get executed once the server start. This is part of the LICC framework that manages commands. One good way to use this, is to switch the log-level to "trace". Write loglevel "trace" into the file to debug the server start.

saves/<world-name>/ contains all the worlds which the server can start. backups/ contains backups created by the server.

config.jecs this is the main server configuration file. componentrestrictions.succ this file contains settings on which restrictions apply on some components.

Make sure to check the configuration section of this guide for information on how to use some of these files.

Launching the server

Once you have the server in-place and all required files, the first thing you should do is start and stop it.

Starting the server:

For each of these you want to first navigate to the server directory. This is the folder that contains Server/ and GameData/ folders. From here on, you do not want to change that directory again.

Once you started (and stopped) the server. All necessary configuration files and a new save World will be generated.

Linux / Mac:

Simply open a terminal at the server installation location, or change the directory to this location. Then run the server with ./Server/Server.

Windows:

Open a terminal. You got several to choose from. I do very much recommend to install the "new" Windows Terminal Store GitHub, which provides modern terminal front-end compared to the old CMD or Powershell frontends. Ofc change the directory to the server folder.

In CMD for example you then run Server\Server.exe. You can quickly open CMD for a folder in Explorer by "opening" %cmd% in the path bar.

TODO: More suggestions and alternatives for Windows - I do not use Windows (unless I have to). Could also just install WSL and then follow the Linux instructions.

Steam:

You can also press Launch for the Logic World Dedicated Server in Steam for this. But I recommend you get comfortable with a terminal instead.

Executable launch arguments:

For the most part, the server is configured via the config.jecs file. Hovever, the internal server is entirely configured via launch arguments. And some things, which might relevant to you as hoster can only be configured via launch arguments.

To get a list of launch arguments, start the server with the argument --help.

Long Short Type Description
Console:
no-color n flag Do not print ANSI colors in program output output (then you get the default text color).
ansi-rgb flag Make color codes in program output use RGB ANSI code. They take a couple more bytes. You then see the same colors which Logic World uses in the client terminal.
Useful arguments:
working-dir w folder Specifies in which directory the server is executed. By default this is where you execute the server command.
root r folder This is the path where the server will look for worlds & config and mods. Relative paths are relative to the working directory. By default the root directory is the parent directory of where the server executable is located.
forceLoad f flag Will cause the save to be backed up and loaded "by force". This can be used to load saves with different set of mods or saves with newer version than the server. This won't remove unsupported modded components.
Internal server arguments:
save s string Name of the save to be loaded. Defaults to save name in config.jecs.
port p int Port the server binds on. Defaults to port in config.jecs.
offline o flag Turns off verified mode, if enabled in config.jecs. This will edit the config file on disk if verified mode was enabled. This argument is automatically set with --integrated argument. It does suppress warning about the server not being in verified mode.
integrated flag Hidden An umbrella argument, which will tell the server it is started for SinglePlayer usage. When set, the server shuts down as soon as all player leave. It also sets the launch argument --offline (if not done so already). Turns off password login, if it was enabled in config.jecs. This will edit the config file on disk, if password was enabled.
parent-pid int Hidden Allows the server to monitor the parent process (client) and shutdown the server if the client crashes.
token string Hidden Unused. Was used for the punch manager before the early access release. The usage of this argument was discontinued to prevent the client token ending up in the server startup argument (which often can be exposed).
Tools:
version v flag Print the version and quit.
benchmark string Perform a benchmark with provided name and quit. TODO: How does this work? I never used it.
graph flag Hidden Print a dependency framework graph to file services.dot and quit.

In general you do not need most of these arguments. They are tailored to start the internal server for single-player. But there are some quite useful arguments not covered by config.jecs.

If you have a Linux/Mac or modern Windows terminal, you might want to supply the --ansi-rgb argument. This will use RGB ANSI color code to print the actual colors intended to be printed by LogicWorld. Without it it falls back to the standard terminal colors.

A note on the working directory: the only files which the server creates in the working directory are the cache/ folder and the services.dot debug file. If you start the internal server in your game installation folder there will be a collision between the games cache/ folder and the one created by the server. This can lead to mod-loading conflict. Start the internal server inside of the Server/ folder or provide the --working-dir Server/ argument.

If you host multiple servers and want to use a single server executable & DLL folder for all of them (this makes updating easier and saves disk space), then you should provide the --root-dir . (provided your working directory is where you saves / config / GameData files/folders are).

Saves:

Just like the game the server does have a saves/ folder which contains all the saves.

By default the server will try to load the save World, unless specified differently in config.jecs (or by launch argument).

Save structure:

SaveName/ # The name of the save is actually the folder name.
	players/
		<username>.jecs # Each player has a config file containing PlayerData (position, rotation, scale, is flying) and the hotbar content.
	ExtraData/ # ExtraData is a system for sharing configurations between game and server.
		MHG.DisplayConfigurations/ # DisplayConfigurations are stored here, created on demand.
		MHG.FlagListOrder.jecs # The order of flags, created on demand.
		MHG.SimulationSpeed.jecs # The current simulation speed.
		MHG.SimulationPaused.jecs # Whether the simulation is currently paused.
		MHG.WorldTypeData.jecs # Contains details for the current world-type (only for <code>MHG.Gridlands</code>).
		<key>.jecs # Any other ExtraData added by mods will be stored here as well.
	backupmetadata.jecs # Contains values required for the backup system (like the world age). Don't mess with this.
	meta.jecs # Contains client metadata, like the title - the server entirely ignores this.
	data.logicworld # This is the actual world file.
	worldinfo.jecs # Saves the world type and the spawn-position.

If you upload a save to the Hub, then the player folder is not uploaded (#privacy).

The meta.jecs file is not generated by the server. It contains the save "title", which the game will show in the sandbox menu.

The data.logicworld format is documented on GitHub Gist, as first instance of truth (this should be an exact mirror of the developers internal documentation).

The .jecs format is documented on GitHub. Previously this file extension was called .succ.

World types:

The world type is saved in the worldinfo.jecs file. The server by default sets the world type to MHG.Grasslands for new saves.

The two primary world types are MHG.Grasslands and MHG.Gridlands. The game supports a couple more hidden world types and mods could potentially add some as well.

The easiest way to switch to a custom configured Gridlands floor type is to create it with the game and copy the save to the server. But you can simply exchange the world type in the worldinfo.jecs file.

The MHG.Gridlands world type allows to change the floor grid. This is stored in ExtraData/MHG.WorldTypeData.jecs (unfortunally). You can change the color and grid manually by editing that file. The default configuration looks like this:

DataType: LogicWorld.SharedCode.Data.GridlandsWorldData
Data:
    ColorA: 222222
    ColorB: 005A6C
    BigCellSizeX: 64
    BigCellSizeZ: 64

Server configuration:

componentrestrictions.jecs:

This file contains component restrictions, currently these are only the minimum & maximum amount of variable input & output pegs.

Base-Game components with variable peg count are: MHG.AndGate & MHG.StandingDisplay & MHG.PanelDisplay

A very common modification to this file is allowing AND gates to have up to 8 inputs.

config.jecs

Most of the server configuration is perform in it's config.jecs file. Setting up a server normally always requires to mess with this file.

The config.jecs file does already contain proper descriptions for each entry. In case that you messed something up, you can always delete the config file - the server then generates a new one.

If new settings are added to the save, you might have to regenerate or save the config file. You can trigger a save by running the motd <motd text> command - hacky but works. If the server stops using a setting, it will remain within the file.

Key Type Default Description
ServerTPS double 60 How many server ticks per second are processed. Each server tick network packets & simulation will be processed and updates are sent to the clients.
Simulation:
DefaultSimulationTPS double 30 The default simulation ticks per second. Clients reset the simulation to this speed.
MaximumSimulationTPS double 100000 The maximum amount of simulation TPS. Higher values are clamped to this.
MaxAllowedSimulationTickDebtSeconds double 1 The simulation tries to catch up ticks it could not perform in the last server tick (called debt time). When it accumulated too much simulation tick time it cannot catch up to, it skips these ticks - the simulation debt time is reset.
PauseSimulationWhenServerEmpty bool true Allows to save computational resources when no player is connected.
Saving:
SaveOnClose bool true Save when the server shuts down.
SaveWhenServerEmpties bool true Save when the server becomes empty.
DoAutosave bool true Save at a fixed interval AutosaveIntervalSeconds.
AutosaveIntervalSeconds float 60 The interval for autosaves.
BackupsPath string "backups" UNUSED This is supposed to define what the backup folder is named. This seems to be hardcoded in code though.
BackupOnSave bool false Backup after a save has been created?
DoAutoBackup bool true Backup at a regular interval? This uses the first interval from the 'BackupSchedule'.
BackupSchedule (count, secondsPerBackup)[] 4*15m, 2*12h, 2*1d, 2*1w The backup schedule defines how many backups should exist for a certain time period. This is updated whenever backups are created. When a new backup gets created the code checks for more than one backup in each backup schedule section and deletes the older ones. To define the schedule just provide the backup sections. The default schedule has keeps backup for a total of 2 weeks and 3 days and 1 hour. Multiple time units are supported: s(econds), m(inutes), h(ours), d(ays), w(eeks), M(onths) and y(ears).
DoAutosaveAndBackupsWhileServerIsEmpty bool false Disable the saving/backup mechanism while the server is empty. In many cases there is no change to the world with an empty server. Do not wasted limited backup time during that time.
Network stuff:
EnableDiscovery bool true Whether to reply to the clients discovery requests. If disabled, the server is displayed as offline in the games MP menu.
MOTD string #random A random text shown in the games MP menu. Might as well contain some sort of description for the server.
AnnounceOnLocalNetwork bool true When enabled, the server broadcasts it's presence to the local network. This is used to have other computers in the network discover SP sessions. For public servers this can safely be turned off.
AnnounceOnLocalNetworkIntervalSeconds float 1 How often per second the server announcement should be sent.
---
DefaultSave string "World" The save (/ folder) name to be loaded from the saves/ folder.
DefaultPort int 43531 The port, which the server will listens for connections on. If you use the default port, clients do not have to specify a port when connecting.
More network stuff:
InternetProtocolOverride Enum: Default, IPv4, IPv6, IPv6_DualStack Default Only use this when the network setup is acting up. If you have legitimate reason to use this, report to the games developers - cause then something is broken. Besides that it can force a higher IP protocol if the game messes up Default detection. Or disable a specific IP protocol, if other issues occur.
Login restrictions:
UsePassword bool false Whether clients have to provide a password when connecting.
Password string "this is a very secure password" The password.
VerifiedMode bool false When enabled, connecting clients must be logged in into Logic Worlds online services (have an account). The main advantage of this is, that players cannot pretend to be someone else. They still can perform ban evasion by creating new accounts. But impersonation is no issue anymore.
OnlineEndpoint string "https://logic.world" Used for development setups while testing the online services. When it is changed, the server downloads a certificate for verified logins at startup from the provided endpoint.
---
MaxPlayers int 20 Maximum amount of players which can be "connecting" & connected. This (sadly) does not refer to only fully connected players.
Access control:
Admin_IDs string[] - List of admins. Admins are permitted to run commands on the server.
UseWhitelist bool false Enable join whitelist. If you use a whitelist, you should enable 'Verified mode', else anyone could just change their name to a whitelisted player.
Whitelisted_IDs string[] - List of playernames to be whitelisted. Currently you have to restart the server to apply a new list.
Banned_IDs string[] - List of playernames to be banned. Should be used with 'Verified mode'. TODO: Can theoretically be performed at runtime => Test (if the command works).
Banned_IPs ip[] - IPs to be banned. TODO: Can theoretically be performed at runtime => Test (if the command works).
---
ChatMessageLengthLimit int 2100 Maximum chat message length. 100 more characters than the client limit, this ensures that usernames fit into the message.
Even more network stuff:
PlayerTimeOutSeconds int 60 Time of not being able to contact a client before they are forcibly disconnected.
Hacky development stuff:
AllowConnectionsFromADifferentGameVersion bool false Useful for testing. But theoretically clients can fake their version anyway. It really does not matter. Enabling this allows funny errors when an incompatible client joins. But it makes the live of developers joining your server with a development version easier.
Magic numbers for Partial World management (subassembly placement & undo):
TrimStalePartialWorldsIntervalSeconds float 900 Interval at which the server deletes partial worlds, if they are older than MaxAgeOfStalePartialWorldsSeconds.
MaxAgeOfStalePartialWorldsSeconds float 180 The maximum age which a partial world may have.
CullStalePartialWorldActionsIntervalSeconds float 30 Interval at which the server cancels unsuccessful partial world placement requests.
MaxAgeOfPartialWorldActionSeconds float 10 The maximum age which partial world placement requests may be until they are considered "not successful" and fail.

Ecconia recommendations:

  • Saving every minute seems a bit over the top. For me every 5 mins or even less often is sufficient - depending on how often the game crashes for you. But recovering 5 minutes of work is often fine.
  • If you are hosting a 24/7 online multiplayer server, you might want to change the backup schedule to something more aggressive. Like 4*15m, 11*1h, 2*6h, 2*12h, 5*1d, 4*1w you could even create a backup every 5 minutes when saving (instead of at a backup interval). Keeping saving/backups off when no player is online. As you only have to maintain one world, you can dedicate more space for backups allowing you go go back much further in time. Adjust it depending on the activeness on your server, but a single player afk'ing on your server for 24 hours does make a difference.

Difference between Subassemblies and Partial worlds. Partial Worlds are pretty much like world files, these define one or more root-components with their child components wires and circuit states. Subassemblies contain a Partial World and additionally some metadata and placement positions for the root components in the Partial World. Subassemblies are never sent to the server, only Partial Worlds with root placements. The client is using subassembly data for the building system. Partial Worlds are created when deleting a component or when loading a Subassembly. The server will store Partial Worlds until a certain cleanup interval (controlled by TrimStalePartialWorldsIntervalSeconds and MaxAgeOfStalePartialWorldsSeconds) deletes them (this can cause the funny GUID_something was not found exception - epic system - no reference counting). When a client requests a certain Partial World to be placed in the world, the server will try to fetch that Partial World from this client (or somewhere else). The CullStalePartialWorldActionsIntervalSeconds and MaxAgeOfPartialWorldActionSeconds config values determine, when these operations should result in a timeout causing the build-request to fail.

Interacting with server console:

The server itself can be configured with it's console at runtime.

To get a list of all commands run the help command. If you want to supply text arguments, make sure to wrap them in quotations command "argument with spaces".

Run server commands from the client:

To run a command from the games console, you will have to run the server "command argument" command. On multiplayer servers you must be administrator to do this (configured in config.jecs). In SinglePlayer it works without administrator, as the game sends the command into the input-stream of the server program.

Useful server commands:

To stop the server simply run exit (or use Control+C).

To save the world run save.

TODO: Figure out, if there are more (non-broken & non-debug) commands worth running.

Networking:

Whether you host a server at home or on a dedicated server machine. There are a few things to know.

In general, supply an IP or Domain in your games multiplayer menu to connect to a server. If the server is not using the default port 43531, you also have to supply that. For example localhost:43531 (simply localhost is enough).

Networking terminology:

IPs & Domains:

For each computer there is one IP. An IP is a set of bytes represented by decimal or hexadecimal numbers. IPv4 (the old one) has the following format 123.123.123.123 (each of the 4 numbers ranges from 0 to 255). IPv6 (the newer one) has the following format 2001:0db8:85a3:0000:0000:8a2e:0370:7334, it's hex. You can leave out sections. Let's not talk about the rules of these. Just be glade if you never have to type an IPv6.

On that matter. Not many can remember numbers well nor type them. Thus we have Domains. These are names which get resolved by a "DNS" system into an IP. You can remember for example https://logic.world and your browser resolves this to 168.119.155.107, which it then connects to. LogicWorld does the same thing, it resovles domains and connects to the IP. One special domain, which you might have seen before is localhost. It connects to your current device. If you want to join the server which runs where your game is. This resolves to 127.0.0.1 (IPv4) and ::1 (IPv6).

If you have a server, it has an IP which is directly reachable from the internet. If you host your server on a computer at your home, it is likely inside of a local network. Then chances are high your Router has a different IP which might be reachable from the internet. Your computer won't be reachable by others. In many cases your router might not even be reachable from the internet. If your router is reachable from the internet, you can make use of a mechanism called Port Forwarding, which allows people to connect to your router, which then forwards all traffic to your computer. In many cases, and this depends on your ISP and internet contract, your router is not reachable from the internet directly. In these cases you must use tunneling to have others connect to you. There exist proxies which are servers in the internet routing the traffic to your machine (traffic is NOT encrypted). And there are virtual private networks (VPN), which allow to connect two local networks with each other (traffic is encrypted). Or just two computers.

Ports:

If everything just connected to a computer, it would be very difficult to know what that incoming traffic is and which program should process it. Thus each computer has ports. These are basically "addresses" on the computer which programs can reserve for themself. For example port 80 is specifically for web requests and 443 for encrypted web request (https), usually a web server program handles these two ports. You can assume traffic on these ports to be for web requests.

Logic World itself also has a default port which is 43531. This does not mean, that traffic has to go to that port. It is just to allow the use of one of the 65536 ports your machine has, to have it be processed by the right application. In this case a Logic World server. But you can use "any" port, as long as you tell the Logic World server which port to listen to.

Protocol: TCP vs UDP

Logic World uses UDP only!

TCP and UDP are two lower level networking protocols which transfer binary data to a different computer, they aide the internet routing process.

TCP has built-in mechanisms to ensure network packets arrive at your applications and even in the correct order. It ensures that you will know when a connection was broken off. UDP does not do that, it just sends the data. Whether it arrives or in the correct order is not guaranteed.

Allowing others to connect to your local computer:

Portforwarding:

If you host the server at home, people cannot simply connect to you. You must perform something called Portforwarding. Your home IP will be exposed to the other player. But this is a directy connection between them and your server, there is no additional delay. With tunnels (proxies / VPNs) you can get a slight overhead.

Preconditions:

  • Your router must have a public IP reachable from the internet. The IP must be uniquely used by your router and not shared with other routers.
  • You must have access into the admin configuration of your router.
  • Pray that your ISP did not come up with other trickery to be annoying to you.

Disclaimer: Router interfaces are different for each type of router. Consult the internet if you are having issues with your router type.

What you have to do:

  • Log into the admin panel of your router.
  • Figure out the IP of your computer, this can be seen in the router - or via several tools on your OS. On windows you can open CMD and use ipconfig. On Mac it's ifconfig. And on Linux there are multiple commands ip addr show is one of them.
  • Navigate to the port-forwarding settings in your router. Add a new rule
  • In general: Get IP of router. Enter IP in browser. Login into router. Find portforward section. Enter new rule.
    • Set the device to be your computer (IP)
    • Set the rule protocol to UDP
    • Set the device port to be 43531 (to 43531, if it wants a range).
    • Set the external port to 43531 (the port on your public router interface).
  • Now it should work, unless you have an issue with Firewalls.

TODO: List alternatives? Like there is a way for computers to tell the router to open a port.

Proxies:

Proxies tunnel traffic through a public server. Players can connect to that server instead of your local network. That server then sends the data to your computer. This works because your computer initialized a connection to the proxy server with a dedicated program.

The traffic is generally not additionally encrypted, it would not be encrypted normally either.

List of proxies:

  • https://playit.gg: Free or (30€ annually). "Functions" out of the box. One issue: UDP packets can only be about 1433 bytes in size. Logic World does send bigger packets when a client downloads the world from the server - these won't ever arrive. The current workaround is the MtuControl mod by Ecconia, which lowest the size of packets which Logic World sends over the network. The server must install it. Clients might have to (if they send big subassemblies).

TODO: Find other proxies.

Virtual Private Networks:

These ensure an encrypted connection between two computers or networks.

List of VPNs:

  • Hamachi (Note: Untested. TODO: Someone test this.)
  • ZeroTier (Note: Untested. TODO: Someone test this.)

TODO: Test the VPNs and find more.

Firewall:

A firewall prevents unwanted traffic from entering your computer. In somecases it even prevents wanted traffic from entering your computer. Configuring it is key.

Windows:

Goodspeed, if you host the server on a dedicated Windows server.

If you however host it on your normal Windows computer, it's firewall might cause a problem. You can TEMPORARILY disable the firewall to see if it is the problem. PLEASE enable it again right after testing!

TODO: Have someone who knows stuff explain what could be done with the Windows firewall. And figure out if this is even required.

Linux (servers):

IPTables:

The common firewall on Linux is iptables. It is quite a bother to use though.

TODO: Explain rule persistence. As I believe it won't apply all rules by default.

Docker:

If you happen to run the server using Docker, it will modify the iptables firewall for you (probably).

UFW:

A neater frontend for it is ufw, which has a simple interface and controls iptables for you.

You might have to install ufw. You might have to enable it (as it should not be active by default). If you just started using it and are doing so on a dedicated server, make sure to whitelist your SSH port (usually 22: ufw allow 22). If you run web servers also allow these ufw allow 443/tcp && ufw allow 80/tcp.

Once you added all the rules (including LW: ufw allow 43531/udp), you can start/apply UFW by running ufw enable.

All firewall commands probably have to be executed as sudo user.

Additional setup steps for dedicated Linux servers:

It is likely, that you host your dedicated logic world server on a Linux server machine. In this case, there are a few things you can do to improve your security, or your comfortability.

Running server in background:

If you run a program in a server terminal and disconnect from it, the program will be stopped. This means to run the LW server, you will have to wrap it in something that ensures it won't stop.

Docker will launch the program in background. TODO: Tutorial for attaching to console. Somewhere.

If you start the server via a service, it also runs in background. But you won't get access to the console of the server, or specifically you can't "input" commands into the server.

There are essentially two pieces of software, which allow you to create a background terminal which runs your server that won't shutdown. These are tmux and screen.

Both essentially do the same. They different keybindings and launch arguments. The biggest difference between both is that tmux uses a terminal buffer (it enters an inner terminal), while screen is not doing this. And tmux allows multiple users to view the terminal. screen will "corrupt" your current terminal with the Logic World server output, but you can easily copy large sections from it. With tmux using a buffered terminal, you can easily enter/exit it while not having your primary terminal being messed up, but selecting things with your mouse requires you to press Shift and scrolling while terminal selecting won't work.

It is a matter of personal preference (or the necessity of sharing a terminal). Both are a very valid choice.

Both function the same at their core. There is a background server hosting the virtual terminals in background. You have the client commands tmux and screen which connect to the background server.

Tmux:

Advantages:

  • Tmux allows multiple tmux-commands to connect to the same terminal and view it simultaniously.
  • Tmux uses a terminal-buffer, opening it won't dump the Logic World server output in your current terminal. (This makes copying large chunks more difficult. Decrease font size and hold Shift to copy from your terminal).
  • Tmux has built-in tiling.

Cheat Sheet: https://tmuxcheatsheet.com/

List terminals: tmux list-sessions Create & Connect terminal: tmux new-session -A -s <terminal-name> Detach from inside: Control + b, d (this is two separated keybinding presses)

You could write a service or cronjob which starts a tmux terminal with a server like so: tmux new-session -d -c ~/your/server/folder -s <terminal-name> ./Server/Server --your-server-arguments. Or start a script with this ./start_my_server.sh.

Screen:

Cheat sheet: https://gist.github.com/jctosta/af918e1618682638aa82

List terminals: screen -ls Create terminal: screen -S <name> Connect to terminal: screen -r <name> Detach from inside: Control + a, d (this is two separated keybinding presses)

You could write a service or cronjob which starts a tmux terminal with a server like so: cd ~/your/server/folder && screen -d -m -S <terminal-name> ./Server/Server --your-server-arguments. Or start a script with this ./start_my_server.sh.

Dedicated user:

It is a safety precaution to create a new user for your internet services, like the Logic World server. If configured properly, it increases difficulty for an attacker to mess up your system. Under no circumstances you should run the Logic World server as admin/root/sudo user.

In general there are two ways to go about this. You can create a user with home directory and store the server there. Or a user without a home directory. Then you have to store the server somewhere else. As for the Logic World server, you want a normal user which you can login to. This allows you to open the server console.

Create user with new home directory: adduser <username> Create user without home directory: adduser <username> --no-create-home You might have to use useradd for when adduser does not exist on your system. In these two examples they are interchangeable.

Once you created the user, you can login to it using su <username> (optionally with sudo). This is useful to either attach to the running server console or to edit crontab to setup autostart of the Logic World server.

If you downloaded the server with a different user. You can change the user and group with chown -R <username>:<username> . with . being the folder/files you want to change the user of.

TODO: Explain file system permissions, to prevent a potential attacker from accessing other users. I believe the general idea is to remove the x permission from other home folders or other folders which an attacker should not get read-access to.

Autostart:

If you wish to have the server start along with your server (in case that it gets shut down by something). There are multiple options.

Docker:

If you use Docker to host the server, it probably already starts along with your server.

Cronjob:

Cronjob is a tool which allows to run a command at a frequent interval or after reboot for your current user.

On first start with cronjob -e, it will ask which text editor to use. If you have no clue, use Nano: Control + O for saving; Control + X for closing.

In the cronjob file, you simply add @reboot /bin/bash <startup_command>. Where <startup_command> is how you start your server.

By default Cronjobs are executed in the users home directory. It is better if you provide the full path or use ~/ to navigate to the script relative to your home directory. You can/should also add some code to set the correct working directory in your startup script. Use a startup script instead of starting the server directly - you could do that though.

TODO: Details about startup command and bash?

Service:

TODO: Provide an example service file. Explain where to put it. And basic commands on how to enable it. Advantage of service is, that it can run as a user easily and you in general do not have to care about it.

Keeping server folders structured (symlinks)

If you host multiple servers one the same machine or you just like to keep things organized, you can reuse the server binaries and mods without copying them. You can do this easily by creating symlinks.

Symlinks pointing to a folder behave as if the actual folder was at that location instead of the symlink. But if you delete the symlink, only the link is gone and not the folder. Programs are able to check if a folder is a symlink (not relevant though). Symlinks also exist on Windows, but you need either admin or enable developer mode.

Create symlinks with:

  • ln -s <target_folder>: Creates a link to a folder, the folder will have the same name as the one <target_folder> points to.
  • ln -s <target_folder> <destination_name>: Creates a link with name <destination_name> pointing to a folder <target_folder>.

You can provide absolute paths for symlinks or relative paths, these are relative to the symlink location.

The advantage of sharing server binaries between multiple servers is that you can update all of them at once without having to duplicate files. But obviously if you want different version or update one server later than another, this is not the best solution.

An example link for server files could look like this: ln -s "${HOME}/Steam/steamapps/common/Logic World Dedicated Server/Server" ~/my_server_folder/Server This would create an absolute link to the server binaries (downloaded via SteamCMD) in ~/my_server_folder/ next to your other game files. ln -s "${HOME}/Steam/steamapps/common/Logic World Dedicated Server/GameData/MHG" ~/my_server_folder/GameData/MHG cd ~/my_server_folder/GameData && ln -s "${HOME}/Steam/steamapps/common/Logic World Dedicated Server/GameData/MHG" This will link the MHG mod into your servers GameData folder. You can also just link the whole GameData folder, if you do not wish to install other mods. If you have a GameData folder with mods shared between multiple servers, you can also link that. This will make individual server configurations a bit more tricky though.

There are multiple ways to construct symbolic links. The most simple and reliable way is to cd to the folder where you want the symbolic link to be. Then you create it by supplying the full path, including home folder ln -s /home/your_name/something/folder_to_link and if you wish to rename the link name just supply a new name as additional argument. Pay attention to spaces in paths, these must be escaped with \, or you wrap the whole thing in quotation (like the examples above). You can use ~ to link to your home directory (will be resolved). Inside of quotations you must use "${HOME}/" though.

Update mods

If you use mods, most of them are distributed via GitHub. And then the mods are located in awkward positions inside each Git repository.

It makes sense to simply use Git to clone the repository (like so: cd ~/mods/ && git clone https://github.com/Ecconia/Ecconia-LogicWorld-Mods.git ecconia_mods) and then symlinking to the mod which you like to use cd ~/my_server_folder/GameData && ln -s ~/mods/ecconia_mods/MtuControl/MtuControl && ln -s ~/mods/ecconia_mods/EcconiaLogicWorldAPI/EcconiaLogicWorldAPI. Using MtuControl as example here, as you might need it for the PlayIt proxy. You can put the cloned mods to any folder you desire.

The big advantage of this is, that if you want to update the mod. You simply have to run git pull inside of the cloned mod repository. No funny file syncing no specific folder selection. Just one command inside the right folder. And the mod should update for all servers that use it.

Things to maybe enhance this guide with?

  • Running server with Proton? I am not sure why this would be required?
  • Mention the plentiful issues with networking that LW has?