Skip to content

Commit

Permalink
Some documentation adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Nov 3, 2024
1 parent 7795110 commit 5d19189
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 66 deletions.
145 changes: 83 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,114 +9,135 @@ the server list webpage template.

First install node.js, e.g.:

# apt-get install nodejs
# # OR:
# pacman -S nodejs
```sh
apt-get install nodejs
# OR:
yum install nodejs
```

Then install doT.js and its dependencies:

$ npm install dot '[email protected]' mkdirp
```sh
npm install dot "[email protected]" mkdirp
```

And finally compile the template:

$ cd static
$ ../node_modules/dot/bin/dot-packer -s .
```sh
cd static
../node_modules/dot/bin/dot-packer -s .
```

You can now serve the webpage by copying the files in static/ to your web root, or by [starting the server list](#setting-up-the-server).
You can now serve the webpage by copying the files in `static/` to your web root, or by [starting the server list](#setting-up-the-server).


Embedding the server list in a page
-----------------------------------

<head>
...
<script>
var master = {
root: 'https://servers.luanti.org/',
limit: 10,
clients_min: 1,
no_flags: true,
no_ping: true,
no_uptime: true
};
</script>
...
</head>
<body>
...
<div id="server_list"></div>
...
<script defer src="https://servers.luanti.org/list.js"></script>
</body>
```html
<head>
...
<script>
var master = {
root: 'https://servers.luanti.org/',
limit: 10,
clients_min: 1,
no_flags: true,
no_ping: true,
no_uptime: true
};
</script>
...
</head>
<body>
...
<div id="server_list"></div>
...
<script defer src="https://servers.luanti.org/list.js"></script>
</body>
```

Setting up the server
---------------------

1. Install Python 3 and pip:

pacman -S python python-pip
# OR:
apt-get install python3 python3-pip
```sh
apt-get install python3 python3-pip
# OR:
yum install python3 python3-pip
```

2. Install required Python packages:

pip3 install -r requirements.txt

3. If using in production, install uwsgi and its python plugin:

pacman -S uwsgi uwsgi-plugin-python
# OR:
apt-get install uwsgi uwsgi-plugin-python3
```sh
apt-get install uwsgi-plugin-python3
# OR:
yum install uwsgi uwsgi-plugin-python3
```

4. Configure the server by adding options to `config.py`.
See `config-example.py` for defaults.

5. Start the server:

$ ./server.py
$ # Or for production:
$ uwsgi -s /run/serverlist.sock --plugin python -w server:app --enable-threads
$ # Then configure according to http://flask.pocoo.org/docs/deploying/uwsgi/
```sh
./server.py
# Or for production:
uwsgi -s /run/serverlist.sock --plugins python3 -w server:app -T --threads 2
# then configure according to https://flask.palletsprojects.com/en/stable/deploying/uwsgi/
```

7. (optional) Configure the proxy server, if any. You should make the server
load static files directly from the static directory. Also, `/list`
should be served from `list.json`. Example for nginx:

root /path/to/server/static;
rewrite ^/$ /index.html break;
rewrite ^/list$ /list.json break;
try_files $uri @uwsgi;
location @uwsgi {
include uwsgi_params;
uwsgi_pass unix:/run/serverlist.sock;
}
```sh
root /path/to/server/static;

rewrite ^/$ /index.html break;
rewrite ^/list$ /list.json break;

try_files $uri @uwsgi;
location @uwsgi {
include uwsgi_params;
uwsgi_pass unix:/run/serverlist.sock;
}
```

Setting up the server (Apache version)
--------------------------------------

If you wish to use Apache to host the server list, do steps 1-2, 4, above. Additionally install/enable mod_wsgi and an Apache site config like the following:
If you wish to use Apache to host the server list, do steps 1-2, 4, above.
Additionally install/enable mod_wsgi and an Apache site config like the following:

# This config assumes you have the server list at DocumentRoot.
# Visitors to the server list in this config would visit http://local.server/ and
# apache would serve up the output from server.py.
```sh
# This config assumes you have the server list at DocumentRoot.
# Visitors to the server list in this config would visit http://local.server/ and
# apache would serve up the output from server.py.

# Where are the serverlist files located?
DocumentRoot /var/games/luanti/serverlist
# Where are the serverlist files located?
DocumentRoot /var/games/luanti/serverlist

# Serve up server.py at the root of the URL.
WSGIScriptAlias / /var/games/luanti/serverlist/server.py
# Serve up server.py at the root of the URL.
WSGIScriptAlias / /var/games/luanti/serverlist/server.py

# The name of the function that we call when we invoke server.py
WSGICallableObject app
# The name of the function that we call when we invoke server.py
WSGICallableObject app

# These options are necessary to enable Daemon mode. Without this, you'll have strange behavior
# with servers dropping off your list! You can tweak threads as needed. See mod_wsgi documentation.
WSGIProcessGroup luanti-serverlist
WSGIDaemonProcess luanti-serverlist threads=2
# These options are necessary to enable Daemon mode. Without this, you'll have strange behavior
# with servers dropping off your list! You can tweak threads as needed. See mod_wsgi documentation.
WSGIProcessGroup luanti-serverlist
WSGIDaemonProcess luanti-serverlist threads=2

<Directory /var/games/luanti/serverlist>
Require all granted
</Directory>
<Directory /var/games/luanti/serverlist>
Require all granted
</Directory>
```

License
-------
Expand Down
8 changes: 4 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@
"If you meant to host a public server, adjust the setting and make sure your "
"firewall is permitting connections (e.g. port forwarding).",
ADDR_IS_INVALID: "The server_address you provided is invalid.\n"
"If you do not have a domain name or need to configure the external IP, "
"try removing the setting from your configuration.",
"If you don't have a domain name, try removing the setting from your configuration.",
ADDR_IS_INVALID_PORT: "The server_address you provided is invalid.\n"
"Note that the value must not include a port number.",
ADDR_IS_UNICODE: "The server_address you provided includes Unicode characters.\n"
"If you have a domain name please enter the punycode notation.",
"For domain names you have to use the punycode notation.",
ADDR_IS_EXAMPLE: "The server_address you provided is an example value.",
}

Expand Down Expand Up @@ -270,7 +269,8 @@ def checkRequestAddress(server):
name = server["address"].lower()

# example value from minetest.conf
if name == "game.minetest.net":
EXAMPLE_TLDS = (".example.com", ".example.net", ".example.org")
if name == "game.minetest.net" or any(name.endswith(s) for s in EXAMPLE_TLDS):
return ADDR_IS_EXAMPLE

# length limit for good measure
Expand Down

0 comments on commit 5d19189

Please sign in to comment.