Туннель: проброс игрового порта наружу через bore
This commit is contained in:
@@ -62,6 +62,17 @@ public final class Server {
|
||||
private volatile net.rustnotmc.server.player.PlayerData playerData =
|
||||
new net.rustnotmc.server.player.PlayerData(null);
|
||||
private volatile net.rustnotmc.server.world.LodGenerator lod;
|
||||
|
||||
/**
|
||||
* The address the server listens on.
|
||||
*
|
||||
* By default the server listens on every address, so that it can be
|
||||
* reached from the network. When the game is reached through a tunnel
|
||||
* (bore, chisel), the tunnel connects to the loopback, and the port
|
||||
* should not hang open on the local network: then the address is
|
||||
* "127.0.0.1".
|
||||
*/
|
||||
private volatile String bindAddress = "0.0.0.0";
|
||||
private volatile HitboxRegistry hitboxes = new HitboxRegistry(null);
|
||||
|
||||
private volatile ServerSocket listener;
|
||||
@@ -255,6 +266,15 @@ public final class Server {
|
||||
}
|
||||
}
|
||||
|
||||
/** Where the server listens: "0.0.0.0" for the whole network. */
|
||||
public String bindAddress() {
|
||||
return this.bindAddress;
|
||||
}
|
||||
|
||||
public void bindAddress(String address) {
|
||||
this.bindAddress = address;
|
||||
}
|
||||
|
||||
/** The far view of the world. */
|
||||
public net.rustnotmc.server.world.LodGenerator lod() {
|
||||
return this.lod;
|
||||
@@ -392,7 +412,7 @@ public final class Server {
|
||||
public void start() throws IOException {
|
||||
this.listener = new ServerSocket();
|
||||
this.listener.setReuseAddress(true);
|
||||
this.listener.bind(new InetSocketAddress("0.0.0.0", this.port));
|
||||
this.listener.bind(new InetSocketAddress(this.bindAddress, this.port));
|
||||
this.running = true;
|
||||
|
||||
this.acceptThread = new Thread(this::acceptLoop, "rsx-accept");
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.rustnotmc.server.world.World;
|
||||
*
|
||||
* run-server.ps1 [--port N] [--accounts path] [--name text] [--motd text]
|
||||
* [--world path] [--seed N] [--token-key text] [--audience name]
|
||||
* [--admins path] [--gamemode survival|creative]
|
||||
* [--admins path] [--gamemode survival|creative] [--bind address]
|
||||
* run-server.ps1 --register Player [--password text]
|
||||
* run-server.ps1 --issue-token Player
|
||||
*
|
||||
@@ -53,6 +53,7 @@ public final class ServerMain {
|
||||
Path hitboxes = null;
|
||||
String tokenKey = null;
|
||||
String audience = "default";
|
||||
String bindAddress = "0.0.0.0";
|
||||
Path adminsFile = null;
|
||||
String issueToken = null;
|
||||
String devToken = null;
|
||||
@@ -86,7 +87,9 @@ public final class ServerMain {
|
||||
launcherApi = value;
|
||||
} else if ("--allow-local-accounts".equals(flag)) {
|
||||
allowLocalAccounts = true;
|
||||
} else if ("--gamemode".equals(flag)) {
|
||||
} else if ("--bind".equals(flag)) {
|
||||
bindAddress = value;
|
||||
} else if ("--gamemode".equals(flag)) {
|
||||
gameMode = value;
|
||||
} else if ("--name".equals(flag)) {
|
||||
name = value;
|
||||
@@ -111,6 +114,9 @@ public final class ServerMain {
|
||||
server.gameMode("creative".equalsIgnoreCase(gameMode)
|
||||
? net.rustnotmc.protocol.Packets.GAMEMODE_CREATIVE
|
||||
: net.rustnotmc.protocol.Packets.GAMEMODE_SURVIVAL);
|
||||
// where the server listens: every address by default, the loopback
|
||||
// alone when the game is reached through a tunnel
|
||||
server.bindAddress(bindAddress);
|
||||
|
||||
if (launcherApi != null) {
|
||||
// the launcher is where accounts live, so it is the way in. The
|
||||
|
||||
Reference in New Issue
Block a user