Skip to content

Commit

Permalink
docs: updated and cleaned up many docs + minor
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Sep 27, 2021
1 parent d350dcd commit 4011f28
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 134 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Join our Discord Server: &nbsp; <a href="https://discord.gg/AFAAXzq"><img src="https://discordapp.com/api/guilds/577993482761928734/widget.png?style=shield"></img></a>
</h4>
<p align="center">
<b>txAdmin</b> is a <b>full featured</b> web panel to Manage & Monitor your FiveM/RedM Server remotely, in use by <strong>OVER 9000</strong> servers worldwide at any given time.
<b>txAdmin</b> is a <b>full featured</b> web panel to Manage & Monitor your FiveM/RedM Server remotely, in use by over <strong>10000</strong> servers worldwide at any given time.
</p>
<p align="center">
<a href="https://zap-hosting.com/txadmin4" target="_blank" rel="noopener">
Expand Down Expand Up @@ -39,7 +39,7 @@
- Server’s CPU/RAM consumption
- Live Console (with log file and command history)
- Online players chart
- Server Activity Log (connections/disconnections, kills, chat, explosions and [custom commands](docs/extra_logging.md))
- Server Activity Log (connections/disconnections, kills, chat, explosions and [custom commands](docs/custom_serverlog.md))
- Player Manager:
- [Warning system](https://www.youtube.com/watch?v=DeE0-5vtZ4E)
- Ban (temporary or permanently) system
Expand Down
114 changes: 12 additions & 102 deletions dev_notes.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
## TODO:
- [x] changed onesync to be "on" by default
- [x] noclip: update heading automatically + optimization
- [x] tweak: error logging stuff
- [x] feat: chart data rate limit
- [x] feat(web/diagnostics): redacting cfx/steam/tebex keys
- [x] feat: prevent noobs from messing setup/deploy opts
- [x] tweak(core): removed space checking in fx paths
- [x] fix(menu/spectate): fix for audio / texture loss when spectating a moving player
- [x] feat: allow two tx on same browser (closes #395)
- [x] fix(client/state): fix not properly checking for netId existing, closes #443
- [x] feat(menu/main): delete vehicle sub option
- [x] fix(core): memory leak on server log
- [x] fix(nui): auth source for zap servers
- [x] chore: updated a few dependencies
> v4.5.0
- [x] FIXME: bunch of missing stuff here
- [x] fix cause of death being always suicide (commit 9434d427)
- [x] update material ui to v5
- [x] fix(core): removed ansi color escape from srvCmdBuffer
- [x] new server log with pagination and filter
- [ ] fix player modal for new server log
- [ ] new console log
- [ ] fix logging data on diagnostics page
- [ ] document new log thing
- [ ] clean this file
- [x] document new log thing
- [x] clean this file
- [ ] update dev env to fxs/node16
- [ ] update packages & test
- [ ] update lowdb
- [ ] fix player modal for new server log
- [ ] new console log
- [ ] fix logging data on diagnostics page
- [ ] try json stream on lowdb
- [ ] write db optimization functions
- [ ] somehow still manage to fix the playerlist?
Expand All @@ -35,75 +21,14 @@



> User report: when admin use txadmin for first time, system ask him to change password, if he change it, all admins must restart to get txadmin working again
> We could totally do like a "jump in time" feature for the log page.
> A slider with 500 steps, and an array with 500 timestamps
> this array can be done by dividing the serverLog.length to get the step, then a for loop to get the timestamps

when admin use txadmin for first time, system ask him to change password, if he change it, all admins must restart to get txadmin working again



### Log Stuff:
- manter array de objetos em memória
- limitar array para 16k elementos, isso deve dar 1h em servidores muito grandes (266 eventos por minuto)
- o identificador nos objetos fica o nome e id do jogador junto do mutex do server
- interface quando receber, transforma o username em clicável
- server mantem em memória todos os ids de todos os mutex desde que o tx iniciou playerIds = {"mutex": {"id": [...]}}
- quando chegar, já coloca em um buffer que dumpa pra logfile com nome serverlog_timestamp.log, totalmente human readable
- quando player entrar, jogar no logfile "player joined {mutex|id} Nome [...identifiers], assim da pra dar um ctrl+f
- quando iniciar o tx pegar todos os logs da pasta e ir deletando os mais antigos até que o peso total da pasta seja menor que 2gb?
https://www.npmjs.com/package/file-stream-rotator
https://www.npmjs.com/package/rotating-file-stream
https://www.npmjs.com/package/simple-node-logger

Olhar links acima, caso nada ajude fazer:
- os registros ficam lá na memória com um timestamp
- página do server log via socket.io channels (tem que mudar live console tb) assim ele n precisa nunca ter o problema de fetch atualizações
- no topo do log tem duas opções: real time e older log
na opção older log, não há nenhum tipo de live ou socket.io, é só fazer paginação normal ou inline (ai os registros são inseridos por meio de uma div de página, e essa div pode ser deletada pra salvar memória)

> provavelmente não: os botões de prev e next podem ser `data-timestamp="xxx" onclick="seekOlder(this)"` e a função pega o this, le o parametro, depois remove o elemento na hora de inserir os novos dados
mover os logs do lua pra dentro do js, e parar de logar perm denied, só printar no console do child fxserver



Página de log:
- 500 items limite, tanto live quanto histórico
- quando clicar na paginação, ele faz um search no log passando "older than X" ou "newer than X", e limita 500 entradas






```js
//NOTE: could be optimized by a a for loop skipping 1k, reading single src[i] and stopping
// after it doesn't satisfy search function, then do a slice and only then run the findindex
function sliceLogNewer(source, timestamp, sliceLength) {
const limitIndex = source.findIndex((x) => x.ts > timestamp);
return events.slice(limitIndex, limitIndex + sliceLength);
}
function sliceLogOlder(source, timestamp, sliceLength) {
const limitIndex = source.findIndex((x) => x.ts >= timestamp);

//everything is older, return last few
if (limitIndex === -1) {
return events.slice(-sliceLength);

//not everything is older
} else {
return events.slice(Math.max(0, limitIndex - sliceLength), limitIndex);
}
}
```



TODO: we could totally do like a "jump in time" feature for the log page.
A slider with 500 steps, and an array with 500 timestamps
this array can be done by dividing the serverLog.length to get the step, then a for loop to get the timestamps

>/**/



Expand Down Expand Up @@ -166,8 +91,6 @@ To check of admin perm, just do `IsPlayerAceAllowed(src, 'txadmin.xxxxxx')`
> Don't use, but I'll leave it saved here: https://github.com/citizenfx/fivem/commit/fd3fae946163e8af472b7f739aed6f29eae8105f



### Admin gun
An "admin gun" where you point a gun to a player and when you point it to a player it shows this player's info, and when you "shoot it" it opens that player's modal.
If not a custom gun model, just use the point animation and make sure we have a crosshair
Expand All @@ -177,6 +100,9 @@ If not a custom gun model, just use the point animation and make sure we have a
- checksum for downloaded files
- remove_path accept array?
- every X download_github wait some time - maybe check if ref or not, to be smarter
- https://github.com/isomorphic-git/isomorphic-git
- easy recipe tester
- fully automated deploy process via CLI. You just set the recipe file path, as well as the required variables, and you can get your server running without any user interaction .

### Todozinhos:
pagina de adicionar admin precisa depois do modal, mostrar mais info:
Expand Down Expand Up @@ -274,22 +200,6 @@ We could wait for the server to finish loading, as well as print in the interfac
https://github.com/citizenfx/fivem/blob/649dac8e9c9702cc3e293f8b6a48105a9378b3f5/code/components/citizen-server-impl/src/ResourceStreamComponent.cpp#L435


### Git clone using isomorphic-git
https://github.com/isomorphic-git/isomorphic-git


### HWID tokens
https://github.com/citizenfx/fivem/commit/f52b4b994a316e1f89423b97c92d73b624bea731
```lua
local pid = 1
local hwids = {}
local max = GetNumPlayerTokens(pid)
for i = 0, max do
hwids[i+1] = GetPlayerToken(pid, i)
end
print(json.encode(hwids))
```

### Spectating with routing bucket:
Message from bubble:
> the obvious 'approach' works well enough:
Expand Down
2 changes: 1 addition & 1 deletion docs/building.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Installing & Building it (Windows/Linux)
# Installing & Building it (Windows/Linux)

**Attention: NOT RECOMMENDED for most users.**
Actually I moved this to a separate file just so people stop copying the commands without reading that you don't need to do this anymore.
Expand Down
7 changes: 4 additions & 3 deletions docs/cache_wiping.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Cache Wiping
### Cache Wiping

This feature was requested many times and in the end we decided against putting it into txAdmin for the following reasons:
- Its just not necessary with the newest builds of FiveM anymore.
- It can be dangerous considering that not configuring it correctly might end up recursively wiping out important files.
- It can be dangerous considering that not configuring it correctly might end up recursively wiping out important files.

More info: https://forum.fivem.net/t/why-people-delete-the-server-cache-folder/573851
More info: https://forum.fivem.net/t/why-people-delete-the-server-cache-folder/573851
21 changes: 14 additions & 7 deletions docs/extra_logging.md → docs/custom_serverlog.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
## Logging Extra Data
# Logging Extra Data

This feature allows you to add logging for custom commands like `/car` and `/tp`.
To do that, you will need to edit the scripts of those commands adding a **txAdmin** callback.

### How to Enable
In the client script, add the following event call inside the command function:
To do that, you will need to edit the scripts of those commands to trigger a `txaLogger:CommandExecuted` event.
> **Note: for now this only supports client commands!**
## How to Enable

In the client script, add the following event call inside the command function:

```lua
TriggerServerEvent('txaLogger:CommandExecuted', rawCommand)
```

Where `rawCommand` is a variable containing the full command with parameters.
You don't NEED to pass `rawCommand`, you can edit this string or pass anything you want.

### Example

## Example

In this example, we will log data from the `/car` command from the `CarCommand` script.

```lua
RegisterCommand('car', function(source, args, rawCommand)
TriggerServerEvent('txaLogger:CommandExecuted', rawCommand) -- txAdmin logging Callback
Expand Down
2 changes: 1 addition & 1 deletion docs/dev_interface.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Interface Development
# Interface Development
**DO NOT** Modify `css/coreui.css`. Either do a patch in the `custom.css` or modify the SCSS variables.
This doc is a reference if you are trying to re-build the `css/coreui.css` from the SCSS source.
The only thing I changed from CoreUI was the `aside-menu` size from 200px to 300px in `scss/_variables.scss : $aside-menu-width`.
Expand Down
2 changes: 1 addition & 1 deletion docs/feature_graveyard.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Feature Graveyard
# Feature Graveyard
In txAdmin codebase, we try to keep things lean, this is one of the few reasons after one year of project, our code base is not *that* bad.
And as part of the process, we "retired" many features and parts of our code base, here is a relation of the majority of them and the reason why:

Expand Down
51 changes: 51 additions & 0 deletions docs/logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Logging
In version v4.6.0, **txAdmin** added support for persistent logging with file rotate, meaning you will have an organized folder (`txData/<profile>/logs/`) containing your log files up to a maximum size and number of days.

> Note: player warn/ban/whitelist actions are not just stored in the Admin Logs, but also on the players database.
## Admin Logs:
Contains log of administrative actions as well as some automated ones like server restarts, bans, warns, settings change, live console input and so on. It does not log the user IP unless if from an authentication endpoint.
- Recent Buffer: None. Methods will read the entire file.
- Interval: 7d
- maxFiles: false
- maxSize: false

## FXServer:
Contains the log of everything that happens in the fxserver console (`stdin`, `stdout`, `stderr`). Any live console input is prefixed with `> `.
- Recent Buffer: 64~128kb
- Interval: 1d
- maxFiles: 7
- maxSize: 5G

## Server Logs:
Contains all actions that happen inside the server, for example player join/leave/die, chat messages, explosions, menu events, commands. Player sources are kept in the format `[mutex#id] name` where the mutex is an identifier of that server execution. If you search the file for a `[mutex#id]`, the first result will be the player join with all his identifiers available.
- Recent Buffer: 32k events
- Interval: 1d
- maxFiles: 7
- maxSize: 10G

## Console log (not released):
Contains everything that txAdmin prints on the console.
- Recent Buffer: last 500 lines
- Interval: 1d
- maxFiles: 7
- maxSize: 5G

## Configuring Log Rotate
The log rotation can be configured, so you can choose to store more or less logs according to your needs.
To configure it, edit your `txData/<profile>/config.json` and add an object inside `logger` with the key being one of `[admin, fxserver, server, console]`. Then add option keys according with the library reference: https://github.com/iccicci/rotating-file-stream#options

Example:
```jsonc
{
//...
"logger": {
"fxserver": {
"interval": "1d",
"maxSize": "2G", //max size of rotated files to keep
"maxFiles": 14 //max number of rotated files to keep
}
}
//...
}
```
20 changes: 10 additions & 10 deletions docs/menu.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## In-Game Menu
# In-Game Menu

txAdmin v4.0.0 introduced an in-game menu equipped with common admin functionality,
an online player browser, and a slightly trimmed down version of the web panel.

You can find a short preview video [here](https://www.youtube.com/watch?v=jWKg0VQK0sc)

### Beta Instructions
## Beta Instructions

There are currently a couple of requirements that your server must
meet in order to test the menu while in beta, these requirements *may* change
Expand All @@ -18,13 +18,13 @@ before the beta is concluded.
If you encounter any bugs that you wish to report, please visit our Discord and use the
`#menu-feedback` channel.

### Accessing the Menu
## Accessing the Menu

You can access the menu in-game by using the command `/tx` or `/txadmin`, alternatively
you can also assign a keybind by going to Settings > Key Bindings > FiveM and assigning
a keybind to the option with `Open the txAdmin Menu (monitor)`.

#### Permissions
### Permissions
Anybody who you would like to give permissions to open the menu in-game, must have a txAdmin
account with either their Discord or FiveM identifiers tied to it.

Expand All @@ -36,7 +36,7 @@ in the admin manager as shown below

![img](https://i.tasoagc.dev/qdt9)

### Convars
## Convars
The txAdmin menu has a variety of different convars that can alter the default behavior
of the menu

Expand Down Expand Up @@ -69,7 +69,7 @@ of the menu
* Default: 0
* Usage: `+set txAdminMenu-alignRight 1`

### Commands
## Commands
**tx | txadmin**
* Description: Will toggle the in-game menu. This command has an optional argument of a player id that will
quickly open up the target player's info modal.
Expand All @@ -87,20 +87,20 @@ quickly open up the target player's info modal.
* Usage: `/txAdmin-reauth`
* Required Perm: `none`

### Troubleshooting menu access
## Troubleshooting menu access

If you type `/tx` and nothing happens, your menu is probably disabled.
If you see a red message like [this](https://i.imgur.com/G83uTNC.png) and you are registered on txAdmin, do the following:
- In txAdmin Live Console, type `txAdmin-debug 1`;
- In your game F8 console, type `txAdmin-reauth`;
- Read the message printed on console for more information.

### Development
## Development

The txAdmin Menu is a Lua + TypeScript React project. Ensure you have all the dependencies by running
`npm i` in the root directory.

#### Hot Reloading Dev Environments
### Hot Reloading Dev Environments

To run the menu in the browser you can use the `dev:menu` script. This will hot reload, everytime
a change is made.
Expand All @@ -118,7 +118,7 @@ npm run dev:menu:game
**Note**: For in-game development, you must have a txAdmin development instance instance running as well as
the `dev:menu:game` script *(You can easily start one by running `npm run watch`)*.

#### General Structure
### General Structure

**Lua**: You can find the majority of the relevant Lua scripts in the `scripts/menu` directory.

Expand Down
16 changes: 15 additions & 1 deletion docs/old_todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,21 @@ More:
- [x] possibly fixed the menu playerlist sync issues;
- [x] a few small fixes and tweaks.
> v4.4.2
- [x] changed onesync to be "on" by default
- [x] noclip: update heading automatically + optimization
- [x] tweak: error logging stuff
- [x] feat: chart data rate limit
- [x] feat(web/diagnostics): redacting cfx/steam/tebex keys
- [x] feat: prevent noobs from messing setup/deploy opts
- [x] tweak(core): removed space checking in fx paths
- [x] fix(menu/spectate): fix for audio / texture loss when spectating a moving player
- [x] feat: allow two tx on same browser (closes #395)
- [x] fix(client/state): fix not properly checking for netId existing, closes #443
- [x] feat(menu/main): delete vehicle sub option
- [x] fix(core): memory leak on server log
- [x] fix(nui): auth source for zap servers
- [x] chore: updated a few dependencies
> v4.5.0
------------------------------
> NOTE: this was an attempt to get the help from the community around september 2019
Expand Down
Loading

0 comments on commit 4011f28

Please sign in to comment.