gslash-server
Version, currently master branch1 version
- master branchlatestOct 8, 2021
github.com/Peter0x44/gslash-server
Server-side portion of Geometry Slash
Installation
# Add this to your shard.yml
dependencies:
gslash-server:
github: Peter0x44/gslash-server
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.1.0- License
- AGPLv3
- Author
- Andrew Pirie
- Target
gslashfrom src/gslash.cr
Dependencies
Runtime Dependencies
README
gslash-server
Server-side code for Geometry Slash
NOTE: This project is not complete.
Setting up traditionally
Prerequisites
- Git (duh)
- Crystal (see here)
- SQLite3
- Reverse proxy (such as h2o or nginx) if you wish to have ratelimiting
Building
Clone the repository, install the shards and build:
git clone https://github.com/2secslater/gslash-server.git && cd gslash-server
shards build --production
- Optionally, you can append
--releaseto theshards buildcommand for optimised binaries at the expense of build time. - For cross-compiling, see here.
Usage
Simply run the binary wherever you built it.
./bin/gslash
Run ./bin/gslash --help for configuring the interface, port and SSL/TLS key/cert if needed.
- GET request
/topto receive the top 50 scores in CSV form. - POST request
/submitwithusername(string) andscore(UInt32) in your POST body.
Setting up service
OpenRC
See the services/openrc directory and install the files onto your server. Change the variables where necessary and make sure /etc/init.d/gslash is executable.
- By default, it expects that you have a user named
gslashwith its own group and home directory located at/var/lib/gslash. - It also expects the server repository to be located at
/var/lib/gslash/gslash-server. - The above can all be changed in
/etc/init.d/gslash. - Other configuration variables can be found in
/etc/conf.d/gslash.
systemd
TODO
Setting up using Docker
Setting up with Docker may be quicker and easier compared to the traditional method.
Prerequisites
- Docker (well, obviously)
- Git (only when building yourself)
You can either pull the image from the container registry using docker pull ghcr.io/2secslater/gslash-server:latest, or build the image yourself as follows:
Building with Docker on your own
Clone the repository and build the Docker image:
git clone https://github.com/2secslater/gslash-server.git && cd gslash-server
docker build -t gslash-server:latest .
Usage
Once you have pulled the image from the registry or built it yourself you can run it as such:
First, create a volume so that the database persists across container updates or resets:
docker volume create gslashdb
Then, run the container, mounting the volume in the /gslash/db folder inside the container:
docker run -d -p YOUR_PORT:3000 -v gslashdb:/gslash/db gslash-server:latest
Where YOUR_PORT is the port that you will be able to access your server from, make sure to forward it if you want public access..
Setting up reverse proxy (optional)
This step is entirely optional, and is recommended if you wish to implement ratelimiting.
NOTE: In development, the game may last 15 seconds long. Otherwise, it may be longer. In any case, ensure that the ratelimit does not exceed the game's time.
h2o
NOTE: For ratelimiting to work, your h2o install must have mruby support
hosts:
gslash.example.tld:
listen:
port: 443
ssl:
certificate-file: /etc/ssl/gslash.example.tld.cert
key-file: /etc/ssl/gslash.example.tld.key
paths:
/:
proxy.reverse.url: http://127.0.0.1:3000
/submit:
mruby.handler: |
require "dos_detector.rb"
DoSDetector.new({
:strategy => DoSDetector::CountingStrategy.new({
:period => 15,
:threshold => 1,
:ban_period => 15
})
})
proxy.reverse.url: http://127.0.0.1:3000/submit
nginx
#limit_req_zone $binary_remote_addr zone=scoreSubmit:10m rate=1r/m; # one request per minute
limit_req_zone $binary_remote_addr zone=scoreSubmit:10m rate=4r/m; # one request per 15 seconds
server {
server_name gslash.example.tld;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/gslash.example.tld.cert;
ssl_certificate_key /etc/ssl/gslash.example.tld.key;
location / {
proxy_pass http://127.0.0.1:3000;
}
location /submit {
limit_req zone=scoreSubmit;
proxy_pass http://127.0.0.1:3000/submit;
}
}
Contributing
- Fork it (https://github.com/2secslater/gslash-server/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Oct 8, 2021
- Crystal
1.1.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/Peter0x44/gslash-server
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1