-
Notifications
You must be signed in to change notification settings - Fork 18
Config
The config may look a bit confusing at first, but it is fairly simple if you understand the structure. The format is essentially JSON but the file itself is a JS file as it allows the use of comments (and more code if you wanted to do that).
If you are not looking for a complex understanding of what the config does, here are a few small steps on how to set up your dimensions server.
Rename or copy and rename the config.js.quickstart file to config.js. This file is what is used to define all of the configurable settings in dimensions.
Open the file in any text editor (preferably one that has javascript syntax highlighting).
Look for the servers: line (3rd line in the file). Here is where we will add entries for each Terraria server we intend to connect together. By default it should look like this in the file:
"use strict"
exports.ConfigSettings = {
servers: [
// ADD YOUR SERVERS HERE (steps: https://github.com/popstarfreas/Dimensions/wiki/Config#quick-start)
],There are more lines below those but ignore them and leave them as they are, we are just going to be editing the servers part.
Start by adding your first entry. Here's an example:
"use strict"
exports.ConfigSettings = {
servers: [
{
listenPort: 7777,
routingServers: [{
name: "lobby",
serverIP: "127.0.0.1",
serverPort: 6777,
hidden: false,
}]
},
],This means that when someone connects on port 7777, dimensions will connect them to the Terraria server running on port 6777. You can add more like this:
"use strict"
exports.ConfigSettings = {
servers: [
{
listenPort: 7777,
routingServers: [{
name: "lobby",
serverIP: "127.0.0.1",
serverPort: 6777,
hidden: false,
}]
},
{
listenPort: 7778,
routingServers: [{
name: "build",
serverIP: "127.0.0.1",
serverPort: 6778,
hidden: false,
}]
},
{
routingServers: [{
name: "pvp",
serverIP: "127.0.0.1",
serverPort: 6779,
hidden: false,
}]
},
],This means I now have:
- When a player connects to port 7777 they will be connected to the lobby server
- When a player connects to 7778 they will be connected to the build server
- A player cannot connect to pvp first, they need to first connect on 7777 or 7778 and then switch after
Players switch by using /{name}, for example to switch to pvp from build or lobby a player would use /pvp. They can switch back using /lobby or /build.
The config is now finished. You should be able to run dimensions (npm start) and connect/switch between servers.
In a trusted environment this step is not necessary but if you are publicly hosting your server you will want to ensure you do this step. The Terraria server ports need to be firewalled or protected in some way so that users cannot join a Terraria server directly. They need to only be able connect to the ports you specified using listenPort: in the dimensions config. This is because as a proxy, dimensions passes information about the clients IP address to ensure the Terraria server knows it, as it will initially only see the IP address of dimensions itself.
The last part of servers is the option to distribute new connections to different Terraria Servers. In the below config, if someone connects on 7777 they will first be routed to Fun Server but then the next person to connect will go to Fun Server Mirror. Each time a new connection comes through it will be routed to the Terraria Server with the least amount of players. Meaning if both have a capacity of 10, then they will both reach 10 at around the same time, when about 20 people have joined.
However, people can switch to the other by doing /funserver or /funservermirror.
servers: [
{
listenPort: 7777,
routingServers: [
{
name: "FunServer",
serverIP: "127.0.0.1",
serverPort: 6777
},
{
name: "FunServerMirror",
serverIP: "127.0.0.1",
serverPort: 6778
},
]
}
],
As dimensions allows you to use multiple individual Terraria servers as though they were one, it may also be useful for applications to get the total count of players, for example, some server lists can use the tShock REST API to do just that. Dimensions provides a basic replica of the endpoint "/v2/status" from tShock to enable applications to get this information.
This is specified by the restApi: { part of the config. It needs to be set to enabled: true, and you need to make sure the port will be accessible to whatever application intends to use it. Some of the other information may also be useful to edit for server lists that can display it. These are listed inside the response: { part, and you are free to manipulate these values to what is best suited for your server.
Adding the vanilla: true option to a routing server allows players to join a vanilla server through dimensions. However, this option prevents dimensions from sending the dimensions IP packet to the server, meaning IP bans will not be effective.
"use strict"
exports.ConfigSettings = {
servers: [
{
listenPort: 7777,
routingServers: [{
name: "lobby",
serverIP: "127.0.0.1",
serverPort: 6777,
vanilla: true,
}]
},