mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 15:29:32 +07:00
Improved ports and updated documentation of UncivServer (#7747)
* Improved ports on UncivServer
See 6315a16d98 (r83109934)
for details
* Update UncivServer.kt
* Update Multiplayer.md
* Update Multiplayer.md
This commit is contained in:

committed by
GitHub

parent
81d2320824
commit
7c1b298a24
@ -31,22 +31,24 @@ From the directory where the `UncivServer.jar` file is located, create a folder
|
|||||||
|
|
||||||
Your server has now started!
|
Your server has now started!
|
||||||
|
|
||||||
To check if everything works, you can start Unciv on the same computer, go to "Options > Multiplayer", then enter `http://localhost` as the "Server address" and click "Check connection to server". You should now get a "Success!" result, which means it's working!
|
To check if everything works, you can start Unciv on the same computer, go to "Options > Multiplayer", then enter `http://localhost:8080` as the "Server address" and click "Check connection to server". You should now get a "Success!" result, which means it's working!
|
||||||
|
|
||||||
|
To connect with other devices outside your local network or to make your server accessible from the web, you'll need a real IP. If your ISP provides you with a real IP already, forward your server's port (default 8080) with your router, and your server would be exposed to the internet! In this case you can also use `http://<your-real-ip-adress>:<your-forwarded-port>`. For example, if you have the IP `203.0.113.1` and forwarded the port of your server to port `1234`, your server can be accessed from the internet from the url `http://203.0.113.1:1234`. Additionally, since the `HTTP` protocol defaults to port `80`, if you have forwarded your server to port `80`, you wouldn’t need to specify any port. For example, if you forward the server's port to port `80` of your real IP, your server would be exposed to `http://<your-real-ip>` or in this case `http://203.0.113.1`.
|
||||||
|
|
||||||
To connect with other devices, you'll need the port (default 80) the server is running on to be visible externally (port forwarding) and know your external IP-address.
|
|
||||||
|
|
||||||
On the other device, enter the URL to your server (`http://<your IP address>:<your chosen port>`), click 'check connection' from the new device, and if you get the same "Success!" result - congratulations, you're connected to the same server and can start a multiplayer game!
|
On the other device, enter the URL to your server (`http://<your IP address>:<your chosen port>`), click 'check connection' from the new device, and if you get the same "Success!" result - congratulations, you're connected to the same server and can start a multiplayer game!
|
||||||
|
|
||||||
Please note:
|
Please note:
|
||||||
* Devices *not* connected to the same server will *not* be able to participate in multiplayer games together
|
* Devices *not* connected to the same server will *not* be able to participate in multiplayer games together
|
||||||
* In many places, your external IP address changes periodically. If that is the case, you either have to update the IP all the time or use something like a dynamic DNS service.
|
* In many places, your external IP address changes periodically. If that is the case, you either have to update the IP all the time or use something like a dynamic DNS service.
|
||||||
|
* To start your server from some special ports like `80` or `443`, you would need admin privileges. If you want to use those ports, run PowerShell as admin. However, if you use port forwarding from a router, you really don't need to do this. You can start the server from port `8080` and forward it to `80`.
|
||||||
|
|
||||||
### How To for people with hosting experience
|
### How To for people with hosting experience
|
||||||
|
|
||||||
* Have a Java JDK installed
|
* Have a Java JDK installed
|
||||||
* Download the [latest UncivServer.jar](https://github.com/yairm210/Unciv/releases/latest/download/UncivServer.jar) (can also use that link to automatically update probably)
|
* Download the [latest UncivServer.jar](https://github.com/yairm210/Unciv/releases/latest/download/UncivServer.jar) (can also use that link to automatically update probably)
|
||||||
* See options with `java -jar UncivServer.jar --help`
|
* See options with `java -jar UncivServer.jar --help`
|
||||||
* The server will run on a specified port (`-p`, default `80`), writing files in a folder (`-f`, default `./MultiplayerFiles/`), so it needs appropriate permissions.
|
* The server will run on a specified port (`-p`, default `8080`), writing files in a folder (`-f`, default `./MultiplayerFiles/`), so it needs appropriate permissions.
|
||||||
* Run it: `java -jar UncivServer.jar -p 8080 -f /some/folder/`
|
* Run it: `java -jar UncivServer.jar -p 8080 -f /some/folder/`
|
||||||
* It basically just does simple file storage over HTTP.
|
* It basically just does simple file storage over HTTP.
|
||||||
* Files are not cleaned automatically if a game ends or is deleted on the client-side
|
* Files are not cleaned automatically if a game ends or is deleted on the client-side
|
||||||
@ -60,6 +62,6 @@ Please note:
|
|||||||
|
|
||||||
## Third-party (unofficial) publicly hosted Unciv servers
|
## Third-party (unofficial) publicly hosted Unciv servers
|
||||||
|
|
||||||
These servers are run by the community and **not** official servers. These servers may become (temporarily or permanently) unavailable and lose your saves. They might also collect data like your IP, how often you play, or other data. Use these only if you accept these risks and trust the server owners.
|
These servers are run by the community and **not** official servers. These servers may become (temporarily or permanently) unavailable and lose your game saves. They might also collect data like your IP, how often you play, or other data. Use these only if you accept these risks and trust the server owners.
|
||||||
|
|
||||||
* [`https://uncivserver.xyz/`](https://uncivserver.xyz/) - Run by PikaPika#2315 on [their Discord](https://discord.gg/H9em4ws8XP) ([Source Code](https://github.com/touhidurrr/UncivServer.xyz/))
|
* [`https://uncivserver.xyz/`](https://uncivserver.xyz/) - Run by PikaPika#2315 on [their Discord](https://discord.gg/H9em4ws8XP) ([Source Code](https://github.com/touhidurrr/UncivServer.xyz/))
|
||||||
|
@ -27,7 +27,7 @@ private class UncivServerRunner : CliktCommand() {
|
|||||||
"-p", "-port",
|
"-p", "-port",
|
||||||
envvar = "UncivServerPort",
|
envvar = "UncivServerPort",
|
||||||
help = "Server port"
|
help = "Server port"
|
||||||
).int().restrictTo(1024..49151).default(80)
|
).int().restrictTo(0..65535).default(8080)
|
||||||
|
|
||||||
private val folder by option(
|
private val folder by option(
|
||||||
"-f", "-folder",
|
"-f", "-folder",
|
||||||
@ -40,7 +40,8 @@ private class UncivServerRunner : CliktCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun serverRun(serverPort: Int, fileFolderName: String) {
|
private fun serverRun(serverPort: Int, fileFolderName: String) {
|
||||||
echo("Starting UncivServer for ${File(fileFolderName).absolutePath} on port $serverPort")
|
val portStr: String = if (serverPort == 80) "" else ":$serverPort"
|
||||||
|
echo("Starting UncivServer for ${File(fileFolderName).absolutePath} on http://localhost$portStr")
|
||||||
embeddedServer(Netty, port = serverPort) {
|
embeddedServer(Netty, port = serverPort) {
|
||||||
routing {
|
routing {
|
||||||
get("/isalive") {
|
get("/isalive") {
|
||||||
|
Reference in New Issue
Block a user