accweb

repository·master·Indexed 41 days ago

https://github.com/assetto-corsa-web/accweb

A web interface for managing Assetto Corsa Competizione servers. It enables users to create, configure, start, stop, and monitor multiple server instances, view logs, and manage configurations via a browser. The tool is available as a binary for Linux and Windows, or as a Docker image.

Tokens
2.7K
Snippets
11
Records
16
Agent score
52%

What's inside accweb

  1. Backup accweb configuration and data

    master

    To perform a backup of your accweb installation, you must save two components:

    1. The config directory.
    2. The config.yml file.

    When migrating to a new version of accweb, you can place the config directory into the new installation folder. However, do not overwrite the new config.yml with your old one directly, as there may be breaking changes; instead, manually adjust the new config.yml based on your old settings.

  2. Set up a local development environment

    master

    To run accweb locally for development, ensure the dev attribute is set to true in your config.yml file.

    Frontend Development

    The frontend is built with Vue.js and located in the public directory. Use the following command to start a watcher that rebuilds the JS package whenever files are edited:

    make run-dev-frontend

    Backend Development

    The backend is written in Go and located in the internal directory. Use the following command to run the backend:

    make run-dev-backend

    Note: You must restart the backend command to see changes made to the Go code.

    # Start frontend watcher
    make run-dev-frontend
    
    # Start backend
    make run-dev-backend
  3. Install accweb manually

    master

    To install accweb on your server, follow these steps:

    1. Download the latest release from the GitHub release section.
    2. Extract the zip file to your server.
    3. Edit the config.yml file to configure your settings.
    4. Open a terminal and navigate to the installation directory.
    5. Start the application:
      • Linux: ./accweb
      • Windows: accweb.exe
    6. Access the interface via your browser at the configured IP/domain and port (e.g., http://example.com:8080).

    Important Notes:

    • If you are on Linux, you must install wine to run the Assetto Corsa Competizione server components.
    • You can specify an alternative configuration file using the --config or -c flag.
    • To enable SSL, configure the certificate settings within config.yml.
    # Start with a specific config file
    ./accweb --config server1.yml
  4. Build a release

    master

    To build a new release, use the build_release.sh script. You must provide the build version as the first argument. This will generate a directory in releases/accweb_<version> containing the build, which can then be zipped and deployed.

    ./build/build_release.sh 1.2.3
  5. Understand the ACCWeb API route hierarchy and permissions

    master

    The API is organized into groups with increasing permission levels. All routes are prefixed with /api and require JWT authentication via the Authorization header or token query parameter.

    1. Public/Authenticated API (/api/*)

    Requires a valid JWT. Common endpoints:

    • GET /servers: List all servers.
    • GET /metadata: Get API metadata.
    • GET /instance/:id: Get instance details.
    • GET /instance/:id/logs: Get instance logs.
    • GET /instance/:id/live: Get live state.
    • GET /instance/:id/export: Export instance configuration.

    2. Moderator API (/api/*)

    Requires ACCWebAuthLevel_Mod permission. Endpoints:

    • POST /servers/stop-all: Stop all running servers.
    • POST /instance/:id/start: Start a specific instance.
    • POST /instance/:id/stop: Stop a specific instance.

    3. Admin API (/api/*)

    Requires ACCWebAuthLevel_Adm permission. Endpoints:

    • POST /instance: Create a new instance.
    • POST /instance/:id: Save instance configuration.
    • DELETE /instance/:id: Delete an instance.
    • POST /instance/:id/clone: Clone an instance.
    • GET/POST /configure/global-entrylist: Manage global admins.
    • GET/POST/DELETE /configure/global-ban: Manage global bans.
  6. User authentication and JWT structure

    master

    Authentication is handled via JWT. Users are identified by a User struct containing their permissions.

    User Schema:

    • user_name (string): The username.
    • admin (bool): Full administrative access.
    • mod (bool): Moderator access (includes Read-Only).
    • read_only (bool): Read-only access.

    Authentication Flow:

    1. Login: Send a POST to /api/login with a JSON body: {"password": "your_password"}.
    2. Token: The server validates the password against config.Auth.AdminPassword, config.Auth.ModeratorPassword, or config.Auth.ReadOnlyPassword and returns a JWT.
    3. Usage: Include the token in subsequent requests using the Authorization header.
    // LoginPayload
    {
      "password": "string"
    }
    // Successful Login Response
    {
      "code": 200,
      "token": "JWT_STRING",
      "expire": "2026-01-24T12:00:00Z",
      "user_name": "username",
      "admin": true,
      "mod": true,
      "read_only": true
    }
  7. Configure accweb persistent storage via Docker volumes

    master

    The accweb service relies on three named volumes for data persistence. Ensure these are mapped correctly in your deployment to prevent data loss:

    • accweb: Maps to /accweb inside the container (application data).
    • acccerts: Maps to /sslcerts inside the container (SSL certificates).
    • accserver: Maps to /accserver inside the container (server configuration/data).
    volumes:
      - "accweb:/accweb"
      - "acccerts:/sslcerts"
      - "accserver:/accserver"
  8. Configure accweb authentication and security via environment variables

    master

    You can manage access levels and security settings for the accweb container using the following environment variables:

    Authentication Passwords

    • ACCWEB_ADMIN_PASSWORD: Password for administrative access.
    • ACCWEB_MOD_PASSWORD: Password for moderator access.
    • ACCWEB_RO_PASSWORD: Password for read-only access.

    TLS/SSL Configuration

    • ACCWEB_ENABLE_TLS: Set to "true" to enable TLS.
    • ACCWEB_CERT_FILE: Path to the certificate file inside the container (default: /sslcerts/certificate.crt).
    • ACCWEB_PRIV_FILE: Path to the private key file inside the container (default: /sslcerts/private.key).

    Other Settings

    • ACCWEB_LOGLEVEL: Sets the logging verbosity (e.g., info).
    • ACCWEB_CORS: Configures Cross-Origin Resource Sharing (e.g., * for all origins).
  9. Get the user's locale with getLocale()

    master
    The getLocale function determines the user's preferred language based on the browser's navigator.languages property. It iterates through available languages and attempts to match them against a supported list of two-character lowercase ISO language codes. If no match is found, it defaults to `
  10. Configure accweb via Docker Compose

    master

    The accweb service can be deployed using Docker Compose. It exposes the web interface on port 8080 and uses several environment variables to control security, authentication, and logging.

    Network and Ports

    • Port Mapping: The service maps host port 8080 to container port 8080 by default.
    • Network: Uses a dedicated network named accnetwork.

    Environment Variables

    VariableDescription
    ACCWEB_HOSTThe host and port the server binds to (e.g., 0.0.0.0:8080).
    ACCWEB_ENABLE_TLSEnables or disables TLS (use `
  11. Start the ACCWeb server with StartServer()

    master

    Use StartServer to initialize and run the HTTP server. It configures the Gin engine based on the config.Dev flag, sets up CORS using config.CORS.Origins, and mounts the API routes and static files. The server can run with or without TLS depending on config.Webserver.TLS.

    import (
    	"github.com/assetto-corsa-web/accweb/internal/pkg/cfg"
    	"github.com/assetto-corsa-web/accweb/internal/pkg/server_manager"
    )
    
    // config is an instance of cfg.Config
    // sM is an instance of server_manager.Service
    StartServer(config, sM)