SquadJS/squad-server/templates/readme-template.md

15 KiB

Logo Logo

SquadJS

GitHub release GitHub contributors GitHub release


GitHub issues GitHub pull requests GitHub issues Discord



About

SquadJS is a scripting framework, designed for Squad servers, that aims to handle all communication and data collection to and from the servers. Using SquadJS as the base to any of your scripting projects allows you to easily write complex plugins without having to worry about the hassle of RCON or log parsing. However, for your convenience SquadJS comes shipped with multiple plugins already built for you allowing you to experience the power of SquadJS right away.


Using SquadJS

SquadJS relies on being able to access the Squad server log directory in order to parse logs live to collect information. Thus, SquadJS must be hosted on the same server box as your Squad server or be connected to your Squad server via FTP.

Prerequisites

Installation

  1. Download SquadJS and unzip the download.
  2. Open the unzipped folder in your terminal.
  3. Install the dependencies by running yarn install in your terminal. Due to the use of Yarn Workspaces it is important to use yarn install and not npm install as this will not work and will break stuff.
  4. Configure the config.json file. See below for more details.
  5. Start SquadJS by running node index.js in your terminal.

Note - If you are interested in testing versions of SquadJS not yet released please download/clone the master branch. Please also see here for more information on our versions and release procedures.


Configuring SquadJS

SquadJS can be configured via a JSON configuration file which, by default, is located in the SquadJS and is named config.json.

