Skip to content

Commit

Permalink
Add more docs. Include link in README.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmacdonald committed Jun 14, 2024
1 parent e084699 commit 4b2ab10
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 186 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ While we currently are [dogfooding](https://en.wikipedia.org/wiki/Eating_your_ow
community with around 50 servers, I would not recommend non-developers use the project yet. It's still in fairly
major development mode and large sections are still incomplete or function but very rough.

Before we tag a 1.0.0 release, we will write some proper user-facing documentation.
Before we tag a 1.0.0 release, we will write some proper user-facing documentation. You can however look at the
currently incomplete [docs](https://leighmacdonald.github.io/gbans/docs/INTRO).

## Features

Expand Down
37 changes: 37 additions & 0 deletions docs/docs/INTRO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
sidebar_position: 1
---

# Intro

gbans is a system for handling Team Fortress 2 server administration in a centralized manner. It is primarily written
in golang, typescript and sourcepawn and consists of 3 major components:

- Website / Frontend
- Backend services
- Sourcemod plugin

## High Level Features

- Several types of bans (steam, ip/cidr, group membership, friends) with whitelisting for ips/steamids.
- User reports and appeals
- Server browser
- Forums
- Wiki
- Chat logs
- SourceTV downloads
- Player Stats
- Patreon integration (OAuth)
- Discord integration (Bot + OAuth)
- Flagging and automatic action for flagged words
- Sourcemod SQL Admins compatibility

Most of these features have some level of being toggled on/off.

## Installation Guide

To get started with installation, please see the [installation guide](./install)

## Development Guide

If you want to hack on gbans, please see the [devel](./devel) section to get started.
32 changes: 32 additions & 0 deletions docs/docs/devel/DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Updating Docs

## Initialize Dependencies

If its your first time running the docs, you will need to install the dependencies first:

```shell
make docs_setup
```

## Starting a local server

To get up and running with the local development web server, run the following command:

```shell
make docs_start
```

This should open a browser tab with the current docs. If it does not open for you, the default
address is [http://localhost:3000/gbans/](http://localhost:3000/gbans/)

## Deployment

Docs for the project are currently auto deployed on every push to the master branch.

## Building

If you wish to build a production version of the docs you may use:

```shell
make docs_build
```
19 changes: 19 additions & 0 deletions docs/docs/guide/DATABASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Database Reference

## Creating a sourcemod user

It's recommended to create a secondary non-privileged user, especially when using servers remote of the
gbans instance. Below is an example of creating a read-only user that only has access to the tables, and functions, required
for operation.

```postgresql
CREATE ROLE sourcemod WITH LOGIN PASSWORD '<new-password>';
GRANT CONNECT ON DATABASE gbans TO sourcemod;
GRANT USAGE ON SCHEMA public TO sourcemod ;
GRANT SELECT ON
sm_config, sm_overrides, sm_group_overrides, sm_group_immunity, sm_groups,
sm_admins_groups, sm_adminsTO sourcemod;
GRANT SELECT, INSERT, UPDATE, DELETE ON sm_cookie_cache, sm_cookies TO sourcemod;
GRANT EXECUTE ON FUNCTION check_ban TO sourcemod;
```
130 changes: 130 additions & 0 deletions docs/docs/install/CONFIG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
sidebar_position: 2
---

# Config

## Server

Copy the example configuration `gbans_example.yml` and name it `gbans.yml`. It should be in
the same directory as the binary. Configure it as desired.

This is your core configuration file. These values cannot be changed without changing this file and restarting
the service. Most other configuration is handled via the webapp admin interface.
```yaml
owner: 76561197960287930
external_url: "http://example.com"

# Listen on this ip address
# 0.0.0.0 = Any
http_host: 0.0.0.0
# Listen on this port
http_port: 6006
http_static_path:
http_client_timeout: 20
# Encryption key for cookies
http_cookie_key: change-me
http_cors_origins:
- "https://example.com"

# DSN to your database
database_dsn: "postgresql://gbans:gbans@192.168.0.200:5432/gbans"
database_log_queries: false
```
## systemd service
If you are not using docker, it's recommended to create a [systemd .service](https://freedesktop.org/software/systemd/man/systemd.service.html)
file so that it can start automatically. More info on configuring this will be available at a later
date.
## Sourcemod
Place the `sourcemod/plugins/gbans.smx` file into `tf/addons/sourcemod/plugins`. Then add the config as
described below.

This config file should be places in `tf/addons/sourcemod/configs/gbans.cfg`.

```
"gbans"
{
// Remote gban server host
"host" "https://example.com"

// Remote gban server port
"port" "443"

// Unique server name for this server, the same as a "server-id"
"server_name" "example-1"

// The authentication token used to retrieve a auth token
"server_key" "YOUR_SERVER_PASSWORD"
}
```
The server gbans server is running you should now be able to see the `[GB]` message logs in the
console. With a message like below on successful authentication with the server.
```
[GB] Using config file: addons/sourcemod/configs/gbans.cfg
[GB] Request to https://gbans.example.com/v1/auth finished with status code 200 in 0.01 seconds
[GB] Successfully authenticated with gbans server

```
## Discord
To use discord you need to [create a discord application](https://discord.com/developers/applications). You will need
the following values from your application:
- Application ID (General -> Application ID)
- Token (Bot -> Token)
- Client Secret (OAuth2 -> Client Secret)
You will also need to fetch the following ids from your discord client. You will want to enable discord developer mode
to be able to easily acquire these role and channel ids through your own discord client.
- Your main server guild id.
- Logging Channels IDs
- Log Channel (default catch-all if no others are configured)
- Match logs
- Vote logs
- Appeal / Report logs
- Ban logs
- Forum logs
- Word filter logs
Care should be taken to restrict these channels to permissions as appropriate.
To enable discord connections, You must also set an oauth2 redirect (Oauth2 -> Redirects -> Add) to point to your own server.
https://example.com/discord/oauth
## IP2Location
To install the GeoLite2 databases, create an account on [IP2location Lite](https://lite.ip2location.com). After
confirmation, you'll be given a download token for use in gbans.yaml.
### Via Web
You can find a button to initiate a refresh of the database via the geo database admin gui at `https://example.com/admin/settings?section=geo_location`.
### Via cli
If instead you want to do it manually, or though cron via CLI you can try the following.
- If using Docker, start the process via `docker exec -it gbans ./gbans net update`.
- If using a compiled binary, navigate to the folder and run `./gbans net update` to start the process.
The process will take up to 30 minutes, depending on hardware, and will add around 2GB to the database when all's said
and done.
## Enabling User Location
The Servers page lets users sort by range. Gbans does not use the locations API to get data from the browser.
Instead, you're required to use Cloudflare to get the location. Gbans must be proxied through Cloudflare to
accomplish this, and setting that up is out of scope of this doc.
Once the domain is set up, go to the domain settings, the `Rules` dropdown, `Transform Rules`, and then the
`Managed Transforms` tab. Enable `Add visitor location headers`, and wait around 5 minutes for it to take effect.
You should then be able to see your location (more or less) on the servers page.
Loading

0 comments on commit 4b2ab10

Please sign in to comment.