update
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
# Nakama Server Setup for Tekton
|
||||
|
||||
This guide explains how to deploy the admin module to your Nakama server.
|
||||
|
||||
## Files
|
||||
|
||||
- `tekton_admin.ts` - TypeScript server runtime module
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Nakama server installed and running
|
||||
2. Node.js and TypeScript for compilation (if using TypeScript)
|
||||
|
||||
## Deployment Steps
|
||||
|
||||
### Option 1: TypeScript (Recommended)
|
||||
|
||||
1. **Install dependencies:**
|
||||
```bash
|
||||
npm install -g typescript
|
||||
```
|
||||
|
||||
2. **Compile TypeScript to JavaScript:**
|
||||
```bash
|
||||
cd server/nakama
|
||||
tsc tekton_admin.ts --outDir dist --lib ES2020 --types nakama-runtime
|
||||
```
|
||||
|
||||
3. **Copy to Nakama modules directory:**
|
||||
```bash
|
||||
cp dist/tekton_admin.js /path/to/nakama/data/modules/
|
||||
```
|
||||
|
||||
4. **Restart Nakama server**
|
||||
|
||||
### Option 2: Convert to Lua
|
||||
|
||||
If you prefer Lua, the TypeScript can be converted. See Nakama docs.
|
||||
|
||||
## Configuration
|
||||
|
||||
In your `nakama.yml` or `nakama-docker.yml`:
|
||||
|
||||
```yaml
|
||||
runtime:
|
||||
js_entrypoint: "tekton_admin.js"
|
||||
```
|
||||
|
||||
Or for multiple modules:
|
||||
|
||||
```yaml
|
||||
runtime:
|
||||
js_entrypoint: "index.js"
|
||||
```
|
||||
|
||||
## Role System
|
||||
|
||||
User roles are stored in account metadata:
|
||||
|
||||
```json
|
||||
{
|
||||
"role": "player" | "moderator" | "admin" | "owner"
|
||||
}
|
||||
```
|
||||
|
||||
### Setting Initial Admin
|
||||
|
||||
Run this in Nakama console or via API:
|
||||
|
||||
```sql
|
||||
UPDATE users
|
||||
SET metadata = '{"role": "owner"}'
|
||||
WHERE username = 'your_admin_username';
|
||||
```
|
||||
|
||||
Or via Nakama HTTP API:
|
||||
```bash
|
||||
curl -X PUT "http://localhost:7350/v2/console/account/{user_id}" \
|
||||
-H "Authorization: Bearer {admin_token}" \
|
||||
-d '{"metadata": "{\"role\": \"owner\"}"}'
|
||||
```
|
||||
|
||||
## RPC Endpoints
|
||||
|
||||
| Endpoint | Required Role | Description |
|
||||
|----------|--------------|-------------|
|
||||
| `admin_kick_player` | Host or Admin | Kick from match |
|
||||
| `admin_ban_player` | Admin only | Ban user |
|
||||
| `admin_unban_player` | Admin only | Unban user |
|
||||
| `admin_get_ban_list` | Admin only | Get all bans |
|
||||
| `admin_get_server_stats` | Host or Admin | Server statistics |
|
||||
| `admin_end_match` | Host or Admin | End current match |
|
||||
| `admin_set_user_role` | Owner only | Change user roles |
|
||||
|
||||
## Security Notes
|
||||
|
||||
1. **Never trust the client** - All admin operations are validated server-side
|
||||
2. **Rate limiting** - Consider adding rate limits for RPC calls
|
||||
3. **Logging** - All admin actions are logged with user ID
|
||||
4. **Ban storage** - Bans are stored in Nakama storage, not local files
|
||||
|
||||
## Testing
|
||||
|
||||
1. Create a test user with admin role
|
||||
2. Login with the admin user
|
||||
3. Press F10 in-game to open admin panel
|
||||
4. Verify kick/ban operations work
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### RPC Not Found
|
||||
- Check module is loaded: `nakama --help` or check logs
|
||||
- Verify js_entrypoint in config
|
||||
|
||||
### Permission Denied
|
||||
- Check user has correct role in metadata
|
||||
- Verify session is valid
|
||||
|
||||
### Ban Not Working
|
||||
- Check Nakama storage permissions
|
||||
- Verify user_id is correct format (UUID)
|
||||
Reference in New Issue
Block a user