The config file needs to be valid JSON syntax. If an error is thrown saying the config cannot be parsed then try putting the config into a JSON syntax checker (there's plenty to choose from that can be found via Google).

Server

Server Configuration

The following section of the configuration contains information about your Squad server.

"server": {
  "id": 1,
  "host": "xxx.xxx.xxx.xxx",
  "queryPort": 27165,
  "rconPort": 21114,
  "rconPassword": "password",
  "logReaderMode": "tail",
  "logDir": "C:/path/to/squad/log/folder",
  "ftp":{
    "port": 21,
    "user": "FTP Username",
    "password": "FTP Password",
    "useListForSize": false
  },
  "adminLists": [
    {
      "type": "local",
      "source": "C:/Users/Administrator/Desktop/Servers/sq_arty_party/SquadGame/ServerConfig/Admins.cfg",
    },
    {
      "type": "remote",
      "source": "http://yourWebsite.com/Server1/Admins.cfg",
    }
  ]
},
  • id - An integer ID to uniquely identify the server.

  • host - The IP of the server.

  • queryPort - The query port of the server.

  • rconPort - The RCON port of the server.

  • rconPassword - The RCON password of the server.

  • logReaderMode - tail will read from a local log file. ftp will read from a remote log file using the FTP protocol.

  • logDir - The folder where your Squad logs are saved. Most likely will be C:/servers/squad_server/SquadGame/Saved/Logs.

  • ftp:port - The FTP port of the server. Only required for ftp logReaderMode.

  • ftp:user - The FTP user of the server. Only required for ftp logReaderMode.

  • ftp:password - The FTP password of the server. Only required for ftp logReaderMode.

  • adminLists - Sources for identifying an admins on the server, either remote or local.


Connectors

Connector Configuration

Connectors allow SquadJS to communicate with external resources.

"connectors": {
  "discord": "Discord Login Token",
},

Connectors should be named, for example the above is named discord, and should have the associated config against it. Configs can be specified by name in plugin options. Should a connector not be needed by any plugin then the default values can be left or you can remove it from your config file.

See below for more details on connectors and their associated config.

Discord

Connects to Discord via discord.js.

"discord": "Discord Login Token",

Requires a Discord bot login token.

Databases

SquadJS uses Sequelize to connect and use a wide range of SQL databases.

The connector should be configured using any of Sequelize's single argument configuration options.

For example:

"mysql": "mysql://user:pass@example.com:5432/dbname"

or:

"sqlite": {
    "dialect": "sqlite",
    "storage": "path/to/database.sqlite"
}

See Sequelize's documentation for more details.


Plugins

Plugin Configuration

The plugins section in your config file lists all plugins built into SquadJS

  "plugins": [
    {
      "plugin": "auto-tk-warn",
      "disabled": false,
      "message": "Please apologise for ALL TKs in ALL chat!"
    }
  ]

The disabled field can be toggled between true/ false to enabled/disable the plugin.

Plugin options are also specified. A full list of plugin options can be seen below.


Verboseness

Console Output Configuration

The logger section configures how verbose a module of SquadJS will be as well as the displayed color.

  "logger": {
    "verboseness": {
      "SquadServer": 1,
      "LogParser": 1,
      "RCON": 1
    },
    "colors": {
      "SquadServer": "yellowBright",
      "SquadServerFactory": "yellowBright",
      "LogParser": "blueBright",
      "RCON": "redBright"
    }
  }

The larger the number set in the verboseness section for a specified module the more it will print to the console.



Plugins

The following is a list of plugins built into SquadJS, you can click their title for more information:

Interested in creating your own plugin? See more here

//PLUGIN-INFO//


Statement on Accuracy

Some information SquadJS collects from Squad servers was never intended or designed to be collected. As a result, it is impossible for any framework to collect the same information with 100% accuracy. SquadJS aims to get as close as possible to that figure, however, it acknowledges that this is not possible in some specific scenarios.

Below is a list of scenarios we know may cause some information to be inaccurate:

  • Use of Realtime Server and Player Information - We update server and player information periodically every 30 seconds (by default) or when we know that it requires an update. As a result, some information about the server or players may be up to 30 seconds out of date or greater if an error occurs whilst updating this information.
  • SquadJS Restarts - If SquadJS is started during an active Squad game some information will be lost or not collected correctly:
    • The current state of players will be lost. For example, if a player was wounded prior to the bot starting and then is revived/gives up after the bot is started information regarding who originally wounded them will not be known.
    • The accurate collection of some server log events will not occur. SquadJS collects players' "suffix" name, i.e. their Steam name without the clan tag added via the game settings, when they join the server and uses this to identify them in certain logs that do not include their full name. As a result, for players connecting prior to SquadJS starting some log events associated with their actions will show the player as null.
  • Duplicated Player Names - If two or more players have the same name or suffix name (see above) then SquadJS will be unable to identify them in the logs. When this occurs event logs will show the player as null. Be on the watch for groups of players who try to abuse this in order to TK or complete other malicious actions without being detected by SquadJS plugins.

SquadJS API

SquadJS pings the following data to the SquadJS API at regular intervals to assist with its development:

  • Squad server IP, query port, name & player count (including queue size).
  • SquadJS version.
  • Log reader mode, i.e. tail or ftp.
  • Plugin configuration.

At this time, this cannot be disabled.

Please note, plugin configurations do not and should not contain any sensitive information which allows us to collect this information. Any sensitive information, e.g. Discord login tokens, should be included in the connectors section of the config which is not sent to our API. It is important that developers of custom plugins maintain this approach to avoid submitting confidential information to our API.

Versions and Releases

Whilst installing SquadJS you may do the following to obtain slightly different versions:

  • Download the latest release - To get the latest stable version of SquadJS.
  • Download/clone the master branch - To get the most up to date version of SquadJS.

All changes proposed to SquadJS will be merged into the master branch prior to being released in the next stable version to allow for a period of larger-scale testing to occur. Therefore, we only recommend individuals who are willing to update regularly and partake in testing/bug reporting use the master branch. Please note, updates to the master branch will not be advertised in the SquadJS startup information, however, notifications of merged pull requests into the master branch may be found in our Discord. Once the master branch is deemed stable a release will be published and advertised via the SquadJS startup information and our Discord.

Releases will be given a version number with the format v{major}.{minor}.{patch}, e.g. v3.1.4. Changes to {major}/{minor}/{patch} will imply the following:

  • {major} - The release contains a new/updated feature that is (potentially) breaking, e.g. changes to event outputs that may cause custom plugins to break.
  • {minor} - The release contains a new/updated feature.
  • {patch} - The release contains a bug fix.

Please note, {minor}/{patch} releases may still break SquadJS installations, however, this may be prevented with configuration changes and should not require custom plugins to be updated.

Release version numbers and changelogs are managed by Release Drafter which relies on the appropriate labels being applied to pull requests. Version numbers are updated in the package.json file manually prior to publishing the release draft.

The above policy was written and put into effect after the release of SquadJS v2.0.5. A major version bump to SquadJS v3.0.0 was made to signify this policy taking affect and to draw a line under the previous poor management of releases and version numbers.

Credits

SquadJS would not be possible without the support of so many individuals and organisations. Our thanks goes out to:

  • SquadJS's contributors.
  • Thomas Smyth's GitHub sponsors.
  • subtlerod for proposing the initial log parsing idea, helping to design the log parsing process and for providing multiple servers to test with.
  • Shanomac99 and the rest of the Squad Wiki team for providing us with layer information.
  • Fourleaf, Mex, various members of ToG / ToG-L and others that helped to stage logs and participate in small scale tests.
  • Various Squad servers/communities for participating in larger scale tests and for providing feedback on plugins.
  • Everyone in the Squad RCON Discord and others who have submitted bug reports, suggestions, feedback and provided logs.

License

Boost Software License - Version 1.0 - August 17th, 2003

Copyright (c) 2020 Thomas Smyth

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.