Git Product home page Git Product logo

rust-ban-server's Introduction

rust-ban-server

Fully-featured ban server compliant with the new Rust (game) server's Centralized Banning feature written in Go + GORM/SQLite.


Usage

Running from the binaries
  1. Download the latest release using a compatible binary for your system

  2. Execute it: ./rust-ban-server. Available flags:

    • -l API listen address (default: :4000)
    • -q Quiet mode, omits HTTP log output.
Building from source
  • WIP

Available Endpoints

  • GET /api/status - For checking if the API is alive
  • GET /api/rustBans/count - For getting the registered ban count
  • GET /api/rustBans/<SteamID64> - For checking for banned SteamIDs (mostly used by the game server)
  • POST /api/rustBans - For adding account bans
  • DELETE /api/rustBans/<SteamID64> - For removing account bans

TODO

  • Secure the POST and DELETE endpoints with a token or access key;
  • HTTPS support;
  • Include Go test files;
  • Database importing and exporting;
  • Use limiter middleware just to be safe;
  • Create endpoint that returns all bans (might wanna implement pagination tho);

Extra

  • There's a Postman collection available for importing here, which contains basic tests to validate the API's operation. (open the link and use Ctrl + S to save the file)

GET /api/status shall always return { "status": "ok" } with status code 200.

GET /api/rustBans/count returns the JSON-encoded ban count. In case of internal errors, the API returns 500 and the JSON-encoded error.

GET /api/rustBans/<SteamID64> first validates the provided SteamID, returning the status code 400 and the JSON-encoded error message Invalid SteamID64. if it's not valid. Otherwise, it returns the JSON data as specified in the Rust wiki with status code 200 if the SteamID has been found. If it wasn't, it returns 404 with the JSON-encoded error SteamID64 not found.. In case of internal errors, the API returns 500 and the JSON-encoded error.

POST /api/rustBans requires a JSON body to be sent through, using the same format as described in the Rust wiki:

{
    "steamId": "76561198060722078",
    "reason": "Too handsome",
    "expiryDate": 1609698084
}

The provided SteamID64 is also validated, returning the status code 400 and an error message if the validation fails. It then checks if the ban already exists. If so, it gets updated and SteamID64 updated. is returned with status code 200. Otherwise, the record is created and the API returns the JSON-encoded message SteamID64 banned. with the status code 201. In case of internal errors, it returns 500 and the JSON-encoded error.

DELETE /api/rustBans/<steamID64> also validates the provided SteamID64, returning the status code 400 and a JSON-encoded error if validation fails. If it's valid, the status code 200 is returned with the JSON-encoded message SteamID64 unbanned. if the SteamID has been removed successfully. If the SteamID doesn't exist, the API returns 404 with the JSON-encoded error SteamID64 not banned.. In case of internal errors, it also returns 500 and the JSON-encoded error.

rust-ban-server's People

Contributors

hecorr avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.